documentation.d.ts 3.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. /**
  408. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  409. * @param num the number to convert and pad
  410. * @param length the expected length of the string
  411. * @returns the padded string
  412. */
  413. static PadNumber(num: number, length: number): string;
  414. }
  415. }
  416. declare module BABYLON {
  417. /**
  418. * Class containing a set of static utilities functions for deep copy.
  419. */
  420. export class DeepCopier {
  421. /**
  422. * Tries to copy an object by duplicating every property
  423. * @param source defines the source object
  424. * @param destination defines the target object
  425. * @param doNotCopyList defines a list of properties to avoid
  426. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  427. */
  428. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  429. }
  430. }
  431. declare module BABYLON {
  432. /**
  433. * Class containing a set of static utilities functions for precision date
  434. */
  435. export class PrecisionDate {
  436. /**
  437. * Gets either window.performance.now() if supported or Date.now() else
  438. */
  439. static get Now(): number;
  440. }
  441. }
  442. declare module BABYLON {
  443. /** @hidden */
  444. export class _DevTools {
  445. static WarnImport(name: string): string;
  446. }
  447. }
  448. declare module BABYLON {
  449. /**
  450. * Interface used to define the mechanism to get data from the network
  451. */
  452. export interface IWebRequest {
  453. /**
  454. * Returns client's response url
  455. */
  456. responseURL: string;
  457. /**
  458. * Returns client's status
  459. */
  460. status: number;
  461. /**
  462. * Returns client's status as a text
  463. */
  464. statusText: string;
  465. }
  466. }
  467. declare module BABYLON {
  468. /**
  469. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  470. */
  471. export class WebRequest implements IWebRequest {
  472. private _xhr;
  473. /**
  474. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  475. * i.e. when loading files, where the server/service expects an Authorization header
  476. */
  477. static CustomRequestHeaders: {
  478. [key: string]: string;
  479. };
  480. /**
  481. * Add callback functions in this array to update all the requests before they get sent to the network
  482. */
  483. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  484. private _injectCustomRequestHeaders;
  485. /**
  486. * Gets or sets a function to be called when loading progress changes
  487. */
  488. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  489. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  490. /**
  491. * Returns client's state
  492. */
  493. get readyState(): number;
  494. /**
  495. * Returns client's status
  496. */
  497. get status(): number;
  498. /**
  499. * Returns client's status as a text
  500. */
  501. get statusText(): string;
  502. /**
  503. * Returns client's response
  504. */
  505. get response(): any;
  506. /**
  507. * Returns client's response url
  508. */
  509. get responseURL(): string;
  510. /**
  511. * Returns client's response as text
  512. */
  513. get responseText(): string;
  514. /**
  515. * Gets or sets the expected response type
  516. */
  517. get responseType(): XMLHttpRequestResponseType;
  518. set responseType(value: XMLHttpRequestResponseType);
  519. /** @hidden */
  520. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  521. /** @hidden */
  522. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  523. /**
  524. * Cancels any network activity
  525. */
  526. abort(): void;
  527. /**
  528. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  529. * @param body defines an optional request body
  530. */
  531. send(body?: Document | BodyInit | null): void;
  532. /**
  533. * Sets the request method, request URL
  534. * @param method defines the method to use (GET, POST, etc..)
  535. * @param url defines the url to connect with
  536. */
  537. open(method: string, url: string): void;
  538. /**
  539. * Sets the value of a request header.
  540. * @param name The name of the header whose value is to be set
  541. * @param value The value to set as the body of the header
  542. */
  543. setRequestHeader(name: string, value: string): void;
  544. /**
  545. * Get the string containing the text of a particular header's value.
  546. * @param name The name of the header
  547. * @returns The string containing the text of the given header name
  548. */
  549. getResponseHeader(name: string): Nullable<string>;
  550. }
  551. }
  552. declare module BABYLON {
  553. /**
  554. * File request interface
  555. */
  556. export interface IFileRequest {
  557. /**
  558. * Raised when the request is complete (success or error).
  559. */
  560. onCompleteObservable: Observable<IFileRequest>;
  561. /**
  562. * Aborts the request for a file.
  563. */
  564. abort: () => void;
  565. }
  566. }
  567. declare module BABYLON {
  568. /**
  569. * Define options used to create a render target texture
  570. */
  571. export class RenderTargetCreationOptions {
  572. /**
  573. * Specifies is mipmaps must be generated
  574. */
  575. generateMipMaps?: boolean;
  576. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  577. generateDepthBuffer?: boolean;
  578. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  579. generateStencilBuffer?: boolean;
  580. /** Defines texture type (int by default) */
  581. type?: number;
  582. /** Defines sampling mode (trilinear by default) */
  583. samplingMode?: number;
  584. /** Defines format (RGBA by default) */
  585. format?: number;
  586. }
  587. }
  588. declare module BABYLON {
  589. /** Defines the cross module used constants to avoid circular dependncies */
  590. export class Constants {
  591. /** Defines that alpha blending is disabled */
  592. static readonly ALPHA_DISABLE: number;
  593. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  594. static readonly ALPHA_ADD: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  596. static readonly ALPHA_COMBINE: number;
  597. /** Defines that alpha blending is DEST - SRC * DEST */
  598. static readonly ALPHA_SUBTRACT: number;
  599. /** Defines that alpha blending is SRC * DEST */
  600. static readonly ALPHA_MULTIPLY: number;
  601. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  602. static readonly ALPHA_MAXIMIZED: number;
  603. /** Defines that alpha blending is SRC + DEST */
  604. static readonly ALPHA_ONEONE: number;
  605. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  606. static readonly ALPHA_PREMULTIPLIED: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  609. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  612. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  613. static readonly ALPHA_INTERPOLATE: number;
  614. /**
  615. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  616. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_SCREENMODE: number;
  619. /**
  620. * Defines that alpha blending is SRC + DST
  621. * Alpha will be set to SRC ALPHA + DST ALPHA
  622. */
  623. static readonly ALPHA_ONEONE_ONEONE: number;
  624. /**
  625. * Defines that alpha blending is SRC * DST ALPHA + DST
  626. * Alpha will be set to 0
  627. */
  628. static readonly ALPHA_ALPHATOCOLOR: number;
  629. /**
  630. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  631. */
  632. static readonly ALPHA_REVERSEONEMINUS: number;
  633. /**
  634. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  635. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  636. */
  637. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST
  640. * Alpha will be set to SRC ALPHA
  641. */
  642. static readonly ALPHA_ONEONE_ONEZERO: number;
  643. /**
  644. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  645. * Alpha will be set to DST ALPHA
  646. */
  647. static readonly ALPHA_EXCLUSION: number;
  648. /** Defines that alpha blending equation a SUM */
  649. static readonly ALPHA_EQUATION_ADD: number;
  650. /** Defines that alpha blending equation a SUBSTRACTION */
  651. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  652. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  654. /** Defines that alpha blending equation a MAX operation */
  655. static readonly ALPHA_EQUATION_MAX: number;
  656. /** Defines that alpha blending equation a MIN operation */
  657. static readonly ALPHA_EQUATION_MIN: number;
  658. /**
  659. * Defines that alpha blending equation a DARKEN operation:
  660. * It takes the min of the src and sums the alpha channels.
  661. */
  662. static readonly ALPHA_EQUATION_DARKEN: number;
  663. /** Defines that the ressource is not delayed*/
  664. static readonly DELAYLOADSTATE_NONE: number;
  665. /** Defines that the ressource was successfully delay loaded */
  666. static readonly DELAYLOADSTATE_LOADED: number;
  667. /** Defines that the ressource is currently delay loading */
  668. static readonly DELAYLOADSTATE_LOADING: number;
  669. /** Defines that the ressource is delayed and has not started loading */
  670. static readonly DELAYLOADSTATE_NOTLOADED: number;
  671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  672. static readonly NEVER: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  674. static readonly ALWAYS: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  676. static readonly LESS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  678. static readonly EQUAL: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  680. static readonly LEQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  682. static readonly GREATER: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  684. static readonly GEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  686. static readonly NOTEQUAL: number;
  687. /** Passed to stencilOperation to specify that stencil value must be kept */
  688. static readonly KEEP: number;
  689. /** Passed to stencilOperation to specify that stencil value must be replaced */
  690. static readonly REPLACE: number;
  691. /** Passed to stencilOperation to specify that stencil value must be incremented */
  692. static readonly INCR: number;
  693. /** Passed to stencilOperation to specify that stencil value must be decremented */
  694. static readonly DECR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be inverted */
  696. static readonly INVERT: number;
  697. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  698. static readonly INCR_WRAP: number;
  699. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  700. static readonly DECR_WRAP: number;
  701. /** Texture is not repeating outside of 0..1 UVs */
  702. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  703. /** Texture is repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  705. /** Texture is repeating and mirrored */
  706. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  707. /** ALPHA */
  708. static readonly TEXTUREFORMAT_ALPHA: number;
  709. /** LUMINANCE */
  710. static readonly TEXTUREFORMAT_LUMINANCE: number;
  711. /** LUMINANCE_ALPHA */
  712. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  713. /** RGB */
  714. static readonly TEXTUREFORMAT_RGB: number;
  715. /** RGBA */
  716. static readonly TEXTUREFORMAT_RGBA: number;
  717. /** RED */
  718. static readonly TEXTUREFORMAT_RED: number;
  719. /** RED (2nd reference) */
  720. static readonly TEXTUREFORMAT_R: number;
  721. /** RG */
  722. static readonly TEXTUREFORMAT_RG: number;
  723. /** RED_INTEGER */
  724. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  725. /** RED_INTEGER (2nd reference) */
  726. static readonly TEXTUREFORMAT_R_INTEGER: number;
  727. /** RG_INTEGER */
  728. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  729. /** RGB_INTEGER */
  730. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  731. /** RGBA_INTEGER */
  732. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  733. /** UNSIGNED_BYTE */
  734. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  735. /** UNSIGNED_BYTE (2nd reference) */
  736. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  737. /** FLOAT */
  738. static readonly TEXTURETYPE_FLOAT: number;
  739. /** HALF_FLOAT */
  740. static readonly TEXTURETYPE_HALF_FLOAT: number;
  741. /** BYTE */
  742. static readonly TEXTURETYPE_BYTE: number;
  743. /** SHORT */
  744. static readonly TEXTURETYPE_SHORT: number;
  745. /** UNSIGNED_SHORT */
  746. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  747. /** INT */
  748. static readonly TEXTURETYPE_INT: number;
  749. /** UNSIGNED_INT */
  750. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  751. /** UNSIGNED_SHORT_4_4_4_4 */
  752. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  753. /** UNSIGNED_SHORT_5_5_5_1 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  755. /** UNSIGNED_SHORT_5_6_5 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  757. /** UNSIGNED_INT_2_10_10_10_REV */
  758. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  759. /** UNSIGNED_INT_24_8 */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  761. /** UNSIGNED_INT_10F_11F_11F_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  763. /** UNSIGNED_INT_5_9_9_9_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  765. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  766. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  767. /** nearest is mag = nearest and min = nearest and no mip */
  768. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  769. /** mag = nearest and min = nearest and mip = none */
  770. static readonly TEXTURE_NEAREST_NEAREST: number;
  771. /** Bilinear is mag = linear and min = linear and no mip */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** mag = linear and min = linear and mip = none */
  774. static readonly TEXTURE_LINEAR_LINEAR: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** Trilinear is mag = linear and min = linear and mip = linear */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  779. /** mag = nearest and min = nearest and mip = nearest */
  780. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  781. /** mag = nearest and min = linear and mip = nearest */
  782. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = linear */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  785. /** mag = nearest and min = linear and mip = none */
  786. static readonly TEXTURE_NEAREST_LINEAR: number;
  787. /** nearest is mag = nearest and min = nearest and mip = linear */
  788. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  789. /** mag = linear and min = nearest and mip = nearest */
  790. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  791. /** mag = linear and min = nearest and mip = linear */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  793. /** Bilinear is mag = linear and min = linear and mip = nearest */
  794. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = none */
  796. static readonly TEXTURE_LINEAR_NEAREST: number;
  797. /** Explicit coordinates mode */
  798. static readonly TEXTURE_EXPLICIT_MODE: number;
  799. /** Spherical coordinates mode */
  800. static readonly TEXTURE_SPHERICAL_MODE: number;
  801. /** Planar coordinates mode */
  802. static readonly TEXTURE_PLANAR_MODE: number;
  803. /** Cubic coordinates mode */
  804. static readonly TEXTURE_CUBIC_MODE: number;
  805. /** Projection coordinates mode */
  806. static readonly TEXTURE_PROJECTION_MODE: number;
  807. /** Skybox coordinates mode */
  808. static readonly TEXTURE_SKYBOX_MODE: number;
  809. /** Inverse Cubic coordinates mode */
  810. static readonly TEXTURE_INVCUBIC_MODE: number;
  811. /** Equirectangular coordinates mode */
  812. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  813. /** Equirectangular Fixed coordinates mode */
  814. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed Mirrored coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  817. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  818. static readonly SCALEMODE_FLOOR: number;
  819. /** Defines that texture rescaling will look for the nearest power of 2 size */
  820. static readonly SCALEMODE_NEAREST: number;
  821. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  822. static readonly SCALEMODE_CEILING: number;
  823. /**
  824. * The dirty texture flag value
  825. */
  826. static readonly MATERIAL_TextureDirtyFlag: number;
  827. /**
  828. * The dirty light flag value
  829. */
  830. static readonly MATERIAL_LightDirtyFlag: number;
  831. /**
  832. * The dirty fresnel flag value
  833. */
  834. static readonly MATERIAL_FresnelDirtyFlag: number;
  835. /**
  836. * The dirty attribute flag value
  837. */
  838. static readonly MATERIAL_AttributesDirtyFlag: number;
  839. /**
  840. * The dirty misc flag value
  841. */
  842. static readonly MATERIAL_MiscDirtyFlag: number;
  843. /**
  844. * The all dirty flag value
  845. */
  846. static readonly MATERIAL_AllDirtyFlag: number;
  847. /**
  848. * Returns the triangle fill mode
  849. */
  850. static readonly MATERIAL_TriangleFillMode: number;
  851. /**
  852. * Returns the wireframe mode
  853. */
  854. static readonly MATERIAL_WireFrameFillMode: number;
  855. /**
  856. * Returns the point fill mode
  857. */
  858. static readonly MATERIAL_PointFillMode: number;
  859. /**
  860. * Returns the point list draw mode
  861. */
  862. static readonly MATERIAL_PointListDrawMode: number;
  863. /**
  864. * Returns the line list draw mode
  865. */
  866. static readonly MATERIAL_LineListDrawMode: number;
  867. /**
  868. * Returns the line loop draw mode
  869. */
  870. static readonly MATERIAL_LineLoopDrawMode: number;
  871. /**
  872. * Returns the line strip draw mode
  873. */
  874. static readonly MATERIAL_LineStripDrawMode: number;
  875. /**
  876. * Returns the triangle strip draw mode
  877. */
  878. static readonly MATERIAL_TriangleStripDrawMode: number;
  879. /**
  880. * Returns the triangle fan draw mode
  881. */
  882. static readonly MATERIAL_TriangleFanDrawMode: number;
  883. /**
  884. * Stores the clock-wise side orientation
  885. */
  886. static readonly MATERIAL_ClockWiseSideOrientation: number;
  887. /**
  888. * Stores the counter clock-wise side orientation
  889. */
  890. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  891. /**
  892. * Nothing
  893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  894. */
  895. static readonly ACTION_NothingTrigger: number;
  896. /**
  897. * On pick
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnPickTrigger: number;
  901. /**
  902. * On left pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnLeftPickTrigger: number;
  906. /**
  907. * On right pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnRightPickTrigger: number;
  911. /**
  912. * On center pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnCenterPickTrigger: number;
  916. /**
  917. * On pick down
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPickDownTrigger: number;
  921. /**
  922. * On double pick
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnDoublePickTrigger: number;
  926. /**
  927. * On pick up
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnPickUpTrigger: number;
  931. /**
  932. * On pick out.
  933. * This trigger will only be raised if you also declared a OnPickDown
  934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnPickOutTrigger: number;
  937. /**
  938. * On long press
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnLongPressTrigger: number;
  942. /**
  943. * On pointer over
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnPointerOverTrigger: number;
  947. /**
  948. * On pointer out
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOutTrigger: number;
  952. /**
  953. * On every frame
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnEveryFrameTrigger: number;
  957. /**
  958. * On intersection enter
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnIntersectionEnterTrigger: number;
  962. /**
  963. * On intersection exit
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionExitTrigger: number;
  967. /**
  968. * On key down
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnKeyDownTrigger: number;
  972. /**
  973. * On key up
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyUpTrigger: number;
  977. /**
  978. * Billboard mode will only apply to Y axis
  979. */
  980. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  981. /**
  982. * Billboard mode will apply to all axes
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  985. /**
  986. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  989. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  990. * Test order :
  991. * Is the bounding sphere outside the frustum ?
  992. * If not, are the bounding box vertices outside the frustum ?
  993. * It not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  996. /** Culling strategy : Bounding Sphere Only.
  997. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  998. * It's also less accurate than the standard because some not visible objects can still be selected.
  999. * Test : is the bounding sphere outside the frustum ?
  1000. * If not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1003. /** Culling strategy : Optimistic Inclusion.
  1004. * This in an inclusion test first, then the standard exclusion test.
  1005. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1006. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1007. * Anyway, it's as accurate as the standard strategy.
  1008. * Test :
  1009. * Is the cullable object bounding sphere center in the frustum ?
  1010. * If not, apply the default culling strategy.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1013. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1014. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1015. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1016. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1017. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1018. * Test :
  1019. * Is the cullable object bounding sphere center in the frustum ?
  1020. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1023. /**
  1024. * No logging while loading
  1025. */
  1026. static readonly SCENELOADER_NO_LOGGING: number;
  1027. /**
  1028. * Minimal logging while loading
  1029. */
  1030. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1031. /**
  1032. * Summary logging while loading
  1033. */
  1034. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1035. /**
  1036. * Detailled logging while loading
  1037. */
  1038. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1039. }
  1040. }
  1041. declare module BABYLON {
  1042. /**
  1043. * This represents the required contract to create a new type of texture loader.
  1044. */
  1045. export interface IInternalTextureLoader {
  1046. /**
  1047. * Defines wether the loader supports cascade loading the different faces.
  1048. */
  1049. supportCascades: boolean;
  1050. /**
  1051. * This returns if the loader support the current file information.
  1052. * @param extension defines the file extension of the file being loaded
  1053. * @returns true if the loader can load the specified file
  1054. */
  1055. canLoad(extension: string): boolean;
  1056. /**
  1057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1058. * @param data contains the texture data
  1059. * @param texture defines the BabylonJS internal texture
  1060. * @param createPolynomials will be true if polynomials have been requested
  1061. * @param onLoad defines the callback to trigger once the texture is ready
  1062. * @param onError defines the callback to trigger in case of error
  1063. */
  1064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1065. /**
  1066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1067. * @param data contains the texture data
  1068. * @param texture defines the BabylonJS internal texture
  1069. * @param callback defines the method to call once ready to upload
  1070. */
  1071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1072. }
  1073. }
  1074. declare module BABYLON {
  1075. /**
  1076. * Class used to store and describe the pipeline context associated with an effect
  1077. */
  1078. export interface IPipelineContext {
  1079. /**
  1080. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1081. */
  1082. isAsync: boolean;
  1083. /**
  1084. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1085. */
  1086. isReady: boolean;
  1087. /** @hidden */
  1088. _getVertexShaderCode(): string | null;
  1089. /** @hidden */
  1090. _getFragmentShaderCode(): string | null;
  1091. /** @hidden */
  1092. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1093. }
  1094. }
  1095. declare module BABYLON {
  1096. /**
  1097. * Class used to store gfx data (like WebGLBuffer)
  1098. */
  1099. export class DataBuffer {
  1100. /**
  1101. * Gets or sets the number of objects referencing this buffer
  1102. */
  1103. references: number;
  1104. /** Gets or sets the size of the underlying buffer */
  1105. capacity: number;
  1106. /**
  1107. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1108. */
  1109. is32Bits: boolean;
  1110. /**
  1111. * Gets the underlying buffer
  1112. */
  1113. get underlyingResource(): any;
  1114. }
  1115. }
  1116. declare module BABYLON {
  1117. /** @hidden */
  1118. export interface IShaderProcessor {
  1119. attributeProcessor?: (attribute: string) => string;
  1120. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1121. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1122. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1123. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1124. lineProcessor?: (line: string, isFragment: boolean) => string;
  1125. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1126. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface ProcessingOptions {
  1132. defines: string[];
  1133. indexParameters: any;
  1134. isFragment: boolean;
  1135. shouldUseHighPrecisionShader: boolean;
  1136. supportsUniformBuffers: boolean;
  1137. shadersRepository: string;
  1138. includesShadersStore: {
  1139. [key: string]: string;
  1140. };
  1141. processor?: IShaderProcessor;
  1142. version: string;
  1143. platformName: string;
  1144. lookForClosingBracketForUniformBuffer?: boolean;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export class ShaderCodeNode {
  1150. line: string;
  1151. children: ShaderCodeNode[];
  1152. additionalDefineKey?: string;
  1153. additionalDefineValue?: string;
  1154. isValid(preprocessors: {
  1155. [key: string]: string;
  1156. }): boolean;
  1157. process(preprocessors: {
  1158. [key: string]: string;
  1159. }, options: ProcessingOptions): string;
  1160. }
  1161. }
  1162. declare module BABYLON {
  1163. /** @hidden */
  1164. export class ShaderCodeCursor {
  1165. private _lines;
  1166. lineIndex: number;
  1167. get currentLine(): string;
  1168. get canRead(): boolean;
  1169. set lines(value: string[]);
  1170. }
  1171. }
  1172. declare module BABYLON {
  1173. /** @hidden */
  1174. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderDefineExpression {
  1183. isTrue(preprocessors: {
  1184. [key: string]: string;
  1185. }): boolean;
  1186. private static _OperatorPriority;
  1187. private static _Stack;
  1188. static postfixToInfix(postfix: string[]): string;
  1189. static infixToPostfix(infix: string): string[];
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeTestNode extends ShaderCodeNode {
  1195. testExpression: ShaderDefineExpression;
  1196. isValid(preprocessors: {
  1197. [key: string]: string;
  1198. }): boolean;
  1199. }
  1200. }
  1201. declare module BABYLON {
  1202. /** @hidden */
  1203. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1204. define: string;
  1205. not: boolean;
  1206. constructor(define: string, not?: boolean);
  1207. isTrue(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. }
  1211. }
  1212. declare module BABYLON {
  1213. /** @hidden */
  1214. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1215. leftOperand: ShaderDefineExpression;
  1216. rightOperand: ShaderDefineExpression;
  1217. isTrue(preprocessors: {
  1218. [key: string]: string;
  1219. }): boolean;
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1225. leftOperand: ShaderDefineExpression;
  1226. rightOperand: ShaderDefineExpression;
  1227. isTrue(preprocessors: {
  1228. [key: string]: string;
  1229. }): boolean;
  1230. }
  1231. }
  1232. declare module BABYLON {
  1233. /** @hidden */
  1234. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1235. define: string;
  1236. operand: string;
  1237. testValue: string;
  1238. constructor(define: string, operand: string, testValue: string);
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module BABYLON {
  1245. /**
  1246. * Class used to enable access to offline support
  1247. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1248. */
  1249. export interface IOfflineProvider {
  1250. /**
  1251. * Gets a boolean indicating if scene must be saved in the database
  1252. */
  1253. enableSceneOffline: boolean;
  1254. /**
  1255. * Gets a boolean indicating if textures must be saved in the database
  1256. */
  1257. enableTexturesOffline: boolean;
  1258. /**
  1259. * Open the offline support and make it available
  1260. * @param successCallback defines the callback to call on success
  1261. * @param errorCallback defines the callback to call on error
  1262. */
  1263. open(successCallback: () => void, errorCallback: () => void): void;
  1264. /**
  1265. * Loads an image from the offline support
  1266. * @param url defines the url to load from
  1267. * @param image defines the target DOM image
  1268. */
  1269. loadImage(url: string, image: HTMLImageElement): void;
  1270. /**
  1271. * Loads a file from offline support
  1272. * @param url defines the URL to load from
  1273. * @param sceneLoaded defines a callback to call on success
  1274. * @param progressCallBack defines a callback to call when progress changed
  1275. * @param errorCallback defines a callback to call on error
  1276. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1277. */
  1278. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1279. }
  1280. }
  1281. declare module BABYLON {
  1282. /**
  1283. * Class used to help managing file picking and drag'n'drop
  1284. * File Storage
  1285. */
  1286. export class FilesInputStore {
  1287. /**
  1288. * List of files ready to be loaded
  1289. */
  1290. static FilesToLoad: {
  1291. [key: string]: File;
  1292. };
  1293. }
  1294. }
  1295. declare module BABYLON {
  1296. /**
  1297. * Class used to define a retry strategy when error happens while loading assets
  1298. */
  1299. export class RetryStrategy {
  1300. /**
  1301. * Function used to defines an exponential back off strategy
  1302. * @param maxRetries defines the maximum number of retries (3 by default)
  1303. * @param baseInterval defines the interval between retries
  1304. * @returns the strategy function to use
  1305. */
  1306. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1307. }
  1308. }
  1309. declare module BABYLON {
  1310. /**
  1311. * @ignore
  1312. * Application error to support additional information when loading a file
  1313. */
  1314. export abstract class BaseError extends Error {
  1315. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1316. }
  1317. }
  1318. declare module BABYLON {
  1319. /** @ignore */
  1320. export class LoadFileError extends BaseError {
  1321. request?: WebRequest;
  1322. file?: File;
  1323. /**
  1324. * Creates a new LoadFileError
  1325. * @param message defines the message of the error
  1326. * @param request defines the optional web request
  1327. * @param file defines the optional file
  1328. */
  1329. constructor(message: string, object?: WebRequest | File);
  1330. }
  1331. /** @ignore */
  1332. export class RequestFileError extends BaseError {
  1333. request: WebRequest;
  1334. /**
  1335. * Creates a new LoadFileError
  1336. * @param message defines the message of the error
  1337. * @param request defines the optional web request
  1338. */
  1339. constructor(message: string, request: WebRequest);
  1340. }
  1341. /** @ignore */
  1342. export class ReadFileError extends BaseError {
  1343. file: File;
  1344. /**
  1345. * Creates a new ReadFileError
  1346. * @param message defines the message of the error
  1347. * @param file defines the optional file
  1348. */
  1349. constructor(message: string, file: File);
  1350. }
  1351. /**
  1352. * @hidden
  1353. */
  1354. export class FileTools {
  1355. /**
  1356. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1357. */
  1358. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1359. /**
  1360. * Gets or sets the base URL to use to load assets
  1361. */
  1362. static BaseUrl: string;
  1363. /**
  1364. * Default behaviour for cors in the application.
  1365. * It can be a string if the expected behavior is identical in the entire app.
  1366. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1367. */
  1368. static CorsBehavior: string | ((url: string | string[]) => string);
  1369. /**
  1370. * Gets or sets a function used to pre-process url before using them to load assets
  1371. */
  1372. static PreprocessUrl: (url: string) => string;
  1373. /**
  1374. * Removes unwanted characters from an url
  1375. * @param url defines the url to clean
  1376. * @returns the cleaned url
  1377. */
  1378. private static _CleanUrl;
  1379. /**
  1380. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1381. * @param url define the url we are trying
  1382. * @param element define the dom element where to configure the cors policy
  1383. */
  1384. static SetCorsBehavior(url: string | string[], element: {
  1385. crossOrigin: string | null;
  1386. }): void;
  1387. /**
  1388. * Loads an image as an HTMLImageElement.
  1389. * @param input url string, ArrayBuffer, or Blob to load
  1390. * @param onLoad callback called when the image successfully loads
  1391. * @param onError callback called when the image fails to load
  1392. * @param offlineProvider offline provider for caching
  1393. * @param mimeType optional mime type
  1394. * @returns the HTMLImageElement of the loaded image
  1395. */
  1396. 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>;
  1397. /**
  1398. * Reads a file from a File object
  1399. * @param file defines the file to load
  1400. * @param onSuccess defines the callback to call when data is loaded
  1401. * @param onProgress defines the callback to call during loading process
  1402. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1403. * @param onError defines the callback to call when an error occurs
  1404. * @returns a file request object
  1405. */
  1406. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1407. /**
  1408. * Loads a file from a url
  1409. * @param url url to load
  1410. * @param onSuccess callback called when the file successfully loads
  1411. * @param onProgress callback called while file is loading (if the server supports this mode)
  1412. * @param offlineProvider defines the offline provider for caching
  1413. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1414. * @param onError callback called when the file fails to load
  1415. * @returns a file request object
  1416. */
  1417. 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;
  1418. /**
  1419. * Loads a file
  1420. * @param url url to load
  1421. * @param onSuccess callback called when the file successfully loads
  1422. * @param onProgress callback called while file is loading (if the server supports this mode)
  1423. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1424. * @param onError callback called when the file fails to load
  1425. * @param onOpened callback called when the web request is opened
  1426. * @returns a file request object
  1427. */
  1428. 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;
  1429. /**
  1430. * Checks if the loaded document was accessed via `file:`-Protocol.
  1431. * @returns boolean
  1432. */
  1433. static IsFileURL(): boolean;
  1434. }
  1435. }
  1436. declare module BABYLON {
  1437. /** @hidden */
  1438. export class ShaderProcessor {
  1439. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1440. private static _ProcessPrecision;
  1441. private static _ExtractOperation;
  1442. private static _BuildSubExpression;
  1443. private static _BuildExpression;
  1444. private static _MoveCursorWithinIf;
  1445. private static _MoveCursor;
  1446. private static _EvaluatePreProcessors;
  1447. private static _PreparePreProcessors;
  1448. private static _ProcessShaderConversion;
  1449. private static _ProcessIncludes;
  1450. /**
  1451. * Loads a file from a url
  1452. * @param url url to load
  1453. * @param onSuccess callback called when the file successfully loads
  1454. * @param onProgress callback called while file is loading (if the server supports this mode)
  1455. * @param offlineProvider defines the offline provider for caching
  1456. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1457. * @param onError callback called when the file fails to load
  1458. * @returns a file request object
  1459. * @hidden
  1460. */
  1461. 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;
  1462. }
  1463. }
  1464. declare module BABYLON {
  1465. /**
  1466. * @hidden
  1467. */
  1468. export interface IColor4Like {
  1469. r: float;
  1470. g: float;
  1471. b: float;
  1472. a: float;
  1473. }
  1474. /**
  1475. * @hidden
  1476. */
  1477. export interface IColor3Like {
  1478. r: float;
  1479. g: float;
  1480. b: float;
  1481. }
  1482. /**
  1483. * @hidden
  1484. */
  1485. export interface IVector4Like {
  1486. x: float;
  1487. y: float;
  1488. z: float;
  1489. w: float;
  1490. }
  1491. /**
  1492. * @hidden
  1493. */
  1494. export interface IVector3Like {
  1495. x: float;
  1496. y: float;
  1497. z: float;
  1498. }
  1499. /**
  1500. * @hidden
  1501. */
  1502. export interface IVector2Like {
  1503. x: float;
  1504. y: float;
  1505. }
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IMatrixLike {
  1510. toArray(): DeepImmutable<Float32Array>;
  1511. updateFlag: int;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IViewportLike {
  1517. x: float;
  1518. y: float;
  1519. width: float;
  1520. height: float;
  1521. }
  1522. /**
  1523. * @hidden
  1524. */
  1525. export interface IPlaneLike {
  1526. normal: IVector3Like;
  1527. d: float;
  1528. normalize(): void;
  1529. }
  1530. }
  1531. declare module BABYLON {
  1532. /**
  1533. * Interface used to define common properties for effect fallbacks
  1534. */
  1535. export interface IEffectFallbacks {
  1536. /**
  1537. * Removes the defines that should be removed when falling back.
  1538. * @param currentDefines defines the current define statements for the shader.
  1539. * @param effect defines the current effect we try to compile
  1540. * @returns The resulting defines with defines of the current rank removed.
  1541. */
  1542. reduce(currentDefines: string, effect: Effect): string;
  1543. /**
  1544. * Removes the fallback from the bound mesh.
  1545. */
  1546. unBindMesh(): void;
  1547. /**
  1548. * Checks to see if more fallbacks are still availible.
  1549. */
  1550. hasMoreFallbacks: boolean;
  1551. }
  1552. }
  1553. declare module BABYLON {
  1554. /**
  1555. * Class used to evalaute queries containing `and` and `or` operators
  1556. */
  1557. export class AndOrNotEvaluator {
  1558. /**
  1559. * Evaluate a query
  1560. * @param query defines the query to evaluate
  1561. * @param evaluateCallback defines the callback used to filter result
  1562. * @returns true if the query matches
  1563. */
  1564. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1565. private static _HandleParenthesisContent;
  1566. private static _SimplifyNegation;
  1567. }
  1568. }
  1569. declare module BABYLON {
  1570. /**
  1571. * Class used to store custom tags
  1572. */
  1573. export class Tags {
  1574. /**
  1575. * Adds support for tags on the given object
  1576. * @param obj defines the object to use
  1577. */
  1578. static EnableFor(obj: any): void;
  1579. /**
  1580. * Removes tags support
  1581. * @param obj defines the object to use
  1582. */
  1583. static DisableFor(obj: any): void;
  1584. /**
  1585. * Gets a boolean indicating if the given object has tags
  1586. * @param obj defines the object to use
  1587. * @returns a boolean
  1588. */
  1589. static HasTags(obj: any): boolean;
  1590. /**
  1591. * Gets the tags available on a given object
  1592. * @param obj defines the object to use
  1593. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1594. * @returns the tags
  1595. */
  1596. static GetTags(obj: any, asString?: boolean): any;
  1597. /**
  1598. * Adds tags to an object
  1599. * @param obj defines the object to use
  1600. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1601. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1602. */
  1603. static AddTagsTo(obj: any, tagsString: string): void;
  1604. /**
  1605. * @hidden
  1606. */
  1607. static _AddTagTo(obj: any, tag: string): void;
  1608. /**
  1609. * Removes specific tags from a specific object
  1610. * @param obj defines the object to use
  1611. * @param tagsString defines the tags to remove
  1612. */
  1613. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1614. /**
  1615. * @hidden
  1616. */
  1617. static _RemoveTagFrom(obj: any, tag: string): void;
  1618. /**
  1619. * Defines if tags hosted on an object match a given query
  1620. * @param obj defines the object to use
  1621. * @param tagsQuery defines the tag query
  1622. * @returns a boolean
  1623. */
  1624. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1625. }
  1626. }
  1627. declare module BABYLON {
  1628. /**
  1629. * Scalar computation library
  1630. */
  1631. export class Scalar {
  1632. /**
  1633. * Two pi constants convenient for computation.
  1634. */
  1635. static TwoPi: number;
  1636. /**
  1637. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. * @param a number
  1639. * @param b number
  1640. * @param epsilon (default = 1.401298E-45)
  1641. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1642. */
  1643. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1644. /**
  1645. * Returns a string : the upper case translation of the number i to hexadecimal.
  1646. * @param i number
  1647. * @returns the upper case translation of the number i to hexadecimal.
  1648. */
  1649. static ToHex(i: number): string;
  1650. /**
  1651. * Returns -1 if value is negative and +1 is value is positive.
  1652. * @param value the value
  1653. * @returns the value itself if it's equal to zero.
  1654. */
  1655. static Sign(value: number): number;
  1656. /**
  1657. * Returns the value itself if it's between min and max.
  1658. * Returns min if the value is lower than min.
  1659. * Returns max if the value is greater than max.
  1660. * @param value the value to clmap
  1661. * @param min the min value to clamp to (default: 0)
  1662. * @param max the max value to clamp to (default: 1)
  1663. * @returns the clamped value
  1664. */
  1665. static Clamp(value: number, min?: number, max?: number): number;
  1666. /**
  1667. * the log2 of value.
  1668. * @param value the value to compute log2 of
  1669. * @returns the log2 of value.
  1670. */
  1671. static Log2(value: number): number;
  1672. /**
  1673. * Loops the value, so that it is never larger than length and never smaller than 0.
  1674. *
  1675. * This is similar to the modulo operator but it works with floating point numbers.
  1676. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1677. * With t = 5 and length = 2.5, the result would be 0.0.
  1678. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1679. * @param value the value
  1680. * @param length the length
  1681. * @returns the looped value
  1682. */
  1683. static Repeat(value: number, length: number): number;
  1684. /**
  1685. * Normalize the value between 0.0 and 1.0 using min and max values
  1686. * @param value value to normalize
  1687. * @param min max to normalize between
  1688. * @param max min to normalize between
  1689. * @returns the normalized value
  1690. */
  1691. static Normalize(value: number, min: number, max: number): number;
  1692. /**
  1693. * Denormalize the value from 0.0 and 1.0 using min and max values
  1694. * @param normalized value to denormalize
  1695. * @param min max to denormalize between
  1696. * @param max min to denormalize between
  1697. * @returns the denormalized value
  1698. */
  1699. static Denormalize(normalized: number, min: number, max: number): number;
  1700. /**
  1701. * Calculates the shortest difference between two given angles given in degrees.
  1702. * @param current current angle in degrees
  1703. * @param target target angle in degrees
  1704. * @returns the delta
  1705. */
  1706. static DeltaAngle(current: number, target: number): number;
  1707. /**
  1708. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1709. * @param tx value
  1710. * @param length length
  1711. * @returns The returned value will move back and forth between 0 and length
  1712. */
  1713. static PingPong(tx: number, length: number): number;
  1714. /**
  1715. * Interpolates between min and max with smoothing at the limits.
  1716. *
  1717. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1718. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1719. * @param from from
  1720. * @param to to
  1721. * @param tx value
  1722. * @returns the smooth stepped value
  1723. */
  1724. static SmoothStep(from: number, to: number, tx: number): number;
  1725. /**
  1726. * Moves a value current towards target.
  1727. *
  1728. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1729. * Negative values of maxDelta pushes the value away from target.
  1730. * @param current current value
  1731. * @param target target value
  1732. * @param maxDelta max distance to move
  1733. * @returns resulting value
  1734. */
  1735. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1736. /**
  1737. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1738. *
  1739. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1740. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1741. * @param current current value
  1742. * @param target target value
  1743. * @param maxDelta max distance to move
  1744. * @returns resulting angle
  1745. */
  1746. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1747. /**
  1748. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1749. * @param start start value
  1750. * @param end target value
  1751. * @param amount amount to lerp between
  1752. * @returns the lerped value
  1753. */
  1754. static Lerp(start: number, end: number, amount: number): number;
  1755. /**
  1756. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1757. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1758. * @param start start value
  1759. * @param end target value
  1760. * @param amount amount to lerp between
  1761. * @returns the lerped value
  1762. */
  1763. static LerpAngle(start: number, end: number, amount: number): number;
  1764. /**
  1765. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1766. * @param a start value
  1767. * @param b target value
  1768. * @param value value between a and b
  1769. * @returns the inverseLerp value
  1770. */
  1771. static InverseLerp(a: number, b: number, value: number): number;
  1772. /**
  1773. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1774. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1775. * @param value1 spline value
  1776. * @param tangent1 spline value
  1777. * @param value2 spline value
  1778. * @param tangent2 spline value
  1779. * @param amount input value
  1780. * @returns hermite result
  1781. */
  1782. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1783. /**
  1784. * Returns a random float number between and min and max values
  1785. * @param min min value of random
  1786. * @param max max value of random
  1787. * @returns random value
  1788. */
  1789. static RandomRange(min: number, max: number): number;
  1790. /**
  1791. * This function returns percentage of a number in a given range.
  1792. *
  1793. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1794. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1795. * @param number to convert to percentage
  1796. * @param min min range
  1797. * @param max max range
  1798. * @returns the percentage
  1799. */
  1800. static RangeToPercent(number: number, min: number, max: number): number;
  1801. /**
  1802. * This function returns number that corresponds to the percentage in a given range.
  1803. *
  1804. * PercentToRange(0.34,0,100) will return 34.
  1805. * @param percent to convert to number
  1806. * @param min min range
  1807. * @param max max range
  1808. * @returns the number
  1809. */
  1810. static PercentToRange(percent: number, min: number, max: number): number;
  1811. /**
  1812. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1813. * @param angle The angle to normalize in radian.
  1814. * @return The converted angle.
  1815. */
  1816. static NormalizeRadians(angle: number): number;
  1817. }
  1818. }
  1819. declare module BABYLON {
  1820. /**
  1821. * Constant used to convert a value to gamma space
  1822. * @ignorenaming
  1823. */
  1824. export const ToGammaSpace: number;
  1825. /**
  1826. * Constant used to convert a value to linear space
  1827. * @ignorenaming
  1828. */
  1829. export const ToLinearSpace = 2.2;
  1830. /**
  1831. * Constant used to define the minimal number value in Babylon.js
  1832. * @ignorenaming
  1833. */
  1834. let Epsilon: number;
  1835. }
  1836. declare module BABYLON {
  1837. /**
  1838. * Class used to represent a viewport on screen
  1839. */
  1840. export class Viewport {
  1841. /** viewport left coordinate */
  1842. x: number;
  1843. /** viewport top coordinate */
  1844. y: number;
  1845. /**viewport width */
  1846. width: number;
  1847. /** viewport height */
  1848. height: number;
  1849. /**
  1850. * Creates a Viewport object located at (x, y) and sized (width, height)
  1851. * @param x defines viewport left coordinate
  1852. * @param y defines viewport top coordinate
  1853. * @param width defines the viewport width
  1854. * @param height defines the viewport height
  1855. */
  1856. constructor(
  1857. /** viewport left coordinate */
  1858. x: number,
  1859. /** viewport top coordinate */
  1860. y: number,
  1861. /**viewport width */
  1862. width: number,
  1863. /** viewport height */
  1864. height: number);
  1865. /**
  1866. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1867. * @param renderWidth defines the rendering width
  1868. * @param renderHeight defines the rendering height
  1869. * @returns a new Viewport
  1870. */
  1871. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1872. /**
  1873. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1874. * @param renderWidth defines the rendering width
  1875. * @param renderHeight defines the rendering height
  1876. * @param ref defines the target viewport
  1877. * @returns the current viewport
  1878. */
  1879. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1880. /**
  1881. * Returns a new Viewport copied from the current one
  1882. * @returns a new Viewport
  1883. */
  1884. clone(): Viewport;
  1885. }
  1886. }
  1887. declare module BABYLON {
  1888. /**
  1889. * Class containing a set of static utilities functions for arrays.
  1890. */
  1891. export class ArrayTools {
  1892. /**
  1893. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1894. * @param size the number of element to construct and put in the array
  1895. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1896. * @returns a new array filled with new objects
  1897. */
  1898. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1899. }
  1900. }
  1901. declare module BABYLON {
  1902. /**
  1903. * Class representing a vector containing 2 coordinates
  1904. */
  1905. export class Vector2 {
  1906. /** defines the first coordinate */
  1907. x: number;
  1908. /** defines the second coordinate */
  1909. y: number;
  1910. /**
  1911. * Creates a new Vector2 from the given x and y coordinates
  1912. * @param x defines the first coordinate
  1913. * @param y defines the second coordinate
  1914. */
  1915. constructor(
  1916. /** defines the first coordinate */
  1917. x?: number,
  1918. /** defines the second coordinate */
  1919. y?: number);
  1920. /**
  1921. * Gets a string with the Vector2 coordinates
  1922. * @returns a string with the Vector2 coordinates
  1923. */
  1924. toString(): string;
  1925. /**
  1926. * Gets class name
  1927. * @returns the string "Vector2"
  1928. */
  1929. getClassName(): string;
  1930. /**
  1931. * Gets current vector hash code
  1932. * @returns the Vector2 hash code as a number
  1933. */
  1934. getHashCode(): number;
  1935. /**
  1936. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1937. * @param array defines the source array
  1938. * @param index defines the offset in source array
  1939. * @returns the current Vector2
  1940. */
  1941. toArray(array: FloatArray, index?: number): Vector2;
  1942. /**
  1943. * Copy the current vector to an array
  1944. * @returns a new array with 2 elements: the Vector2 coordinates.
  1945. */
  1946. asArray(): number[];
  1947. /**
  1948. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1949. * @param source defines the source Vector2
  1950. * @returns the current updated Vector2
  1951. */
  1952. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1953. /**
  1954. * Sets the Vector2 coordinates with the given floats
  1955. * @param x defines the first coordinate
  1956. * @param y defines the second coordinate
  1957. * @returns the current updated Vector2
  1958. */
  1959. copyFromFloats(x: number, y: number): Vector2;
  1960. /**
  1961. * Sets the Vector2 coordinates with the given floats
  1962. * @param x defines the first coordinate
  1963. * @param y defines the second coordinate
  1964. * @returns the current updated Vector2
  1965. */
  1966. set(x: number, y: number): Vector2;
  1967. /**
  1968. * Add another vector with the current one
  1969. * @param otherVector defines the other vector
  1970. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1971. */
  1972. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1973. /**
  1974. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1975. * @param otherVector defines the other vector
  1976. * @param result defines the target vector
  1977. * @returns the unmodified current Vector2
  1978. */
  1979. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1980. /**
  1981. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1982. * @param otherVector defines the other vector
  1983. * @returns the current updated Vector2
  1984. */
  1985. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1986. /**
  1987. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1988. * @param otherVector defines the other vector
  1989. * @returns a new Vector2
  1990. */
  1991. addVector3(otherVector: Vector3): Vector2;
  1992. /**
  1993. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2
  1996. */
  1997. subtract(otherVector: Vector2): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Multiplies in place the current Vector2 coordinates by the given ones
  2013. * @param otherVector defines the other vector
  2014. * @returns the current updated Vector2
  2015. */
  2016. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2017. /**
  2018. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2023. /**
  2024. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2032. * @param x defines the first coordinate
  2033. * @param y defines the second coordinate
  2034. * @returns a new Vector2
  2035. */
  2036. multiplyByFloats(x: number, y: number): Vector2;
  2037. /**
  2038. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @returns a new Vector2
  2041. */
  2042. divide(otherVector: Vector2): Vector2;
  2043. /**
  2044. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2045. * @param otherVector defines the other vector
  2046. * @param result defines the target vector
  2047. * @returns the unmodified current Vector2
  2048. */
  2049. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2050. /**
  2051. * Divides the current Vector2 coordinates by the given ones
  2052. * @param otherVector defines the other vector
  2053. * @returns the current updated Vector2
  2054. */
  2055. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2056. /**
  2057. * Gets a new Vector2 with current Vector2 negated coordinates
  2058. * @returns a new Vector2
  2059. */
  2060. negate(): Vector2;
  2061. /**
  2062. * Negate this vector in place
  2063. * @returns this
  2064. */
  2065. negateInPlace(): Vector2;
  2066. /**
  2067. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2068. * @param result defines the Vector3 object where to store the result
  2069. * @returns the current Vector2
  2070. */
  2071. negateToRef(result: Vector2): Vector2;
  2072. /**
  2073. * Multiply the Vector2 coordinates by scale
  2074. * @param scale defines the scaling factor
  2075. * @returns the current updated Vector2
  2076. */
  2077. scaleInPlace(scale: number): Vector2;
  2078. /**
  2079. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2080. * @param scale defines the scaling factor
  2081. * @returns a new Vector2
  2082. */
  2083. scale(scale: number): Vector2;
  2084. /**
  2085. * Scale the current Vector2 values by a factor to a given Vector2
  2086. * @param scale defines the scale factor
  2087. * @param result defines the Vector2 object where to store the result
  2088. * @returns the unmodified current Vector2
  2089. */
  2090. scaleToRef(scale: number, result: Vector2): Vector2;
  2091. /**
  2092. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2093. * @param scale defines the scale factor
  2094. * @param result defines the Vector2 object where to store the result
  2095. * @returns the unmodified current Vector2
  2096. */
  2097. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2098. /**
  2099. * Gets a boolean if two vectors are equals
  2100. * @param otherVector defines the other vector
  2101. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2102. */
  2103. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2104. /**
  2105. * Gets a boolean if two vectors are equals (using an epsilon value)
  2106. * @param otherVector defines the other vector
  2107. * @param epsilon defines the minimal distance to consider equality
  2108. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2109. */
  2110. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2111. /**
  2112. * Gets a new Vector2 from current Vector2 floored values
  2113. * @returns a new Vector2
  2114. */
  2115. floor(): Vector2;
  2116. /**
  2117. * Gets a new Vector2 from current Vector2 floored values
  2118. * @returns a new Vector2
  2119. */
  2120. fract(): Vector2;
  2121. /**
  2122. * Gets the length of the vector
  2123. * @returns the vector length (float)
  2124. */
  2125. length(): number;
  2126. /**
  2127. * Gets the vector squared length
  2128. * @returns the vector squared length (float)
  2129. */
  2130. lengthSquared(): number;
  2131. /**
  2132. * Normalize the vector
  2133. * @returns the current updated Vector2
  2134. */
  2135. normalize(): Vector2;
  2136. /**
  2137. * Gets a new Vector2 copied from the Vector2
  2138. * @returns a new Vector2
  2139. */
  2140. clone(): Vector2;
  2141. /**
  2142. * Gets a new Vector2(0, 0)
  2143. * @returns a new Vector2
  2144. */
  2145. static Zero(): Vector2;
  2146. /**
  2147. * Gets a new Vector2(1, 1)
  2148. * @returns a new Vector2
  2149. */
  2150. static One(): Vector2;
  2151. /**
  2152. * Gets a new Vector2 set from the given index element of the given array
  2153. * @param array defines the data source
  2154. * @param offset defines the offset in the data source
  2155. * @returns a new Vector2
  2156. */
  2157. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2158. /**
  2159. * Sets "result" from the given index element of the given array
  2160. * @param array defines the data source
  2161. * @param offset defines the offset in the data source
  2162. * @param result defines the target vector
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2165. /**
  2166. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2167. * @param value1 defines 1st point of control
  2168. * @param value2 defines 2nd point of control
  2169. * @param value3 defines 3rd point of control
  2170. * @param value4 defines 4th point of control
  2171. * @param amount defines the interpolation factor
  2172. * @returns a new Vector2
  2173. */
  2174. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2175. /**
  2176. * 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".
  2177. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2178. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2179. * @param value defines the value to clamp
  2180. * @param min defines the lower limit
  2181. * @param max defines the upper limit
  2182. * @returns a new Vector2
  2183. */
  2184. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2185. /**
  2186. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2187. * @param value1 defines the 1st control point
  2188. * @param tangent1 defines the outgoing tangent
  2189. * @param value2 defines the 2nd control point
  2190. * @param tangent2 defines the incoming tangent
  2191. * @param amount defines the interpolation factor
  2192. * @returns a new Vector2
  2193. */
  2194. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2195. /**
  2196. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2197. * @param start defines the start vector
  2198. * @param end defines the end vector
  2199. * @param amount defines the interpolation factor
  2200. * @returns a new Vector2
  2201. */
  2202. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2203. /**
  2204. * Gets the dot product of the vector "left" and the vector "right"
  2205. * @param left defines first vector
  2206. * @param right defines second vector
  2207. * @returns the dot product (float)
  2208. */
  2209. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2210. /**
  2211. * Returns a new Vector2 equal to the normalized given vector
  2212. * @param vector defines the vector to normalize
  2213. * @returns a new Vector2
  2214. */
  2215. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2218. * @param left defines 1st vector
  2219. * @param right defines 2nd vector
  2220. * @returns a new Vector2
  2221. */
  2222. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2223. /**
  2224. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2225. * @param left defines 1st vector
  2226. * @param right defines 2nd vector
  2227. * @returns a new Vector2
  2228. */
  2229. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2232. * @param vector defines the vector to transform
  2233. * @param transformation defines the matrix to apply
  2234. * @returns a new Vector2
  2235. */
  2236. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2237. /**
  2238. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2239. * @param vector defines the vector to transform
  2240. * @param transformation defines the matrix to apply
  2241. * @param result defines the target vector
  2242. */
  2243. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2244. /**
  2245. * Determines if a given vector is included in a triangle
  2246. * @param p defines the vector to test
  2247. * @param p0 defines 1st triangle point
  2248. * @param p1 defines 2nd triangle point
  2249. * @param p2 defines 3rd triangle point
  2250. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2251. */
  2252. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2253. /**
  2254. * Gets the distance between the vectors "value1" and "value2"
  2255. * @param value1 defines first vector
  2256. * @param value2 defines second vector
  2257. * @returns the distance between vectors
  2258. */
  2259. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2260. /**
  2261. * Returns the squared distance between the vectors "value1" and "value2"
  2262. * @param value1 defines first vector
  2263. * @param value2 defines second vector
  2264. * @returns the squared distance between vectors
  2265. */
  2266. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2267. /**
  2268. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns a new Vector2
  2272. */
  2273. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2274. /**
  2275. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2276. * @param p defines the middle point
  2277. * @param segA defines one point of the segment
  2278. * @param segB defines the other point of the segment
  2279. * @returns the shortest distance
  2280. */
  2281. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2282. }
  2283. /**
  2284. * Class used to store (x,y,z) vector representation
  2285. * A Vector3 is the main object used in 3D geometry
  2286. * It can represent etiher the coordinates of a point the space, either a direction
  2287. * Reminder: js uses a left handed forward facing system
  2288. */
  2289. export class Vector3 {
  2290. /**
  2291. * Defines the first coordinates (on X axis)
  2292. */
  2293. x: number;
  2294. /**
  2295. * Defines the second coordinates (on Y axis)
  2296. */
  2297. y: number;
  2298. /**
  2299. * Defines the third coordinates (on Z axis)
  2300. */
  2301. z: number;
  2302. private static _UpReadOnly;
  2303. private static _ZeroReadOnly;
  2304. /**
  2305. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2306. * @param x defines the first coordinates (on X axis)
  2307. * @param y defines the second coordinates (on Y axis)
  2308. * @param z defines the third coordinates (on Z axis)
  2309. */
  2310. constructor(
  2311. /**
  2312. * Defines the first coordinates (on X axis)
  2313. */
  2314. x?: number,
  2315. /**
  2316. * Defines the second coordinates (on Y axis)
  2317. */
  2318. y?: number,
  2319. /**
  2320. * Defines the third coordinates (on Z axis)
  2321. */
  2322. z?: number);
  2323. /**
  2324. * Creates a string representation of the Vector3
  2325. * @returns a string with the Vector3 coordinates.
  2326. */
  2327. toString(): string;
  2328. /**
  2329. * Gets the class name
  2330. * @returns the string "Vector3"
  2331. */
  2332. getClassName(): string;
  2333. /**
  2334. * Creates the Vector3 hash code
  2335. * @returns a number which tends to be unique between Vector3 instances
  2336. */
  2337. getHashCode(): number;
  2338. /**
  2339. * Creates an array containing three elements : the coordinates of the Vector3
  2340. * @returns a new array of numbers
  2341. */
  2342. asArray(): number[];
  2343. /**
  2344. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2345. * @param array defines the destination array
  2346. * @param index defines the offset in the destination array
  2347. * @returns the current Vector3
  2348. */
  2349. toArray(array: FloatArray, index?: number): Vector3;
  2350. /**
  2351. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2352. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2353. */
  2354. toQuaternion(): Quaternion;
  2355. /**
  2356. * Adds the given vector to the current Vector3
  2357. * @param otherVector defines the second operand
  2358. * @returns the current updated Vector3
  2359. */
  2360. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2361. /**
  2362. * Adds the given coordinates to the current Vector3
  2363. * @param x defines the x coordinate of the operand
  2364. * @param y defines the y coordinate of the operand
  2365. * @param z defines the z coordinate of the operand
  2366. * @returns the current updated Vector3
  2367. */
  2368. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2369. /**
  2370. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2371. * @param otherVector defines the second operand
  2372. * @returns the resulting Vector3
  2373. */
  2374. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2377. * @param otherVector defines the second operand
  2378. * @param result defines the Vector3 object where to store the result
  2379. * @returns the current Vector3
  2380. */
  2381. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2382. /**
  2383. * Subtract the given vector from the current Vector3
  2384. * @param otherVector defines the second operand
  2385. * @returns the current updated Vector3
  2386. */
  2387. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2388. /**
  2389. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2390. * @param otherVector defines the second operand
  2391. * @returns the resulting Vector3
  2392. */
  2393. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2394. /**
  2395. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2396. * @param otherVector defines the second operand
  2397. * @param result defines the Vector3 object where to store the result
  2398. * @returns the current Vector3
  2399. */
  2400. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2401. /**
  2402. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2403. * @param x defines the x coordinate of the operand
  2404. * @param y defines the y coordinate of the operand
  2405. * @param z defines the z coordinate of the operand
  2406. * @returns the resulting Vector3
  2407. */
  2408. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2409. /**
  2410. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2411. * @param x defines the x coordinate of the operand
  2412. * @param y defines the y coordinate of the operand
  2413. * @param z defines the z coordinate of the operand
  2414. * @param result defines the Vector3 object where to store the result
  2415. * @returns the current Vector3
  2416. */
  2417. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2418. /**
  2419. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2420. * @returns a new Vector3
  2421. */
  2422. negate(): Vector3;
  2423. /**
  2424. * Negate this vector in place
  2425. * @returns this
  2426. */
  2427. negateInPlace(): Vector3;
  2428. /**
  2429. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2430. * @param result defines the Vector3 object where to store the result
  2431. * @returns the current Vector3
  2432. */
  2433. negateToRef(result: Vector3): Vector3;
  2434. /**
  2435. * Multiplies the Vector3 coordinates by the float "scale"
  2436. * @param scale defines the multiplier factor
  2437. * @returns the current updated Vector3
  2438. */
  2439. scaleInPlace(scale: number): Vector3;
  2440. /**
  2441. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2442. * @param scale defines the multiplier factor
  2443. * @returns a new Vector3
  2444. */
  2445. scale(scale: number): Vector3;
  2446. /**
  2447. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2448. * @param scale defines the multiplier factor
  2449. * @param result defines the Vector3 object where to store the result
  2450. * @returns the current Vector3
  2451. */
  2452. scaleToRef(scale: number, result: Vector3): Vector3;
  2453. /**
  2454. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2455. * @param scale defines the scale factor
  2456. * @param result defines the Vector3 object where to store the result
  2457. * @returns the unmodified current Vector3
  2458. */
  2459. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2460. /**
  2461. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2462. * @param otherVector defines the second operand
  2463. * @returns true if both vectors are equals
  2464. */
  2465. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2466. /**
  2467. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2468. * @param otherVector defines the second operand
  2469. * @param epsilon defines the minimal distance to define values as equals
  2470. * @returns true if both vectors are distant less than epsilon
  2471. */
  2472. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2473. /**
  2474. * Returns true if the current Vector3 coordinates equals the given floats
  2475. * @param x defines the x coordinate of the operand
  2476. * @param y defines the y coordinate of the operand
  2477. * @param z defines the z coordinate of the operand
  2478. * @returns true if both vectors are equals
  2479. */
  2480. equalsToFloats(x: number, y: number, z: number): boolean;
  2481. /**
  2482. * Multiplies the current Vector3 coordinates by the given ones
  2483. * @param otherVector defines the second operand
  2484. * @returns the current updated Vector3
  2485. */
  2486. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2487. /**
  2488. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2489. * @param otherVector defines the second operand
  2490. * @returns the new Vector3
  2491. */
  2492. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2493. /**
  2494. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2495. * @param otherVector defines the second operand
  2496. * @param result defines the Vector3 object where to store the result
  2497. * @returns the current Vector3
  2498. */
  2499. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2500. /**
  2501. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2502. * @param x defines the x coordinate of the operand
  2503. * @param y defines the y coordinate of the operand
  2504. * @param z defines the z coordinate of the operand
  2505. * @returns the new Vector3
  2506. */
  2507. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2508. /**
  2509. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2510. * @param otherVector defines the second operand
  2511. * @returns the new Vector3
  2512. */
  2513. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2514. /**
  2515. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2516. * @param otherVector defines the second operand
  2517. * @param result defines the Vector3 object where to store the result
  2518. * @returns the current Vector3
  2519. */
  2520. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2521. /**
  2522. * Divides the current Vector3 coordinates by the given ones.
  2523. * @param otherVector defines the second operand
  2524. * @returns the current updated Vector3
  2525. */
  2526. divideInPlace(otherVector: Vector3): Vector3;
  2527. /**
  2528. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2529. * @param other defines the second operand
  2530. * @returns the current updated Vector3
  2531. */
  2532. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2533. /**
  2534. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2535. * @param other defines the second operand
  2536. * @returns the current updated Vector3
  2537. */
  2538. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2539. /**
  2540. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2541. * @param x defines the x coordinate of the operand
  2542. * @param y defines the y coordinate of the operand
  2543. * @param z defines the z coordinate of the operand
  2544. * @returns the current updated Vector3
  2545. */
  2546. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2547. /**
  2548. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2549. * @param x defines the x coordinate of the operand
  2550. * @param y defines the y coordinate of the operand
  2551. * @param z defines the z coordinate of the operand
  2552. * @returns the current updated Vector3
  2553. */
  2554. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2555. /**
  2556. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2557. * Check if is non uniform within a certain amount of decimal places to account for this
  2558. * @param epsilon the amount the values can differ
  2559. * @returns if the the vector is non uniform to a certain number of decimal places
  2560. */
  2561. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2562. /**
  2563. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2564. */
  2565. get isNonUniform(): boolean;
  2566. /**
  2567. * Gets a new Vector3 from current Vector3 floored values
  2568. * @returns a new Vector3
  2569. */
  2570. floor(): Vector3;
  2571. /**
  2572. * Gets a new Vector3 from current Vector3 floored values
  2573. * @returns a new Vector3
  2574. */
  2575. fract(): Vector3;
  2576. /**
  2577. * Gets the length of the Vector3
  2578. * @returns the length of the Vector3
  2579. */
  2580. length(): number;
  2581. /**
  2582. * Gets the squared length of the Vector3
  2583. * @returns squared length of the Vector3
  2584. */
  2585. lengthSquared(): number;
  2586. /**
  2587. * Normalize the current Vector3.
  2588. * Please note that this is an in place operation.
  2589. * @returns the current updated Vector3
  2590. */
  2591. normalize(): Vector3;
  2592. /**
  2593. * Reorders the x y z properties of the vector in place
  2594. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2595. * @returns the current updated vector
  2596. */
  2597. reorderInPlace(order: string): this;
  2598. /**
  2599. * Rotates the vector around 0,0,0 by a quaternion
  2600. * @param quaternion the rotation quaternion
  2601. * @param result vector to store the result
  2602. * @returns the resulting vector
  2603. */
  2604. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2605. /**
  2606. * Rotates a vector around a given point
  2607. * @param quaternion the rotation quaternion
  2608. * @param point the point to rotate around
  2609. * @param result vector to store the result
  2610. * @returns the resulting vector
  2611. */
  2612. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2613. /**
  2614. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2615. * The cross product is then orthogonal to both current and "other"
  2616. * @param other defines the right operand
  2617. * @returns the cross product
  2618. */
  2619. cross(other: Vector3): Vector3;
  2620. /**
  2621. * Normalize the current Vector3 with the given input length.
  2622. * Please note that this is an in place operation.
  2623. * @param len the length of the vector
  2624. * @returns the current updated Vector3
  2625. */
  2626. normalizeFromLength(len: number): Vector3;
  2627. /**
  2628. * Normalize the current Vector3 to a new vector
  2629. * @returns the new Vector3
  2630. */
  2631. normalizeToNew(): Vector3;
  2632. /**
  2633. * Normalize the current Vector3 to the reference
  2634. * @param reference define the Vector3 to update
  2635. * @returns the updated Vector3
  2636. */
  2637. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2638. /**
  2639. * Creates a new Vector3 copied from the current Vector3
  2640. * @returns the new Vector3
  2641. */
  2642. clone(): Vector3;
  2643. /**
  2644. * Copies the given vector coordinates to the current Vector3 ones
  2645. * @param source defines the source Vector3
  2646. * @returns the current updated Vector3
  2647. */
  2648. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2649. /**
  2650. * Copies the given floats to the current Vector3 coordinates
  2651. * @param x defines the x coordinate of the operand
  2652. * @param y defines the y coordinate of the operand
  2653. * @param z defines the z coordinate of the operand
  2654. * @returns the current updated Vector3
  2655. */
  2656. copyFromFloats(x: number, y: number, z: number): Vector3;
  2657. /**
  2658. * Copies the given floats to the current Vector3 coordinates
  2659. * @param x defines the x coordinate of the operand
  2660. * @param y defines the y coordinate of the operand
  2661. * @param z defines the z coordinate of the operand
  2662. * @returns the current updated Vector3
  2663. */
  2664. set(x: number, y: number, z: number): Vector3;
  2665. /**
  2666. * Copies the given float to the current Vector3 coordinates
  2667. * @param v defines the x, y and z coordinates of the operand
  2668. * @returns the current updated Vector3
  2669. */
  2670. setAll(v: number): Vector3;
  2671. /**
  2672. * Get the clip factor between two vectors
  2673. * @param vector0 defines the first operand
  2674. * @param vector1 defines the second operand
  2675. * @param axis defines the axis to use
  2676. * @param size defines the size along the axis
  2677. * @returns the clip factor
  2678. */
  2679. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2680. /**
  2681. * Get angle between two vectors
  2682. * @param vector0 angle between vector0 and vector1
  2683. * @param vector1 angle between vector0 and vector1
  2684. * @param normal direction of the normal
  2685. * @return the angle between vector0 and vector1
  2686. */
  2687. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2688. /**
  2689. * Returns a new Vector3 set from the index "offset" of the given array
  2690. * @param array defines the source array
  2691. * @param offset defines the offset in the source array
  2692. * @returns the new Vector3
  2693. */
  2694. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2695. /**
  2696. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2697. * @param array defines the source array
  2698. * @param offset defines the offset in the source array
  2699. * @returns the new Vector3
  2700. * @deprecated Please use FromArray instead.
  2701. */
  2702. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2703. /**
  2704. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2705. * @param array defines the source array
  2706. * @param offset defines the offset in the source array
  2707. * @param result defines the Vector3 where to store the result
  2708. */
  2709. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2710. /**
  2711. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2712. * @param array defines the source array
  2713. * @param offset defines the offset in the source array
  2714. * @param result defines the Vector3 where to store the result
  2715. * @deprecated Please use FromArrayToRef instead.
  2716. */
  2717. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2718. /**
  2719. * Sets the given vector "result" with the given floats.
  2720. * @param x defines the x coordinate of the source
  2721. * @param y defines the y coordinate of the source
  2722. * @param z defines the z coordinate of the source
  2723. * @param result defines the Vector3 where to store the result
  2724. */
  2725. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2726. /**
  2727. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2728. * @returns a new empty Vector3
  2729. */
  2730. static Zero(): Vector3;
  2731. /**
  2732. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2733. * @returns a new unit Vector3
  2734. */
  2735. static One(): Vector3;
  2736. /**
  2737. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2738. * @returns a new up Vector3
  2739. */
  2740. static Up(): Vector3;
  2741. /**
  2742. * Gets a up Vector3 that must not be updated
  2743. */
  2744. static get UpReadOnly(): DeepImmutable<Vector3>;
  2745. /**
  2746. * Gets a zero Vector3 that must not be updated
  2747. */
  2748. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2749. /**
  2750. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2751. * @returns a new down Vector3
  2752. */
  2753. static Down(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2756. * @returns a new forward Vector3
  2757. */
  2758. static Forward(): Vector3;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2761. * @returns a new forward Vector3
  2762. */
  2763. static Backward(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2766. * @returns a new right Vector3
  2767. */
  2768. static Right(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2771. * @returns a new left Vector3
  2772. */
  2773. static Left(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2776. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2777. * @param vector defines the Vector3 to transform
  2778. * @param transformation defines the transformation matrix
  2779. * @returns the transformed Vector3
  2780. */
  2781. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2782. /**
  2783. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2784. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2785. * @param vector defines the Vector3 to transform
  2786. * @param transformation defines the transformation matrix
  2787. * @param result defines the Vector3 where to store the result
  2788. */
  2789. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2790. /**
  2791. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2792. * This method computes tranformed coordinates only, not transformed direction vectors
  2793. * @param x define the x coordinate of the source vector
  2794. * @param y define the y coordinate of the source vector
  2795. * @param z define the z coordinate of the source vector
  2796. * @param transformation defines the transformation matrix
  2797. * @param result defines the Vector3 where to store the result
  2798. */
  2799. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2800. /**
  2801. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2802. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2803. * @param vector defines the Vector3 to transform
  2804. * @param transformation defines the transformation matrix
  2805. * @returns the new Vector3
  2806. */
  2807. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2808. /**
  2809. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2810. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2811. * @param vector defines the Vector3 to transform
  2812. * @param transformation defines the transformation matrix
  2813. * @param result defines the Vector3 where to store the result
  2814. */
  2815. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2816. /**
  2817. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2818. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2819. * @param x define the x coordinate of the source vector
  2820. * @param y define the y coordinate of the source vector
  2821. * @param z define the z coordinate of the source vector
  2822. * @param transformation defines the transformation matrix
  2823. * @param result defines the Vector3 where to store the result
  2824. */
  2825. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2826. /**
  2827. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2828. * @param value1 defines the first control point
  2829. * @param value2 defines the second control point
  2830. * @param value3 defines the third control point
  2831. * @param value4 defines the fourth control point
  2832. * @param amount defines the amount on the spline to use
  2833. * @returns the new Vector3
  2834. */
  2835. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2836. /**
  2837. * 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"
  2838. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2839. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2840. * @param value defines the current value
  2841. * @param min defines the lower range value
  2842. * @param max defines the upper range value
  2843. * @returns the new Vector3
  2844. */
  2845. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2846. /**
  2847. * 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"
  2848. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2849. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2850. * @param value defines the current value
  2851. * @param min defines the lower range value
  2852. * @param max defines the upper range value
  2853. * @param result defines the Vector3 where to store the result
  2854. */
  2855. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2856. /**
  2857. * Checks if a given vector is inside a specific range
  2858. * @param v defines the vector to test
  2859. * @param min defines the minimum range
  2860. * @param max defines the maximum range
  2861. */
  2862. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2863. /**
  2864. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2865. * @param value1 defines the first control point
  2866. * @param tangent1 defines the first tangent vector
  2867. * @param value2 defines the second control point
  2868. * @param tangent2 defines the second tangent vector
  2869. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2870. * @returns the new Vector3
  2871. */
  2872. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2873. /**
  2874. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2875. * @param start defines the start value
  2876. * @param end defines the end value
  2877. * @param amount max defines amount between both (between 0 and 1)
  2878. * @returns the new Vector3
  2879. */
  2880. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2881. /**
  2882. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2883. * @param start defines the start value
  2884. * @param end defines the end value
  2885. * @param amount max defines amount between both (between 0 and 1)
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2889. /**
  2890. * Returns the dot product (float) between the vectors "left" and "right"
  2891. * @param left defines the left operand
  2892. * @param right defines the right operand
  2893. * @returns the dot product
  2894. */
  2895. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2896. /**
  2897. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2898. * The cross product is then orthogonal to both "left" and "right"
  2899. * @param left defines the left operand
  2900. * @param right defines the right operand
  2901. * @returns the cross product
  2902. */
  2903. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2904. /**
  2905. * Sets the given vector "result" with the cross product of "left" and "right"
  2906. * The cross product is then orthogonal to both "left" and "right"
  2907. * @param left defines the left operand
  2908. * @param right defines the right operand
  2909. * @param result defines the Vector3 where to store the result
  2910. */
  2911. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2912. /**
  2913. * Returns a new Vector3 as the normalization of the given vector
  2914. * @param vector defines the Vector3 to normalize
  2915. * @returns the new Vector3
  2916. */
  2917. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2918. /**
  2919. * Sets the given vector "result" with the normalization of the given first vector
  2920. * @param vector defines the Vector3 to normalize
  2921. * @param result defines the Vector3 where to store the result
  2922. */
  2923. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2924. /**
  2925. * Project a Vector3 onto screen space
  2926. * @param vector defines the Vector3 to project
  2927. * @param world defines the world matrix to use
  2928. * @param transform defines the transform (view x projection) matrix to use
  2929. * @param viewport defines the screen viewport to use
  2930. * @returns the new Vector3
  2931. */
  2932. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2933. /** @hidden */
  2934. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2935. /**
  2936. * Unproject from screen space to object space
  2937. * @param source defines the screen space Vector3 to use
  2938. * @param viewportWidth defines the current width of the viewport
  2939. * @param viewportHeight defines the current height of the viewport
  2940. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2941. * @param transform defines the transform (view x projection) matrix to use
  2942. * @returns the new Vector3
  2943. */
  2944. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2945. /**
  2946. * Unproject from screen space to object space
  2947. * @param source defines the screen space Vector3 to use
  2948. * @param viewportWidth defines the current width of the viewport
  2949. * @param viewportHeight defines the current height of the viewport
  2950. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2951. * @param view defines the view matrix to use
  2952. * @param projection defines the projection matrix to use
  2953. * @returns the new Vector3
  2954. */
  2955. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2956. /**
  2957. * Unproject from screen space to object space
  2958. * @param source defines the screen space Vector3 to use
  2959. * @param viewportWidth defines the current width of the viewport
  2960. * @param viewportHeight defines the current height of the viewport
  2961. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2962. * @param view defines the view matrix to use
  2963. * @param projection defines the projection matrix to use
  2964. * @param result defines the Vector3 where to store the result
  2965. */
  2966. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2967. /**
  2968. * Unproject from screen space to object space
  2969. * @param sourceX defines the screen space x coordinate to use
  2970. * @param sourceY defines the screen space y coordinate to use
  2971. * @param sourceZ defines the screen space z coordinate to use
  2972. * @param viewportWidth defines the current width of the viewport
  2973. * @param viewportHeight defines the current height of the viewport
  2974. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2975. * @param view defines the view matrix to use
  2976. * @param projection defines the projection matrix to use
  2977. * @param result defines the Vector3 where to store the result
  2978. */
  2979. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2980. /**
  2981. * Gets the minimal coordinate values between two Vector3
  2982. * @param left defines the first operand
  2983. * @param right defines the second operand
  2984. * @returns the new Vector3
  2985. */
  2986. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2987. /**
  2988. * Gets the maximal coordinate values between two Vector3
  2989. * @param left defines the first operand
  2990. * @param right defines the second operand
  2991. * @returns the new Vector3
  2992. */
  2993. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2994. /**
  2995. * Returns the distance between the vectors "value1" and "value2"
  2996. * @param value1 defines the first operand
  2997. * @param value2 defines the second operand
  2998. * @returns the distance
  2999. */
  3000. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3001. /**
  3002. * Returns the squared distance between the vectors "value1" and "value2"
  3003. * @param value1 defines the first operand
  3004. * @param value2 defines the second operand
  3005. * @returns the squared distance
  3006. */
  3007. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3008. /**
  3009. * Returns a new Vector3 located at the center between "value1" and "value2"
  3010. * @param value1 defines the first operand
  3011. * @param value2 defines the second operand
  3012. * @returns the new Vector3
  3013. */
  3014. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3015. /**
  3016. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3017. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3018. * to something in order to rotate it from its local system to the given target system
  3019. * Note: axis1, axis2 and axis3 are normalized during this operation
  3020. * @param axis1 defines the first axis
  3021. * @param axis2 defines the second axis
  3022. * @param axis3 defines the third axis
  3023. * @returns a new Vector3
  3024. */
  3025. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3026. /**
  3027. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3028. * @param axis1 defines the first axis
  3029. * @param axis2 defines the second axis
  3030. * @param axis3 defines the third axis
  3031. * @param ref defines the Vector3 where to store the result
  3032. */
  3033. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3034. }
  3035. /**
  3036. * Vector4 class created for EulerAngle class conversion to Quaternion
  3037. */
  3038. export class Vector4 {
  3039. /** x value of the vector */
  3040. x: number;
  3041. /** y value of the vector */
  3042. y: number;
  3043. /** z value of the vector */
  3044. z: number;
  3045. /** w value of the vector */
  3046. w: number;
  3047. /**
  3048. * Creates a Vector4 object from the given floats.
  3049. * @param x x value of the vector
  3050. * @param y y value of the vector
  3051. * @param z z value of the vector
  3052. * @param w w value of the vector
  3053. */
  3054. constructor(
  3055. /** x value of the vector */
  3056. x: number,
  3057. /** y value of the vector */
  3058. y: number,
  3059. /** z value of the vector */
  3060. z: number,
  3061. /** w value of the vector */
  3062. w: number);
  3063. /**
  3064. * Returns the string with the Vector4 coordinates.
  3065. * @returns a string containing all the vector values
  3066. */
  3067. toString(): string;
  3068. /**
  3069. * Returns the string "Vector4".
  3070. * @returns "Vector4"
  3071. */
  3072. getClassName(): string;
  3073. /**
  3074. * Returns the Vector4 hash code.
  3075. * @returns a unique hash code
  3076. */
  3077. getHashCode(): number;
  3078. /**
  3079. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3080. * @returns the resulting array
  3081. */
  3082. asArray(): number[];
  3083. /**
  3084. * Populates the given array from the given index with the Vector4 coordinates.
  3085. * @param array array to populate
  3086. * @param index index of the array to start at (default: 0)
  3087. * @returns the Vector4.
  3088. */
  3089. toArray(array: FloatArray, index?: number): Vector4;
  3090. /**
  3091. * Adds the given vector to the current Vector4.
  3092. * @param otherVector the vector to add
  3093. * @returns the updated Vector4.
  3094. */
  3095. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3096. /**
  3097. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3098. * @param otherVector the vector to add
  3099. * @returns the resulting vector
  3100. */
  3101. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3102. /**
  3103. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3104. * @param otherVector the vector to add
  3105. * @param result the vector to store the result
  3106. * @returns the current Vector4.
  3107. */
  3108. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3109. /**
  3110. * Subtract in place the given vector from the current Vector4.
  3111. * @param otherVector the vector to subtract
  3112. * @returns the updated Vector4.
  3113. */
  3114. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3115. /**
  3116. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3117. * @param otherVector the vector to add
  3118. * @returns the new vector with the result
  3119. */
  3120. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3121. /**
  3122. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3123. * @param otherVector the vector to subtract
  3124. * @param result the vector to store the result
  3125. * @returns the current Vector4.
  3126. */
  3127. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3128. /**
  3129. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3130. */
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. * @param x value to subtract
  3134. * @param y value to subtract
  3135. * @param z value to subtract
  3136. * @param w value to subtract
  3137. * @returns new vector containing the result
  3138. */
  3139. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3140. /**
  3141. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3142. * @param x value to subtract
  3143. * @param y value to subtract
  3144. * @param z value to subtract
  3145. * @param w value to subtract
  3146. * @param result the vector to store the result in
  3147. * @returns the current Vector4.
  3148. */
  3149. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3150. /**
  3151. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3152. * @returns a new vector with the negated values
  3153. */
  3154. negate(): Vector4;
  3155. /**
  3156. * Negate this vector in place
  3157. * @returns this
  3158. */
  3159. negateInPlace(): Vector4;
  3160. /**
  3161. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3162. * @param result defines the Vector3 object where to store the result
  3163. * @returns the current Vector4
  3164. */
  3165. negateToRef(result: Vector4): Vector4;
  3166. /**
  3167. * Multiplies the current Vector4 coordinates by scale (float).
  3168. * @param scale the number to scale with
  3169. * @returns the updated Vector4.
  3170. */
  3171. scaleInPlace(scale: number): Vector4;
  3172. /**
  3173. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3174. * @param scale the number to scale with
  3175. * @returns a new vector with the result
  3176. */
  3177. scale(scale: number): Vector4;
  3178. /**
  3179. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3180. * @param scale the number to scale with
  3181. * @param result a vector to store the result in
  3182. * @returns the current Vector4.
  3183. */
  3184. scaleToRef(scale: number, result: Vector4): Vector4;
  3185. /**
  3186. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3187. * @param scale defines the scale factor
  3188. * @param result defines the Vector4 object where to store the result
  3189. * @returns the unmodified current Vector4
  3190. */
  3191. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3192. /**
  3193. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3194. * @param otherVector the vector to compare against
  3195. * @returns true if they are equal
  3196. */
  3197. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3198. /**
  3199. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3200. * @param otherVector vector to compare against
  3201. * @param epsilon (Default: very small number)
  3202. * @returns true if they are equal
  3203. */
  3204. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3205. /**
  3206. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3207. * @param x x value to compare against
  3208. * @param y y value to compare against
  3209. * @param z z value to compare against
  3210. * @param w w value to compare against
  3211. * @returns true if equal
  3212. */
  3213. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3214. /**
  3215. * Multiplies in place the current Vector4 by the given one.
  3216. * @param otherVector vector to multiple with
  3217. * @returns the updated Vector4.
  3218. */
  3219. multiplyInPlace(otherVector: Vector4): Vector4;
  3220. /**
  3221. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3222. * @param otherVector vector to multiple with
  3223. * @returns resulting new vector
  3224. */
  3225. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3226. /**
  3227. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3228. * @param otherVector vector to multiple with
  3229. * @param result vector to store the result
  3230. * @returns the current Vector4.
  3231. */
  3232. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3233. /**
  3234. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3235. * @param x x value multiply with
  3236. * @param y y value multiply with
  3237. * @param z z value multiply with
  3238. * @param w w value multiply with
  3239. * @returns resulting new vector
  3240. */
  3241. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3242. /**
  3243. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3244. * @param otherVector vector to devide with
  3245. * @returns resulting new vector
  3246. */
  3247. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3248. /**
  3249. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3250. * @param otherVector vector to devide with
  3251. * @param result vector to store the result
  3252. * @returns the current Vector4.
  3253. */
  3254. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3255. /**
  3256. * Divides the current Vector3 coordinates by the given ones.
  3257. * @param otherVector vector to devide with
  3258. * @returns the updated Vector3.
  3259. */
  3260. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3261. /**
  3262. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3263. * @param other defines the second operand
  3264. * @returns the current updated Vector4
  3265. */
  3266. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3267. /**
  3268. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3269. * @param other defines the second operand
  3270. * @returns the current updated Vector4
  3271. */
  3272. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3273. /**
  3274. * Gets a new Vector4 from current Vector4 floored values
  3275. * @returns a new Vector4
  3276. */
  3277. floor(): Vector4;
  3278. /**
  3279. * Gets a new Vector4 from current Vector3 floored values
  3280. * @returns a new Vector4
  3281. */
  3282. fract(): Vector4;
  3283. /**
  3284. * Returns the Vector4 length (float).
  3285. * @returns the length
  3286. */
  3287. length(): number;
  3288. /**
  3289. * Returns the Vector4 squared length (float).
  3290. * @returns the length squared
  3291. */
  3292. lengthSquared(): number;
  3293. /**
  3294. * Normalizes in place the Vector4.
  3295. * @returns the updated Vector4.
  3296. */
  3297. normalize(): Vector4;
  3298. /**
  3299. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3300. * @returns this converted to a new vector3
  3301. */
  3302. toVector3(): Vector3;
  3303. /**
  3304. * Returns a new Vector4 copied from the current one.
  3305. * @returns the new cloned vector
  3306. */
  3307. clone(): Vector4;
  3308. /**
  3309. * Updates the current Vector4 with the given one coordinates.
  3310. * @param source the source vector to copy from
  3311. * @returns the updated Vector4.
  3312. */
  3313. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3314. /**
  3315. * Updates the current Vector4 coordinates with the given floats.
  3316. * @param x float to copy from
  3317. * @param y float to copy from
  3318. * @param z float to copy from
  3319. * @param w float to copy from
  3320. * @returns the updated Vector4.
  3321. */
  3322. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Updates the current Vector4 coordinates with the given floats.
  3325. * @param x float to set from
  3326. * @param y float to set from
  3327. * @param z float to set from
  3328. * @param w float to set from
  3329. * @returns the updated Vector4.
  3330. */
  3331. set(x: number, y: number, z: number, w: number): Vector4;
  3332. /**
  3333. * Copies the given float to the current Vector3 coordinates
  3334. * @param v defines the x, y, z and w coordinates of the operand
  3335. * @returns the current updated Vector3
  3336. */
  3337. setAll(v: number): Vector4;
  3338. /**
  3339. * Returns a new Vector4 set from the starting index of the given array.
  3340. * @param array the array to pull values from
  3341. * @param offset the offset into the array to start at
  3342. * @returns the new vector
  3343. */
  3344. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3345. /**
  3346. * Updates the given vector "result" from the starting index of the given array.
  3347. * @param array the array to pull values from
  3348. * @param offset the offset into the array to start at
  3349. * @param result the vector to store the result in
  3350. */
  3351. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3352. /**
  3353. * Updates the given vector "result" from the starting index of the given Float32Array.
  3354. * @param array the array to pull values from
  3355. * @param offset the offset into the array to start at
  3356. * @param result the vector to store the result in
  3357. */
  3358. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3359. /**
  3360. * Updates the given vector "result" coordinates from the given floats.
  3361. * @param x float to set from
  3362. * @param y float to set from
  3363. * @param z float to set from
  3364. * @param w float to set from
  3365. * @param result the vector to the floats in
  3366. */
  3367. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3368. /**
  3369. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3370. * @returns the new vector
  3371. */
  3372. static Zero(): Vector4;
  3373. /**
  3374. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3375. * @returns the new vector
  3376. */
  3377. static One(): Vector4;
  3378. /**
  3379. * Returns a new normalized Vector4 from the given one.
  3380. * @param vector the vector to normalize
  3381. * @returns the vector
  3382. */
  3383. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3384. /**
  3385. * Updates the given vector "result" from the normalization of the given one.
  3386. * @param vector the vector to normalize
  3387. * @param result the vector to store the result in
  3388. */
  3389. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3390. /**
  3391. * Returns a vector with the minimum values from the left and right vectors
  3392. * @param left left vector to minimize
  3393. * @param right right vector to minimize
  3394. * @returns a new vector with the minimum of the left and right vector values
  3395. */
  3396. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3397. /**
  3398. * Returns a vector with the maximum values from the left and right vectors
  3399. * @param left left vector to maximize
  3400. * @param right right vector to maximize
  3401. * @returns a new vector with the maximum of the left and right vector values
  3402. */
  3403. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Returns the distance (float) between the vectors "value1" and "value2".
  3406. * @param value1 value to calulate the distance between
  3407. * @param value2 value to calulate the distance between
  3408. * @return the distance between the two vectors
  3409. */
  3410. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3411. /**
  3412. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3413. * @param value1 value to calulate the distance between
  3414. * @param value2 value to calulate the distance between
  3415. * @return the distance between the two vectors squared
  3416. */
  3417. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3418. /**
  3419. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3420. * @param value1 value to calulate the center between
  3421. * @param value2 value to calulate the center between
  3422. * @return the center between the two vectors
  3423. */
  3424. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @returns the new vector
  3431. */
  3432. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param vector the vector to transform
  3437. * @param transformation the transformation matrix to apply
  3438. * @param result the vector to store the result in
  3439. */
  3440. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3441. /**
  3442. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3443. * This methods computes transformed normalized direction vectors only.
  3444. * @param x value to transform
  3445. * @param y value to transform
  3446. * @param z value to transform
  3447. * @param w value to transform
  3448. * @param transformation the transformation matrix to apply
  3449. * @param result the vector to store the results in
  3450. */
  3451. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3452. /**
  3453. * Creates a new Vector4 from a Vector3
  3454. * @param source defines the source data
  3455. * @param w defines the 4th component (default is 0)
  3456. * @returns a new Vector4
  3457. */
  3458. static FromVector3(source: Vector3, w?: number): Vector4;
  3459. }
  3460. /**
  3461. * Class used to store quaternion data
  3462. * @see https://en.wikipedia.org/wiki/Quaternion
  3463. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3464. */
  3465. export class Quaternion {
  3466. /** defines the first component (0 by default) */
  3467. x: number;
  3468. /** defines the second component (0 by default) */
  3469. y: number;
  3470. /** defines the third component (0 by default) */
  3471. z: number;
  3472. /** defines the fourth component (1.0 by default) */
  3473. w: number;
  3474. /**
  3475. * Creates a new Quaternion from the given floats
  3476. * @param x defines the first component (0 by default)
  3477. * @param y defines the second component (0 by default)
  3478. * @param z defines the third component (0 by default)
  3479. * @param w defines the fourth component (1.0 by default)
  3480. */
  3481. constructor(
  3482. /** defines the first component (0 by default) */
  3483. x?: number,
  3484. /** defines the second component (0 by default) */
  3485. y?: number,
  3486. /** defines the third component (0 by default) */
  3487. z?: number,
  3488. /** defines the fourth component (1.0 by default) */
  3489. w?: number);
  3490. /**
  3491. * Gets a string representation for the current quaternion
  3492. * @returns a string with the Quaternion coordinates
  3493. */
  3494. toString(): string;
  3495. /**
  3496. * Gets the class name of the quaternion
  3497. * @returns the string "Quaternion"
  3498. */
  3499. getClassName(): string;
  3500. /**
  3501. * Gets a hash code for this quaternion
  3502. * @returns the quaternion hash code
  3503. */
  3504. getHashCode(): number;
  3505. /**
  3506. * Copy the quaternion to an array
  3507. * @returns a new array populated with 4 elements from the quaternion coordinates
  3508. */
  3509. asArray(): number[];
  3510. /**
  3511. * Check if two quaternions are equals
  3512. * @param otherQuaternion defines the second operand
  3513. * @return true if the current quaternion and the given one coordinates are strictly equals
  3514. */
  3515. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3516. /**
  3517. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3518. * @param otherQuaternion defines the other quaternion
  3519. * @param epsilon defines the minimal distance to consider equality
  3520. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3521. */
  3522. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3523. /**
  3524. * Clone the current quaternion
  3525. * @returns a new quaternion copied from the current one
  3526. */
  3527. clone(): Quaternion;
  3528. /**
  3529. * Copy a quaternion to the current one
  3530. * @param other defines the other quaternion
  3531. * @returns the updated current quaternion
  3532. */
  3533. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3534. /**
  3535. * Updates the current quaternion with the given float coordinates
  3536. * @param x defines the x coordinate
  3537. * @param y defines the y coordinate
  3538. * @param z defines the z coordinate
  3539. * @param w defines the w coordinate
  3540. * @returns the updated current quaternion
  3541. */
  3542. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3543. /**
  3544. * Updates the current quaternion from the given float coordinates
  3545. * @param x defines the x coordinate
  3546. * @param y defines the y coordinate
  3547. * @param z defines the z coordinate
  3548. * @param w defines the w coordinate
  3549. * @returns the updated current quaternion
  3550. */
  3551. set(x: number, y: number, z: number, w: number): Quaternion;
  3552. /**
  3553. * Adds two quaternions
  3554. * @param other defines the second operand
  3555. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3556. */
  3557. add(other: DeepImmutable<Quaternion>): Quaternion;
  3558. /**
  3559. * Add a quaternion to the current one
  3560. * @param other defines the quaternion to add
  3561. * @returns the current quaternion
  3562. */
  3563. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3564. /**
  3565. * Subtract two quaternions
  3566. * @param other defines the second operand
  3567. * @returns a new quaternion as the subtraction result of the given one from the current one
  3568. */
  3569. subtract(other: Quaternion): Quaternion;
  3570. /**
  3571. * Multiplies the current quaternion by a scale factor
  3572. * @param value defines the scale factor
  3573. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3574. */
  3575. scale(value: number): Quaternion;
  3576. /**
  3577. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3578. * @param scale defines the scale factor
  3579. * @param result defines the Quaternion object where to store the result
  3580. * @returns the unmodified current quaternion
  3581. */
  3582. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3583. /**
  3584. * Multiplies in place the current quaternion by a scale factor
  3585. * @param value defines the scale factor
  3586. * @returns the current modified quaternion
  3587. */
  3588. scaleInPlace(value: number): Quaternion;
  3589. /**
  3590. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3591. * @param scale defines the scale factor
  3592. * @param result defines the Quaternion object where to store the result
  3593. * @returns the unmodified current quaternion
  3594. */
  3595. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3596. /**
  3597. * Multiplies two quaternions
  3598. * @param q1 defines the second operand
  3599. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3600. */
  3601. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3602. /**
  3603. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3604. * @param q1 defines the second operand
  3605. * @param result defines the target quaternion
  3606. * @returns the current quaternion
  3607. */
  3608. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3609. /**
  3610. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3611. * @param q1 defines the second operand
  3612. * @returns the currentupdated quaternion
  3613. */
  3614. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3615. /**
  3616. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3617. * @param ref defines the target quaternion
  3618. * @returns the current quaternion
  3619. */
  3620. conjugateToRef(ref: Quaternion): Quaternion;
  3621. /**
  3622. * Conjugates in place (1-q) the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. conjugateInPlace(): Quaternion;
  3626. /**
  3627. * Conjugates in place (1-q) the current quaternion
  3628. * @returns a new quaternion
  3629. */
  3630. conjugate(): Quaternion;
  3631. /**
  3632. * Gets length of current quaternion
  3633. * @returns the quaternion length (float)
  3634. */
  3635. length(): number;
  3636. /**
  3637. * Normalize in place the current quaternion
  3638. * @returns the current updated quaternion
  3639. */
  3640. normalize(): Quaternion;
  3641. /**
  3642. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3643. * @param order is a reserved parameter and is ignore for now
  3644. * @returns a new Vector3 containing the Euler angles
  3645. */
  3646. toEulerAngles(order?: string): Vector3;
  3647. /**
  3648. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3649. * @param result defines the vector which will be filled with the Euler angles
  3650. * @param order is a reserved parameter and is ignore for now
  3651. * @returns the current unchanged quaternion
  3652. */
  3653. toEulerAnglesToRef(result: Vector3): Quaternion;
  3654. /**
  3655. * Updates the given rotation matrix with the current quaternion values
  3656. * @param result defines the target matrix
  3657. * @returns the current unchanged quaternion
  3658. */
  3659. toRotationMatrix(result: Matrix): Quaternion;
  3660. /**
  3661. * Updates the current quaternion from the given rotation matrix values
  3662. * @param matrix defines the source matrix
  3663. * @returns the current updated quaternion
  3664. */
  3665. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3666. /**
  3667. * Creates a new quaternion from a rotation matrix
  3668. * @param matrix defines the source matrix
  3669. * @returns a new quaternion created from the given rotation matrix values
  3670. */
  3671. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3672. /**
  3673. * Updates the given quaternion with the given rotation matrix values
  3674. * @param matrix defines the source matrix
  3675. * @param result defines the target quaternion
  3676. */
  3677. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3678. /**
  3679. * Returns the dot product (float) between the quaternions "left" and "right"
  3680. * @param left defines the left operand
  3681. * @param right defines the right operand
  3682. * @returns the dot product
  3683. */
  3684. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3685. /**
  3686. * Checks if the two quaternions are close to each other
  3687. * @param quat0 defines the first quaternion to check
  3688. * @param quat1 defines the second quaternion to check
  3689. * @returns true if the two quaternions are close to each other
  3690. */
  3691. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3692. /**
  3693. * Creates an empty quaternion
  3694. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3695. */
  3696. static Zero(): Quaternion;
  3697. /**
  3698. * Inverse a given quaternion
  3699. * @param q defines the source quaternion
  3700. * @returns a new quaternion as the inverted current quaternion
  3701. */
  3702. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3703. /**
  3704. * Inverse a given quaternion
  3705. * @param q defines the source quaternion
  3706. * @param result the quaternion the result will be stored in
  3707. * @returns the result quaternion
  3708. */
  3709. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3710. /**
  3711. * Creates an identity quaternion
  3712. * @returns the identity quaternion
  3713. */
  3714. static Identity(): Quaternion;
  3715. /**
  3716. * Gets a boolean indicating if the given quaternion is identity
  3717. * @param quaternion defines the quaternion to check
  3718. * @returns true if the quaternion is identity
  3719. */
  3720. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3721. /**
  3722. * Creates a quaternion from a rotation around an axis
  3723. * @param axis defines the axis to use
  3724. * @param angle defines the angle to use
  3725. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3726. */
  3727. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3728. /**
  3729. * Creates a rotation around an axis and stores it into the given quaternion
  3730. * @param axis defines the axis to use
  3731. * @param angle defines the angle to use
  3732. * @param result defines the target quaternion
  3733. * @returns the target quaternion
  3734. */
  3735. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3736. /**
  3737. * Creates a new quaternion from data stored into an array
  3738. * @param array defines the data source
  3739. * @param offset defines the offset in the source array where the data starts
  3740. * @returns a new quaternion
  3741. */
  3742. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3743. /**
  3744. * Updates the given quaternion "result" from the starting index of the given array.
  3745. * @param array the array to pull values from
  3746. * @param offset the offset into the array to start at
  3747. * @param result the quaternion to store the result in
  3748. */
  3749. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3750. /**
  3751. * Create a quaternion from Euler rotation angles
  3752. * @param x Pitch
  3753. * @param y Yaw
  3754. * @param z Roll
  3755. * @returns the new Quaternion
  3756. */
  3757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3758. /**
  3759. * Updates a quaternion from Euler rotation angles
  3760. * @param x Pitch
  3761. * @param y Yaw
  3762. * @param z Roll
  3763. * @param result the quaternion to store the result
  3764. * @returns the updated quaternion
  3765. */
  3766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3767. /**
  3768. * Create a quaternion from Euler rotation vector
  3769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3770. * @returns the new Quaternion
  3771. */
  3772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3773. /**
  3774. * Updates a quaternion from Euler rotation vector
  3775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3776. * @param result the quaternion to store the result
  3777. * @returns the updated quaternion
  3778. */
  3779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3780. /**
  3781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3782. * @param yaw defines the rotation around Y axis
  3783. * @param pitch defines the rotation around X axis
  3784. * @param roll defines the rotation around Z axis
  3785. * @returns the new quaternion
  3786. */
  3787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3788. /**
  3789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3790. * @param yaw defines the rotation around Y axis
  3791. * @param pitch defines the rotation around X axis
  3792. * @param roll defines the rotation around Z axis
  3793. * @param result defines the target quaternion
  3794. */
  3795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3796. /**
  3797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3798. * @param alpha defines the rotation around first axis
  3799. * @param beta defines the rotation around second axis
  3800. * @param gamma defines the rotation around third axis
  3801. * @returns the new quaternion
  3802. */
  3803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3804. /**
  3805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3806. * @param alpha defines the rotation around first axis
  3807. * @param beta defines the rotation around second axis
  3808. * @param gamma defines the rotation around third axis
  3809. * @param result defines the target quaternion
  3810. */
  3811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3812. /**
  3813. * 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)
  3814. * @param axis1 defines the first axis
  3815. * @param axis2 defines the second axis
  3816. * @param axis3 defines the third axis
  3817. * @returns the new quaternion
  3818. */
  3819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3820. /**
  3821. * 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
  3822. * @param axis1 defines the first axis
  3823. * @param axis2 defines the second axis
  3824. * @param axis3 defines the third axis
  3825. * @param ref defines the target quaternion
  3826. */
  3827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3828. /**
  3829. * Interpolates between two quaternions
  3830. * @param left defines first quaternion
  3831. * @param right defines second quaternion
  3832. * @param amount defines the gradient to use
  3833. * @returns the new interpolated quaternion
  3834. */
  3835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3836. /**
  3837. * Interpolates between two quaternions and stores it into a target quaternion
  3838. * @param left defines first quaternion
  3839. * @param right defines second quaternion
  3840. * @param amount defines the gradient to use
  3841. * @param result defines the target quaternion
  3842. */
  3843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3844. /**
  3845. * Interpolate between two quaternions using Hermite interpolation
  3846. * @param value1 defines first quaternion
  3847. * @param tangent1 defines the incoming tangent
  3848. * @param value2 defines second quaternion
  3849. * @param tangent2 defines the outgoing tangent
  3850. * @param amount defines the target quaternion
  3851. * @returns the new interpolated quaternion
  3852. */
  3853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3854. }
  3855. /**
  3856. * Class used to store matrix data (4x4)
  3857. */
  3858. export class Matrix {
  3859. private static _updateFlagSeed;
  3860. private static _identityReadOnly;
  3861. private _isIdentity;
  3862. private _isIdentityDirty;
  3863. private _isIdentity3x2;
  3864. private _isIdentity3x2Dirty;
  3865. /**
  3866. * Gets the update flag of the matrix which is an unique number for the matrix.
  3867. * It will be incremented every time the matrix data change.
  3868. * You can use it to speed the comparison between two versions of the same matrix.
  3869. */
  3870. updateFlag: number;
  3871. private readonly _m;
  3872. /**
  3873. * Gets the internal data of the matrix
  3874. */
  3875. get m(): DeepImmutable<Float32Array>;
  3876. /** @hidden */
  3877. _markAsUpdated(): void;
  3878. /** @hidden */
  3879. private _updateIdentityStatus;
  3880. /**
  3881. * Creates an empty matrix (filled with zeros)
  3882. */
  3883. constructor();
  3884. /**
  3885. * Check if the current matrix is identity
  3886. * @returns true is the matrix is the identity matrix
  3887. */
  3888. isIdentity(): boolean;
  3889. /**
  3890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3891. * @returns true is the matrix is the identity matrix
  3892. */
  3893. isIdentityAs3x2(): boolean;
  3894. /**
  3895. * Gets the determinant of the matrix
  3896. * @returns the matrix determinant
  3897. */
  3898. determinant(): number;
  3899. /**
  3900. * Returns the matrix as a Float32Array
  3901. * @returns the matrix underlying array
  3902. */
  3903. toArray(): DeepImmutable<Float32Array>;
  3904. /**
  3905. * Returns the matrix as a Float32Array
  3906. * @returns the matrix underlying array.
  3907. */
  3908. asArray(): DeepImmutable<Float32Array>;
  3909. /**
  3910. * Inverts the current matrix in place
  3911. * @returns the current inverted matrix
  3912. */
  3913. invert(): Matrix;
  3914. /**
  3915. * Sets all the matrix elements to zero
  3916. * @returns the current matrix
  3917. */
  3918. reset(): Matrix;
  3919. /**
  3920. * Adds the current matrix with a second one
  3921. * @param other defines the matrix to add
  3922. * @returns a new matrix as the addition of the current matrix and the given one
  3923. */
  3924. add(other: DeepImmutable<Matrix>): Matrix;
  3925. /**
  3926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3927. * @param other defines the matrix to add
  3928. * @param result defines the target matrix
  3929. * @returns the current matrix
  3930. */
  3931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3932. /**
  3933. * Adds in place the given matrix to the current matrix
  3934. * @param other defines the second operand
  3935. * @returns the current updated matrix
  3936. */
  3937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3938. /**
  3939. * Sets the given matrix to the current inverted Matrix
  3940. * @param other defines the target matrix
  3941. * @returns the unmodified current matrix
  3942. */
  3943. invertToRef(other: Matrix): Matrix;
  3944. /**
  3945. * add a value at the specified position in the current Matrix
  3946. * @param index the index of the value within the matrix. between 0 and 15.
  3947. * @param value the value to be added
  3948. * @returns the current updated matrix
  3949. */
  3950. addAtIndex(index: number, value: number): Matrix;
  3951. /**
  3952. * mutiply the specified position in the current Matrix by a value
  3953. * @param index the index of the value within the matrix. between 0 and 15.
  3954. * @param value the value to be added
  3955. * @returns the current updated matrix
  3956. */
  3957. multiplyAtIndex(index: number, value: number): Matrix;
  3958. /**
  3959. * Inserts the translation vector (using 3 floats) in the current matrix
  3960. * @param x defines the 1st component of the translation
  3961. * @param y defines the 2nd component of the translation
  3962. * @param z defines the 3rd component of the translation
  3963. * @returns the current updated matrix
  3964. */
  3965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3966. /**
  3967. * Adds the translation vector (using 3 floats) in the current matrix
  3968. * @param x defines the 1st component of the translation
  3969. * @param y defines the 2nd component of the translation
  3970. * @param z defines the 3rd component of the translation
  3971. * @returns the current updated matrix
  3972. */
  3973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3974. /**
  3975. * Inserts the translation vector in the current matrix
  3976. * @param vector3 defines the translation to insert
  3977. * @returns the current updated matrix
  3978. */
  3979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3980. /**
  3981. * Gets the translation value of the current matrix
  3982. * @returns a new Vector3 as the extracted translation from the matrix
  3983. */
  3984. getTranslation(): Vector3;
  3985. /**
  3986. * Fill a Vector3 with the extracted translation from the matrix
  3987. * @param result defines the Vector3 where to store the translation
  3988. * @returns the current matrix
  3989. */
  3990. getTranslationToRef(result: Vector3): Matrix;
  3991. /**
  3992. * Remove rotation and scaling part from the matrix
  3993. * @returns the updated matrix
  3994. */
  3995. removeRotationAndScaling(): Matrix;
  3996. /**
  3997. * Multiply two matrices
  3998. * @param other defines the second operand
  3999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4000. */
  4001. multiply(other: DeepImmutable<Matrix>): Matrix;
  4002. /**
  4003. * Copy the current matrix from the given one
  4004. * @param other defines the source matrix
  4005. * @returns the current updated matrix
  4006. */
  4007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4008. /**
  4009. * Populates the given array from the starting index with the current matrix values
  4010. * @param array defines the target array
  4011. * @param offset defines the offset in the target array where to start storing values
  4012. * @returns the current matrix
  4013. */
  4014. copyToArray(array: Float32Array, offset?: number): Matrix;
  4015. /**
  4016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4017. * @param other defines the second operand
  4018. * @param result defines the matrix where to store the multiplication
  4019. * @returns the current matrix
  4020. */
  4021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4022. /**
  4023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4024. * @param other defines the second operand
  4025. * @param result defines the array where to store the multiplication
  4026. * @param offset defines the offset in the target array where to start storing values
  4027. * @returns the current matrix
  4028. */
  4029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4030. /**
  4031. * Check equality between this matrix and a second one
  4032. * @param value defines the second matrix to compare
  4033. * @returns true is the current matrix and the given one values are strictly equal
  4034. */
  4035. equals(value: DeepImmutable<Matrix>): boolean;
  4036. /**
  4037. * Clone the current matrix
  4038. * @returns a new matrix from the current matrix
  4039. */
  4040. clone(): Matrix;
  4041. /**
  4042. * Returns the name of the current matrix class
  4043. * @returns the string "Matrix"
  4044. */
  4045. getClassName(): string;
  4046. /**
  4047. * Gets the hash code of the current matrix
  4048. * @returns the hash code
  4049. */
  4050. getHashCode(): number;
  4051. /**
  4052. * Decomposes the current Matrix into a translation, rotation and scaling components
  4053. * @param scale defines the scale vector3 given as a reference to update
  4054. * @param rotation defines the rotation quaternion given as a reference to update
  4055. * @param translation defines the translation vector3 given as a reference to update
  4056. * @returns true if operation was successful
  4057. */
  4058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4059. /**
  4060. * Gets specific row of the matrix
  4061. * @param index defines the number of the row to get
  4062. * @returns the index-th row of the current matrix as a new Vector4
  4063. */
  4064. getRow(index: number): Nullable<Vector4>;
  4065. /**
  4066. * Sets the index-th row of the current matrix to the vector4 values
  4067. * @param index defines the number of the row to set
  4068. * @param row defines the target vector4
  4069. * @returns the updated current matrix
  4070. */
  4071. setRow(index: number, row: Vector4): Matrix;
  4072. /**
  4073. * Compute the transpose of the matrix
  4074. * @returns the new transposed matrix
  4075. */
  4076. transpose(): Matrix;
  4077. /**
  4078. * Compute the transpose of the matrix and store it in a given matrix
  4079. * @param result defines the target matrix
  4080. * @returns the current matrix
  4081. */
  4082. transposeToRef(result: Matrix): Matrix;
  4083. /**
  4084. * Sets the index-th row of the current matrix with the given 4 x float values
  4085. * @param index defines the row index
  4086. * @param x defines the x component to set
  4087. * @param y defines the y component to set
  4088. * @param z defines the z component to set
  4089. * @param w defines the w component to set
  4090. * @returns the updated current matrix
  4091. */
  4092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4093. /**
  4094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4095. * @param scale defines the scale factor
  4096. * @returns a new matrix
  4097. */
  4098. scale(scale: number): Matrix;
  4099. /**
  4100. * Scale the current matrix values by a factor to a given result matrix
  4101. * @param scale defines the scale factor
  4102. * @param result defines the matrix to store the result
  4103. * @returns the current matrix
  4104. */
  4105. scaleToRef(scale: number, result: Matrix): Matrix;
  4106. /**
  4107. * Scale the current matrix values by a factor and add the result to a given matrix
  4108. * @param scale defines the scale factor
  4109. * @param result defines the Matrix to store the result
  4110. * @returns the current matrix
  4111. */
  4112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4113. /**
  4114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4115. * @param ref matrix to store the result
  4116. */
  4117. toNormalMatrix(ref: Matrix): void;
  4118. /**
  4119. * Gets only rotation part of the current matrix
  4120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4121. */
  4122. getRotationMatrix(): Matrix;
  4123. /**
  4124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4125. * @param result defines the target matrix to store data to
  4126. * @returns the current matrix
  4127. */
  4128. getRotationMatrixToRef(result: Matrix): Matrix;
  4129. /**
  4130. * Toggles model matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleModelMatrixHandInPlace(): void;
  4133. /**
  4134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4135. */
  4136. toggleProjectionMatrixHandInPlace(): void;
  4137. /**
  4138. * Creates a matrix from an array
  4139. * @param array defines the source array
  4140. * @param offset defines an offset in the source array
  4141. * @returns a new Matrix set from the starting index of the given array
  4142. */
  4143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4144. /**
  4145. * Copy the content of an array into a given matrix
  4146. * @param array defines the source array
  4147. * @param offset defines an offset in the source array
  4148. * @param result defines the target matrix
  4149. */
  4150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4151. /**
  4152. * Stores an array into a matrix after having multiplied each component by a given factor
  4153. * @param array defines the source array
  4154. * @param offset defines the offset in the source array
  4155. * @param scale defines the scaling factor
  4156. * @param result defines the target matrix
  4157. */
  4158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4159. /**
  4160. * Gets an identity matrix that must not be updated
  4161. */
  4162. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4163. /**
  4164. * Stores a list of values (16) inside a given matrix
  4165. * @param initialM11 defines 1st value of 1st row
  4166. * @param initialM12 defines 2nd value of 1st row
  4167. * @param initialM13 defines 3rd value of 1st row
  4168. * @param initialM14 defines 4th value of 1st row
  4169. * @param initialM21 defines 1st value of 2nd row
  4170. * @param initialM22 defines 2nd value of 2nd row
  4171. * @param initialM23 defines 3rd value of 2nd row
  4172. * @param initialM24 defines 4th value of 2nd row
  4173. * @param initialM31 defines 1st value of 3rd row
  4174. * @param initialM32 defines 2nd value of 3rd row
  4175. * @param initialM33 defines 3rd value of 3rd row
  4176. * @param initialM34 defines 4th value of 3rd row
  4177. * @param initialM41 defines 1st value of 4th row
  4178. * @param initialM42 defines 2nd value of 4th row
  4179. * @param initialM43 defines 3rd value of 4th row
  4180. * @param initialM44 defines 4th value of 4th row
  4181. * @param result defines the target matrix
  4182. */
  4183. 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;
  4184. /**
  4185. * Creates new matrix from a list of values (16)
  4186. * @param initialM11 defines 1st value of 1st row
  4187. * @param initialM12 defines 2nd value of 1st row
  4188. * @param initialM13 defines 3rd value of 1st row
  4189. * @param initialM14 defines 4th value of 1st row
  4190. * @param initialM21 defines 1st value of 2nd row
  4191. * @param initialM22 defines 2nd value of 2nd row
  4192. * @param initialM23 defines 3rd value of 2nd row
  4193. * @param initialM24 defines 4th value of 2nd row
  4194. * @param initialM31 defines 1st value of 3rd row
  4195. * @param initialM32 defines 2nd value of 3rd row
  4196. * @param initialM33 defines 3rd value of 3rd row
  4197. * @param initialM34 defines 4th value of 3rd row
  4198. * @param initialM41 defines 1st value of 4th row
  4199. * @param initialM42 defines 2nd value of 4th row
  4200. * @param initialM43 defines 3rd value of 4th row
  4201. * @param initialM44 defines 4th value of 4th row
  4202. * @returns the new matrix
  4203. */
  4204. 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;
  4205. /**
  4206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4207. * @param scale defines the scale vector3
  4208. * @param rotation defines the rotation quaternion
  4209. * @param translation defines the translation vector3
  4210. * @returns a new matrix
  4211. */
  4212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4213. /**
  4214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4215. * @param scale defines the scale vector3
  4216. * @param rotation defines the rotation quaternion
  4217. * @param translation defines the translation vector3
  4218. * @param result defines the target matrix
  4219. */
  4220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4221. /**
  4222. * Creates a new identity matrix
  4223. * @returns a new identity matrix
  4224. */
  4225. static Identity(): Matrix;
  4226. /**
  4227. * Creates a new identity matrix and stores the result in a given matrix
  4228. * @param result defines the target matrix
  4229. */
  4230. static IdentityToRef(result: Matrix): void;
  4231. /**
  4232. * Creates a new zero matrix
  4233. * @returns a new zero matrix
  4234. */
  4235. static Zero(): Matrix;
  4236. /**
  4237. * Creates a new rotation matrix for "angle" radians around the X axis
  4238. * @param angle defines the angle (in radians) to use
  4239. * @return the new matrix
  4240. */
  4241. static RotationX(angle: number): Matrix;
  4242. /**
  4243. * Creates a new matrix as the invert of a given matrix
  4244. * @param source defines the source matrix
  4245. * @returns the new matrix
  4246. */
  4247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4248. /**
  4249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4250. * @param angle defines the angle (in radians) to use
  4251. * @param result defines the target matrix
  4252. */
  4253. static RotationXToRef(angle: number, result: Matrix): void;
  4254. /**
  4255. * Creates a new rotation matrix for "angle" radians around the Y axis
  4256. * @param angle defines the angle (in radians) to use
  4257. * @return the new matrix
  4258. */
  4259. static RotationY(angle: number): Matrix;
  4260. /**
  4261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4262. * @param angle defines the angle (in radians) to use
  4263. * @param result defines the target matrix
  4264. */
  4265. static RotationYToRef(angle: number, result: Matrix): void;
  4266. /**
  4267. * Creates a new rotation matrix for "angle" radians around the Z axis
  4268. * @param angle defines the angle (in radians) to use
  4269. * @return the new matrix
  4270. */
  4271. static RotationZ(angle: number): Matrix;
  4272. /**
  4273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4274. * @param angle defines the angle (in radians) to use
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationZToRef(angle: number, result: Matrix): void;
  4278. /**
  4279. * Creates a new rotation matrix for "angle" radians around the given axis
  4280. * @param axis defines the axis to use
  4281. * @param angle defines the angle (in radians) to use
  4282. * @return the new matrix
  4283. */
  4284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4285. /**
  4286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4287. * @param axis defines the axis to use
  4288. * @param angle defines the angle (in radians) to use
  4289. * @param result defines the target matrix
  4290. */
  4291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4292. /**
  4293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4295. * @param from defines the vector to align
  4296. * @param to defines the vector to align to
  4297. * @param result defines the target matrix
  4298. */
  4299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4300. /**
  4301. * Creates a rotation matrix
  4302. * @param yaw defines the yaw angle in radians (Y axis)
  4303. * @param pitch defines the pitch angle in radians (X axis)
  4304. * @param roll defines the roll angle in radians (X axis)
  4305. * @returns the new rotation matrix
  4306. */
  4307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4308. /**
  4309. * Creates a rotation matrix and stores it in a given matrix
  4310. * @param yaw defines the yaw angle in radians (Y axis)
  4311. * @param pitch defines the pitch angle in radians (X axis)
  4312. * @param roll defines the roll angle in radians (X axis)
  4313. * @param result defines the target matrix
  4314. */
  4315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4316. /**
  4317. * Creates a scaling matrix
  4318. * @param x defines the scale factor on X axis
  4319. * @param y defines the scale factor on Y axis
  4320. * @param z defines the scale factor on Z axis
  4321. * @returns the new matrix
  4322. */
  4323. static Scaling(x: number, y: number, z: number): Matrix;
  4324. /**
  4325. * Creates a scaling matrix and stores it in a given matrix
  4326. * @param x defines the scale factor on X axis
  4327. * @param y defines the scale factor on Y axis
  4328. * @param z defines the scale factor on Z axis
  4329. * @param result defines the target matrix
  4330. */
  4331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4332. /**
  4333. * Creates a translation matrix
  4334. * @param x defines the translation on X axis
  4335. * @param y defines the translation on Y axis
  4336. * @param z defines the translationon Z axis
  4337. * @returns the new matrix
  4338. */
  4339. static Translation(x: number, y: number, z: number): Matrix;
  4340. /**
  4341. * Creates a translation matrix and stores it in a given matrix
  4342. * @param x defines the translation on X axis
  4343. * @param y defines the translation on Y axis
  4344. * @param z defines the translationon Z axis
  4345. * @param result defines the target matrix
  4346. */
  4347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4348. /**
  4349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4350. * @param startValue defines the start value
  4351. * @param endValue defines the end value
  4352. * @param gradient defines the gradient factor
  4353. * @returns the new matrix
  4354. */
  4355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4356. /**
  4357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4358. * @param startValue defines the start value
  4359. * @param endValue defines the end value
  4360. * @param gradient defines the gradient factor
  4361. * @param result defines the Matrix object where to store data
  4362. */
  4363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * Builds a new matrix whose values are computed by:
  4366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4369. * @param startValue defines the first matrix
  4370. * @param endValue defines the second matrix
  4371. * @param gradient defines the gradient between the two matrices
  4372. * @returns the new matrix
  4373. */
  4374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4375. /**
  4376. * Update a matrix to values which are computed by:
  4377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4380. * @param startValue defines the first matrix
  4381. * @param endValue defines the second matrix
  4382. * @param gradient defines the gradient between the two matrices
  4383. * @param result defines the target matrix
  4384. */
  4385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4386. /**
  4387. * 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"
  4388. * This function works in left handed mode
  4389. * @param eye defines the final position of the entity
  4390. * @param target defines where the entity should look at
  4391. * @param up defines the up vector for the entity
  4392. * @returns the new matrix
  4393. */
  4394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4395. /**
  4396. * 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".
  4397. * This function works in left handed mode
  4398. * @param eye defines the final position of the entity
  4399. * @param target defines where the entity should look at
  4400. * @param up defines the up vector for the entity
  4401. * @param result defines the target matrix
  4402. */
  4403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4404. /**
  4405. * 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"
  4406. * This function works in right handed mode
  4407. * @param eye defines the final position of the entity
  4408. * @param target defines where the entity should look at
  4409. * @param up defines the up vector for the entity
  4410. * @returns the new matrix
  4411. */
  4412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4413. /**
  4414. * 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".
  4415. * This function works in right handed mode
  4416. * @param eye defines the final position of the entity
  4417. * @param target defines where the entity should look at
  4418. * @param up defines the up vector for the entity
  4419. * @param result defines the target matrix
  4420. */
  4421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4422. /**
  4423. * Create a left-handed orthographic projection matrix
  4424. * @param width defines the viewport width
  4425. * @param height defines the viewport height
  4426. * @param znear defines the near clip plane
  4427. * @param zfar defines the far clip plane
  4428. * @returns a new matrix as a left-handed orthographic projection matrix
  4429. */
  4430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4431. /**
  4432. * Store a left-handed orthographic projection to a given matrix
  4433. * @param width defines the viewport width
  4434. * @param height defines the viewport height
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Create a left-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a left-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a left-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a right-handed orthographic projection matrix
  4464. * @param left defines the viewport left coordinate
  4465. * @param right defines the viewport right coordinate
  4466. * @param bottom defines the viewport bottom coordinate
  4467. * @param top defines the viewport top coordinate
  4468. * @param znear defines the near clip plane
  4469. * @param zfar defines the far clip plane
  4470. * @returns a new matrix as a right-handed orthographic projection matrix
  4471. */
  4472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4473. /**
  4474. * Stores a right-handed orthographic projection into a given matrix
  4475. * @param left defines the viewport left coordinate
  4476. * @param right defines the viewport right coordinate
  4477. * @param bottom defines the viewport bottom coordinate
  4478. * @param top defines the viewport top coordinate
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @param result defines the target matrix
  4482. */
  4483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4484. /**
  4485. * Creates a left-handed perspective projection matrix
  4486. * @param width defines the viewport width
  4487. * @param height defines the viewport height
  4488. * @param znear defines the near clip plane
  4489. * @param zfar defines the far clip plane
  4490. * @returns a new matrix as a left-handed perspective projection matrix
  4491. */
  4492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4493. /**
  4494. * Creates a left-handed perspective projection matrix
  4495. * @param fov defines the horizontal field of view
  4496. * @param aspect defines the aspect ratio
  4497. * @param znear defines the near clip plane
  4498. * @param zfar defines the far clip plane
  4499. * @returns a new matrix as a left-handed perspective projection matrix
  4500. */
  4501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4502. /**
  4503. * Stores a left-handed perspective projection into a given matrix
  4504. * @param fov defines the horizontal field of view
  4505. * @param aspect defines the aspect ratio
  4506. * @param znear defines the near clip plane
  4507. * @param zfar defines the far clip plane
  4508. * @param result defines the target matrix
  4509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4510. */
  4511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4512. /**
  4513. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4514. * @param fov defines the horizontal field of view
  4515. * @param aspect defines the aspect ratio
  4516. * @param znear defines the near clip plane
  4517. * @param zfar not used as infinity is used as far clip
  4518. * @param result defines the target matrix
  4519. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4520. */
  4521. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4522. /**
  4523. * Creates a right-handed perspective projection matrix
  4524. * @param fov defines the horizontal field of view
  4525. * @param aspect defines the aspect ratio
  4526. * @param znear defines the near clip plane
  4527. * @param zfar defines the far clip plane
  4528. * @returns a new matrix as a right-handed perspective projection matrix
  4529. */
  4530. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4531. /**
  4532. * Stores a right-handed perspective projection into a given matrix
  4533. * @param fov defines the horizontal field of view
  4534. * @param aspect defines the aspect ratio
  4535. * @param znear defines the near clip plane
  4536. * @param zfar defines the far clip plane
  4537. * @param result defines the target matrix
  4538. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4539. */
  4540. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4541. /**
  4542. * Stores a right-handed perspective projection into a given matrix
  4543. * @param fov defines the horizontal field of view
  4544. * @param aspect defines the aspect ratio
  4545. * @param znear defines the near clip plane
  4546. * @param zfar not used as infinity is used as far clip
  4547. * @param result defines the target matrix
  4548. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4549. */
  4550. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4551. /**
  4552. * Stores a perspective projection for WebVR info a given matrix
  4553. * @param fov defines the field of view
  4554. * @param znear defines the near clip plane
  4555. * @param zfar defines the far clip plane
  4556. * @param result defines the target matrix
  4557. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4558. */
  4559. static PerspectiveFovWebVRToRef(fov: {
  4560. upDegrees: number;
  4561. downDegrees: number;
  4562. leftDegrees: number;
  4563. rightDegrees: number;
  4564. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4565. /**
  4566. * Computes a complete transformation matrix
  4567. * @param viewport defines the viewport to use
  4568. * @param world defines the world matrix
  4569. * @param view defines the view matrix
  4570. * @param projection defines the projection matrix
  4571. * @param zmin defines the near clip plane
  4572. * @param zmax defines the far clip plane
  4573. * @returns the transformation matrix
  4574. */
  4575. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4576. /**
  4577. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4578. * @param matrix defines the matrix to use
  4579. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4580. */
  4581. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4582. /**
  4583. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4584. * @param matrix defines the matrix to use
  4585. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4586. */
  4587. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4588. /**
  4589. * Compute the transpose of a given matrix
  4590. * @param matrix defines the matrix to transpose
  4591. * @returns the new matrix
  4592. */
  4593. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4594. /**
  4595. * Compute the transpose of a matrix and store it in a target matrix
  4596. * @param matrix defines the matrix to transpose
  4597. * @param result defines the target matrix
  4598. */
  4599. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4600. /**
  4601. * Computes a reflection matrix from a plane
  4602. * @param plane defines the reflection plane
  4603. * @returns a new matrix
  4604. */
  4605. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4606. /**
  4607. * Computes a reflection matrix from a plane
  4608. * @param plane defines the reflection plane
  4609. * @param result defines the target matrix
  4610. */
  4611. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4612. /**
  4613. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4614. * @param xaxis defines the value of the 1st axis
  4615. * @param yaxis defines the value of the 2nd axis
  4616. * @param zaxis defines the value of the 3rd axis
  4617. * @param result defines the target matrix
  4618. */
  4619. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4620. /**
  4621. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4622. * @param quat defines the quaternion to use
  4623. * @param result defines the target matrix
  4624. */
  4625. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4626. }
  4627. /**
  4628. * @hidden
  4629. */
  4630. export class TmpVectors {
  4631. static Vector2: Vector2[];
  4632. static Vector3: Vector3[];
  4633. static Vector4: Vector4[];
  4634. static Quaternion: Quaternion[];
  4635. static Matrix: Matrix[];
  4636. }
  4637. }
  4638. declare module BABYLON {
  4639. /**
  4640. * Defines potential orientation for back face culling
  4641. */
  4642. export enum Orientation {
  4643. /**
  4644. * Clockwise
  4645. */
  4646. CW = 0,
  4647. /** Counter clockwise */
  4648. CCW = 1
  4649. }
  4650. /** Class used to represent a Bezier curve */
  4651. export class BezierCurve {
  4652. /**
  4653. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4654. * @param t defines the time
  4655. * @param x1 defines the left coordinate on X axis
  4656. * @param y1 defines the left coordinate on Y axis
  4657. * @param x2 defines the right coordinate on X axis
  4658. * @param y2 defines the right coordinate on Y axis
  4659. * @returns the interpolated value
  4660. */
  4661. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4662. }
  4663. /**
  4664. * Defines angle representation
  4665. */
  4666. export class Angle {
  4667. private _radians;
  4668. /**
  4669. * Creates an Angle object of "radians" radians (float).
  4670. * @param radians the angle in radians
  4671. */
  4672. constructor(radians: number);
  4673. /**
  4674. * Get value in degrees
  4675. * @returns the Angle value in degrees (float)
  4676. */
  4677. degrees(): number;
  4678. /**
  4679. * Get value in radians
  4680. * @returns the Angle value in radians (float)
  4681. */
  4682. radians(): number;
  4683. /**
  4684. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4685. * @param a defines first vector
  4686. * @param b defines second vector
  4687. * @returns a new Angle
  4688. */
  4689. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4690. /**
  4691. * Gets a new Angle object from the given float in radians
  4692. * @param radians defines the angle value in radians
  4693. * @returns a new Angle
  4694. */
  4695. static FromRadians(radians: number): Angle;
  4696. /**
  4697. * Gets a new Angle object from the given float in degrees
  4698. * @param degrees defines the angle value in degrees
  4699. * @returns a new Angle
  4700. */
  4701. static FromDegrees(degrees: number): Angle;
  4702. }
  4703. /**
  4704. * This represents an arc in a 2d space.
  4705. */
  4706. export class Arc2 {
  4707. /** Defines the start point of the arc */
  4708. startPoint: Vector2;
  4709. /** Defines the mid point of the arc */
  4710. midPoint: Vector2;
  4711. /** Defines the end point of the arc */
  4712. endPoint: Vector2;
  4713. /**
  4714. * Defines the center point of the arc.
  4715. */
  4716. centerPoint: Vector2;
  4717. /**
  4718. * Defines the radius of the arc.
  4719. */
  4720. radius: number;
  4721. /**
  4722. * Defines the angle of the arc (from mid point to end point).
  4723. */
  4724. angle: Angle;
  4725. /**
  4726. * Defines the start angle of the arc (from start point to middle point).
  4727. */
  4728. startAngle: Angle;
  4729. /**
  4730. * Defines the orientation of the arc (clock wise/counter clock wise).
  4731. */
  4732. orientation: Orientation;
  4733. /**
  4734. * Creates an Arc object from the three given points : start, middle and end.
  4735. * @param startPoint Defines the start point of the arc
  4736. * @param midPoint Defines the midlle point of the arc
  4737. * @param endPoint Defines the end point of the arc
  4738. */
  4739. constructor(
  4740. /** Defines the start point of the arc */
  4741. startPoint: Vector2,
  4742. /** Defines the mid point of the arc */
  4743. midPoint: Vector2,
  4744. /** Defines the end point of the arc */
  4745. endPoint: Vector2);
  4746. }
  4747. /**
  4748. * Represents a 2D path made up of multiple 2D points
  4749. */
  4750. export class Path2 {
  4751. private _points;
  4752. private _length;
  4753. /**
  4754. * If the path start and end point are the same
  4755. */
  4756. closed: boolean;
  4757. /**
  4758. * Creates a Path2 object from the starting 2D coordinates x and y.
  4759. * @param x the starting points x value
  4760. * @param y the starting points y value
  4761. */
  4762. constructor(x: number, y: number);
  4763. /**
  4764. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4765. * @param x the added points x value
  4766. * @param y the added points y value
  4767. * @returns the updated Path2.
  4768. */
  4769. addLineTo(x: number, y: number): Path2;
  4770. /**
  4771. * 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.
  4772. * @param midX middle point x value
  4773. * @param midY middle point y value
  4774. * @param endX end point x value
  4775. * @param endY end point y value
  4776. * @param numberOfSegments (default: 36)
  4777. * @returns the updated Path2.
  4778. */
  4779. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4780. /**
  4781. * Closes the Path2.
  4782. * @returns the Path2.
  4783. */
  4784. close(): Path2;
  4785. /**
  4786. * Gets the sum of the distance between each sequential point in the path
  4787. * @returns the Path2 total length (float).
  4788. */
  4789. length(): number;
  4790. /**
  4791. * Gets the points which construct the path
  4792. * @returns the Path2 internal array of points.
  4793. */
  4794. getPoints(): Vector2[];
  4795. /**
  4796. * Retreives the point at the distance aways from the starting point
  4797. * @param normalizedLengthPosition the length along the path to retreive the point from
  4798. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4799. */
  4800. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4801. /**
  4802. * Creates a new path starting from an x and y position
  4803. * @param x starting x value
  4804. * @param y starting y value
  4805. * @returns a new Path2 starting at the coordinates (x, y).
  4806. */
  4807. static StartingAt(x: number, y: number): Path2;
  4808. }
  4809. /**
  4810. * Represents a 3D path made up of multiple 3D points
  4811. */
  4812. export class Path3D {
  4813. /**
  4814. * an array of Vector3, the curve axis of the Path3D
  4815. */
  4816. path: Vector3[];
  4817. private _curve;
  4818. private _distances;
  4819. private _tangents;
  4820. private _normals;
  4821. private _binormals;
  4822. private _raw;
  4823. private _alignTangentsWithPath;
  4824. private readonly _pointAtData;
  4825. /**
  4826. * new Path3D(path, normal, raw)
  4827. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4828. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4829. * @param path an array of Vector3, the curve axis of the Path3D
  4830. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4831. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4832. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4833. */
  4834. constructor(
  4835. /**
  4836. * an array of Vector3, the curve axis of the Path3D
  4837. */
  4838. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4839. /**
  4840. * Returns the Path3D array of successive Vector3 designing its curve.
  4841. * @returns the Path3D array of successive Vector3 designing its curve.
  4842. */
  4843. getCurve(): Vector3[];
  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. getPoints(): Vector3[];
  4849. /**
  4850. * @returns the computed length (float) of the path.
  4851. */
  4852. length(): number;
  4853. /**
  4854. * Returns an array populated with tangent vectors on each Path3D curve point.
  4855. * @returns an array populated with tangent vectors on each Path3D curve point.
  4856. */
  4857. getTangents(): Vector3[];
  4858. /**
  4859. * Returns an array populated with normal vectors on each Path3D curve point.
  4860. * @returns an array populated with normal vectors on each Path3D curve point.
  4861. */
  4862. getNormals(): Vector3[];
  4863. /**
  4864. * Returns an array populated with binormal vectors on each Path3D curve point.
  4865. * @returns an array populated with binormal vectors on each Path3D curve point.
  4866. */
  4867. getBinormals(): Vector3[];
  4868. /**
  4869. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4870. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4871. */
  4872. getDistances(): number[];
  4873. /**
  4874. * Returns an interpolated point along this path
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @returns a new Vector3 as the point
  4877. */
  4878. getPointAt(position: number): Vector3;
  4879. /**
  4880. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4881. * @param position the position of the point along this path, from 0.0 to 1.0
  4882. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4883. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4884. */
  4885. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4886. /**
  4887. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4888. * @param position the position of the point along this path, from 0.0 to 1.0
  4889. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4890. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4891. */
  4892. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4893. /**
  4894. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4895. * @param position the position of the point along this path, from 0.0 to 1.0
  4896. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4897. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4898. */
  4899. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4900. /**
  4901. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4902. * @param position the position of the point along this path, from 0.0 to 1.0
  4903. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4904. */
  4905. getDistanceAt(position: number): number;
  4906. /**
  4907. * Returns the array index of the previous point of an interpolated point along this path
  4908. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4909. * @returns the array index
  4910. */
  4911. getPreviousPointIndexAt(position: number): number;
  4912. /**
  4913. * 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)
  4914. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4915. * @returns the sub position
  4916. */
  4917. getSubPositionAt(position: number): number;
  4918. /**
  4919. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4920. * @param target the vector of which to get the closest position to
  4921. * @returns the position of the closest virtual point on this path to the target vector
  4922. */
  4923. getClosestPositionTo(target: Vector3): number;
  4924. /**
  4925. * Returns a sub path (slice) of this path
  4926. * @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
  4927. * @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
  4928. * @returns a sub path (slice) of this path
  4929. */
  4930. slice(start?: number, end?: number): Path3D;
  4931. /**
  4932. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4933. * @param path path which all values are copied into the curves points
  4934. * @param firstNormal which should be projected onto the curve
  4935. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4936. * @returns the same object updated.
  4937. */
  4938. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4939. private _compute;
  4940. private _getFirstNonNullVector;
  4941. private _getLastNonNullVector;
  4942. private _normalVector;
  4943. /**
  4944. * Updates the point at data for an interpolated point along this curve
  4945. * @param position the position of the point along this curve, from 0.0 to 1.0
  4946. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4947. * @returns the (updated) point at data
  4948. */
  4949. private _updatePointAtData;
  4950. /**
  4951. * Updates the point at data from the specified parameters
  4952. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4953. * @param point the interpolated point
  4954. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4955. */
  4956. private _setPointAtData;
  4957. /**
  4958. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4959. */
  4960. private _updateInterpolationMatrix;
  4961. }
  4962. /**
  4963. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4964. * A Curve3 is designed from a series of successive Vector3.
  4965. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4966. */
  4967. export class Curve3 {
  4968. private _points;
  4969. private _length;
  4970. /**
  4971. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4972. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4973. * @param v1 (Vector3) the control point
  4974. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4975. * @param nbPoints (integer) the wanted number of points in the curve
  4976. * @returns the created Curve3
  4977. */
  4978. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4979. /**
  4980. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4981. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4982. * @param v1 (Vector3) the first control point
  4983. * @param v2 (Vector3) the second control point
  4984. * @param v3 (Vector3) the end point of the Cubic Bezier
  4985. * @param nbPoints (integer) the wanted number of points in the curve
  4986. * @returns the created Curve3
  4987. */
  4988. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4989. /**
  4990. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4991. * @param p1 (Vector3) the origin point of the Hermite Spline
  4992. * @param t1 (Vector3) the tangent vector at the origin point
  4993. * @param p2 (Vector3) the end point of the Hermite Spline
  4994. * @param t2 (Vector3) the tangent vector at the end point
  4995. * @param nbPoints (integer) the wanted number of points in the curve
  4996. * @returns the created Curve3
  4997. */
  4998. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4999. /**
  5000. * Returns a Curve3 object along a CatmullRom Spline curve :
  5001. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5002. * @param nbPoints (integer) the wanted number of points between each curve control points
  5003. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5004. * @returns the created Curve3
  5005. */
  5006. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5007. /**
  5008. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5009. * A Curve3 is designed from a series of successive Vector3.
  5010. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5011. * @param points points which make up the curve
  5012. */
  5013. constructor(points: Vector3[]);
  5014. /**
  5015. * @returns the Curve3 stored array of successive Vector3
  5016. */
  5017. getPoints(): Vector3[];
  5018. /**
  5019. * @returns the computed length (float) of the curve.
  5020. */
  5021. length(): number;
  5022. /**
  5023. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5024. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5025. * curveA and curveB keep unchanged.
  5026. * @param curve the curve to continue from this curve
  5027. * @returns the newly constructed curve
  5028. */
  5029. continue(curve: DeepImmutable<Curve3>): Curve3;
  5030. private _computeLength;
  5031. }
  5032. }
  5033. declare module BABYLON {
  5034. /**
  5035. * This represents the main contract an easing function should follow.
  5036. * Easing functions are used throughout the animation system.
  5037. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5038. */
  5039. export interface IEasingFunction {
  5040. /**
  5041. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5042. * of the easing function.
  5043. * The link below provides some of the most common examples of easing functions.
  5044. * @see https://easings.net/
  5045. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5046. * @returns the corresponding value on the curve defined by the easing function
  5047. */
  5048. ease(gradient: number): number;
  5049. }
  5050. /**
  5051. * Base class used for every default easing function.
  5052. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5053. */
  5054. export class EasingFunction implements IEasingFunction {
  5055. /**
  5056. * Interpolation follows the mathematical formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEIN: number;
  5059. /**
  5060. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5061. */
  5062. static readonly EASINGMODE_EASEOUT: number;
  5063. /**
  5064. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5065. */
  5066. static readonly EASINGMODE_EASEINOUT: number;
  5067. private _easingMode;
  5068. /**
  5069. * Sets the easing mode of the current function.
  5070. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5071. */
  5072. setEasingMode(easingMode: number): void;
  5073. /**
  5074. * Gets the current easing mode.
  5075. * @returns the easing mode
  5076. */
  5077. getEasingMode(): number;
  5078. /**
  5079. * @hidden
  5080. */
  5081. easeInCore(gradient: number): number;
  5082. /**
  5083. * Given an input gradient between 0 and 1, this returns the corresponding value
  5084. * of the easing function.
  5085. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5086. * @returns the corresponding value on the curve defined by the easing function
  5087. */
  5088. ease(gradient: number): number;
  5089. }
  5090. /**
  5091. * Easing function with a circle shape (see link below).
  5092. * @see https://easings.net/#easeInCirc
  5093. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5094. */
  5095. export class CircleEase extends EasingFunction implements IEasingFunction {
  5096. /** @hidden */
  5097. easeInCore(gradient: number): number;
  5098. }
  5099. /**
  5100. * Easing function with a ease back shape (see link below).
  5101. * @see https://easings.net/#easeInBack
  5102. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5103. */
  5104. export class BackEase extends EasingFunction implements IEasingFunction {
  5105. /** Defines the amplitude of the function */
  5106. amplitude: number;
  5107. /**
  5108. * Instantiates a back ease easing
  5109. * @see https://easings.net/#easeInBack
  5110. * @param amplitude Defines the amplitude of the function
  5111. */
  5112. constructor(
  5113. /** Defines the amplitude of the function */
  5114. amplitude?: number);
  5115. /** @hidden */
  5116. easeInCore(gradient: number): number;
  5117. }
  5118. /**
  5119. * Easing function with a bouncing shape (see link below).
  5120. * @see https://easings.net/#easeInBounce
  5121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5122. */
  5123. export class BounceEase extends EasingFunction implements IEasingFunction {
  5124. /** Defines the number of bounces */
  5125. bounces: number;
  5126. /** Defines the amplitude of the bounce */
  5127. bounciness: number;
  5128. /**
  5129. * Instantiates a bounce easing
  5130. * @see https://easings.net/#easeInBounce
  5131. * @param bounces Defines the number of bounces
  5132. * @param bounciness Defines the amplitude of the bounce
  5133. */
  5134. constructor(
  5135. /** Defines the number of bounces */
  5136. bounces?: number,
  5137. /** Defines the amplitude of the bounce */
  5138. bounciness?: number);
  5139. /** @hidden */
  5140. easeInCore(gradient: number): number;
  5141. }
  5142. /**
  5143. * Easing function with a power of 3 shape (see link below).
  5144. * @see https://easings.net/#easeInCubic
  5145. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5146. */
  5147. export class CubicEase extends EasingFunction implements IEasingFunction {
  5148. /** @hidden */
  5149. easeInCore(gradient: number): number;
  5150. }
  5151. /**
  5152. * Easing function with an elastic shape (see link below).
  5153. * @see https://easings.net/#easeInElastic
  5154. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5155. */
  5156. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5157. /** Defines the number of oscillations*/
  5158. oscillations: number;
  5159. /** Defines the amplitude of the oscillations*/
  5160. springiness: number;
  5161. /**
  5162. * Instantiates an elastic easing function
  5163. * @see https://easings.net/#easeInElastic
  5164. * @param oscillations Defines the number of oscillations
  5165. * @param springiness Defines the amplitude of the oscillations
  5166. */
  5167. constructor(
  5168. /** Defines the number of oscillations*/
  5169. oscillations?: number,
  5170. /** Defines the amplitude of the oscillations*/
  5171. springiness?: number);
  5172. /** @hidden */
  5173. easeInCore(gradient: number): number;
  5174. }
  5175. /**
  5176. * Easing function with an exponential shape (see link below).
  5177. * @see https://easings.net/#easeInExpo
  5178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5179. */
  5180. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5181. /** Defines the exponent of the function */
  5182. exponent: number;
  5183. /**
  5184. * Instantiates an exponential easing function
  5185. * @see https://easings.net/#easeInExpo
  5186. * @param exponent Defines the exponent of the function
  5187. */
  5188. constructor(
  5189. /** Defines the exponent of the function */
  5190. exponent?: number);
  5191. /** @hidden */
  5192. easeInCore(gradient: number): number;
  5193. }
  5194. /**
  5195. * Easing function with a power shape (see link below).
  5196. * @see https://easings.net/#easeInQuad
  5197. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5198. */
  5199. export class PowerEase extends EasingFunction implements IEasingFunction {
  5200. /** Defines the power of the function */
  5201. power: number;
  5202. /**
  5203. * Instantiates an power base easing function
  5204. * @see https://easings.net/#easeInQuad
  5205. * @param power Defines the power of the function
  5206. */
  5207. constructor(
  5208. /** Defines the power of the function */
  5209. power?: number);
  5210. /** @hidden */
  5211. easeInCore(gradient: number): number;
  5212. }
  5213. /**
  5214. * Easing function with a power of 2 shape (see link below).
  5215. * @see https://easings.net/#easeInQuad
  5216. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5217. */
  5218. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5219. /** @hidden */
  5220. easeInCore(gradient: number): number;
  5221. }
  5222. /**
  5223. * Easing function with a power of 4 shape (see link below).
  5224. * @see https://easings.net/#easeInQuart
  5225. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5226. */
  5227. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5228. /** @hidden */
  5229. easeInCore(gradient: number): number;
  5230. }
  5231. /**
  5232. * Easing function with a power of 5 shape (see link below).
  5233. * @see https://easings.net/#easeInQuint
  5234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5235. */
  5236. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5237. /** @hidden */
  5238. easeInCore(gradient: number): number;
  5239. }
  5240. /**
  5241. * Easing function with a sin shape (see link below).
  5242. * @see https://easings.net/#easeInSine
  5243. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5244. */
  5245. export class SineEase extends EasingFunction implements IEasingFunction {
  5246. /** @hidden */
  5247. easeInCore(gradient: number): number;
  5248. }
  5249. /**
  5250. * Easing function with a bezier shape (see link below).
  5251. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5252. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5253. */
  5254. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5255. /** Defines the x component of the start tangent in the bezier curve */
  5256. x1: number;
  5257. /** Defines the y component of the start tangent in the bezier curve */
  5258. y1: number;
  5259. /** Defines the x component of the end tangent in the bezier curve */
  5260. x2: number;
  5261. /** Defines the y component of the end tangent in the bezier curve */
  5262. y2: number;
  5263. /**
  5264. * Instantiates a bezier function
  5265. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5266. * @param x1 Defines the x component of the start tangent in the bezier curve
  5267. * @param y1 Defines the y component of the start tangent in the bezier curve
  5268. * @param x2 Defines the x component of the end tangent in the bezier curve
  5269. * @param y2 Defines the y component of the end tangent in the bezier curve
  5270. */
  5271. constructor(
  5272. /** Defines the x component of the start tangent in the bezier curve */
  5273. x1?: number,
  5274. /** Defines the y component of the start tangent in the bezier curve */
  5275. y1?: number,
  5276. /** Defines the x component of the end tangent in the bezier curve */
  5277. x2?: number,
  5278. /** Defines the y component of the end tangent in the bezier curve */
  5279. y2?: number);
  5280. /** @hidden */
  5281. easeInCore(gradient: number): number;
  5282. }
  5283. }
  5284. declare module BABYLON {
  5285. /**
  5286. * Class used to hold a RBG color
  5287. */
  5288. export class Color3 {
  5289. /**
  5290. * Defines the red component (between 0 and 1, default is 0)
  5291. */
  5292. r: number;
  5293. /**
  5294. * Defines the green component (between 0 and 1, default is 0)
  5295. */
  5296. g: number;
  5297. /**
  5298. * Defines the blue component (between 0 and 1, default is 0)
  5299. */
  5300. b: number;
  5301. /**
  5302. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5303. * @param r defines the red component (between 0 and 1, default is 0)
  5304. * @param g defines the green component (between 0 and 1, default is 0)
  5305. * @param b defines the blue component (between 0 and 1, default is 0)
  5306. */
  5307. constructor(
  5308. /**
  5309. * Defines the red component (between 0 and 1, default is 0)
  5310. */
  5311. r?: number,
  5312. /**
  5313. * Defines the green component (between 0 and 1, default is 0)
  5314. */
  5315. g?: number,
  5316. /**
  5317. * Defines the blue component (between 0 and 1, default is 0)
  5318. */
  5319. b?: number);
  5320. /**
  5321. * Creates a string with the Color3 current values
  5322. * @returns the string representation of the Color3 object
  5323. */
  5324. toString(): string;
  5325. /**
  5326. * Returns the string "Color3"
  5327. * @returns "Color3"
  5328. */
  5329. getClassName(): string;
  5330. /**
  5331. * Compute the Color3 hash code
  5332. * @returns an unique number that can be used to hash Color3 objects
  5333. */
  5334. getHashCode(): number;
  5335. /**
  5336. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5337. * @param array defines the array where to store the r,g,b components
  5338. * @param index defines an optional index in the target array to define where to start storing values
  5339. * @returns the current Color3 object
  5340. */
  5341. toArray(array: FloatArray, index?: number): Color3;
  5342. /**
  5343. * Returns a new Color4 object from the current Color3 and the given alpha
  5344. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5345. * @returns a new Color4 object
  5346. */
  5347. toColor4(alpha?: number): Color4;
  5348. /**
  5349. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5350. * @returns the new array
  5351. */
  5352. asArray(): number[];
  5353. /**
  5354. * Returns the luminance value
  5355. * @returns a float value
  5356. */
  5357. toLuminance(): number;
  5358. /**
  5359. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5360. * @param otherColor defines the second operand
  5361. * @returns the new Color3 object
  5362. */
  5363. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5364. /**
  5365. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5366. * @param otherColor defines the second operand
  5367. * @param result defines the Color3 object where to store the result
  5368. * @returns the current Color3
  5369. */
  5370. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5371. /**
  5372. * Determines equality between Color3 objects
  5373. * @param otherColor defines the second operand
  5374. * @returns true if the rgb values are equal to the given ones
  5375. */
  5376. equals(otherColor: DeepImmutable<Color3>): boolean;
  5377. /**
  5378. * Determines equality between the current Color3 object and a set of r,b,g values
  5379. * @param r defines the red component to check
  5380. * @param g defines the green component to check
  5381. * @param b defines the blue component to check
  5382. * @returns true if the rgb values are equal to the given ones
  5383. */
  5384. equalsFloats(r: number, g: number, b: number): boolean;
  5385. /**
  5386. * Multiplies in place each rgb value by scale
  5387. * @param scale defines the scaling factor
  5388. * @returns the updated Color3
  5389. */
  5390. scale(scale: number): Color3;
  5391. /**
  5392. * Multiplies the rgb values by scale and stores the result into "result"
  5393. * @param scale defines the scaling factor
  5394. * @param result defines the Color3 object where to store the result
  5395. * @returns the unmodified current Color3
  5396. */
  5397. scaleToRef(scale: number, result: Color3): Color3;
  5398. /**
  5399. * Scale the current Color3 values by a factor and add the result to a given Color3
  5400. * @param scale defines the scale factor
  5401. * @param result defines color to store the result into
  5402. * @returns the unmodified current Color3
  5403. */
  5404. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5405. /**
  5406. * Clamps the rgb values by the min and max values and stores the result into "result"
  5407. * @param min defines minimum clamping value (default is 0)
  5408. * @param max defines maximum clamping value (default is 1)
  5409. * @param result defines color to store the result into
  5410. * @returns the original Color3
  5411. */
  5412. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5413. /**
  5414. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5415. * @param otherColor defines the second operand
  5416. * @returns the new Color3
  5417. */
  5418. add(otherColor: DeepImmutable<Color3>): Color3;
  5419. /**
  5420. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5421. * @param otherColor defines the second operand
  5422. * @param result defines Color3 object to store the result into
  5423. * @returns the unmodified current Color3
  5424. */
  5425. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5426. /**
  5427. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5428. * @param otherColor defines the second operand
  5429. * @returns the new Color3
  5430. */
  5431. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5432. /**
  5433. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5434. * @param otherColor defines the second operand
  5435. * @param result defines Color3 object to store the result into
  5436. * @returns the unmodified current Color3
  5437. */
  5438. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5439. /**
  5440. * Copy the current object
  5441. * @returns a new Color3 copied the current one
  5442. */
  5443. clone(): Color3;
  5444. /**
  5445. * Copies the rgb values from the source in the current Color3
  5446. * @param source defines the source Color3 object
  5447. * @returns the updated Color3 object
  5448. */
  5449. copyFrom(source: DeepImmutable<Color3>): Color3;
  5450. /**
  5451. * Updates the Color3 rgb values from the given floats
  5452. * @param r defines the red component to read from
  5453. * @param g defines the green component to read from
  5454. * @param b defines the blue component to read from
  5455. * @returns the current Color3 object
  5456. */
  5457. copyFromFloats(r: number, g: number, b: number): Color3;
  5458. /**
  5459. * Updates the Color3 rgb values from the given floats
  5460. * @param r defines the red component to read from
  5461. * @param g defines the green component to read from
  5462. * @param b defines the blue component to read from
  5463. * @returns the current Color3 object
  5464. */
  5465. set(r: number, g: number, b: number): Color3;
  5466. /**
  5467. * Compute the Color3 hexadecimal code as a string
  5468. * @returns a string containing the hexadecimal representation of the Color3 object
  5469. */
  5470. toHexString(): string;
  5471. /**
  5472. * Computes a new Color3 converted from the current one to linear space
  5473. * @returns a new Color3 object
  5474. */
  5475. toLinearSpace(): Color3;
  5476. /**
  5477. * Converts current color in rgb space to HSV values
  5478. * @returns a new color3 representing the HSV values
  5479. */
  5480. toHSV(): Color3;
  5481. /**
  5482. * Converts current color in rgb space to HSV values
  5483. * @param result defines the Color3 where to store the HSV values
  5484. */
  5485. toHSVToRef(result: Color3): void;
  5486. /**
  5487. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5488. * @param convertedColor defines the Color3 object where to store the linear space version
  5489. * @returns the unmodified Color3
  5490. */
  5491. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5492. /**
  5493. * Computes a new Color3 converted from the current one to gamma space
  5494. * @returns a new Color3 object
  5495. */
  5496. toGammaSpace(): Color3;
  5497. /**
  5498. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5499. * @param convertedColor defines the Color3 object where to store the gamma space version
  5500. * @returns the unmodified Color3
  5501. */
  5502. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5503. private static _BlackReadOnly;
  5504. /**
  5505. * Convert Hue, saturation and value to a Color3 (RGB)
  5506. * @param hue defines the hue
  5507. * @param saturation defines the saturation
  5508. * @param value defines the value
  5509. * @param result defines the Color3 where to store the RGB values
  5510. */
  5511. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5512. /**
  5513. * Creates a new Color3 from the string containing valid hexadecimal values
  5514. * @param hex defines a string containing valid hexadecimal values
  5515. * @returns a new Color3 object
  5516. */
  5517. static FromHexString(hex: string): Color3;
  5518. /**
  5519. * Creates a new Color3 from the starting index of the given array
  5520. * @param array defines the source array
  5521. * @param offset defines an offset in the source array
  5522. * @returns a new Color3 object
  5523. */
  5524. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5525. /**
  5526. * Creates a new Color3 from integer values (< 256)
  5527. * @param r defines the red component to read from (value between 0 and 255)
  5528. * @param g defines the green component to read from (value between 0 and 255)
  5529. * @param b defines the blue component to read from (value between 0 and 255)
  5530. * @returns a new Color3 object
  5531. */
  5532. static FromInts(r: number, g: number, b: number): Color3;
  5533. /**
  5534. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5535. * @param start defines the start Color3 value
  5536. * @param end defines the end Color3 value
  5537. * @param amount defines the gradient value between start and end
  5538. * @returns a new Color3 object
  5539. */
  5540. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5541. /**
  5542. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5543. * @param left defines the start value
  5544. * @param right defines the end value
  5545. * @param amount defines the gradient factor
  5546. * @param result defines the Color3 object where to store the result
  5547. */
  5548. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5549. /**
  5550. * Returns a Color3 value containing a red color
  5551. * @returns a new Color3 object
  5552. */
  5553. static Red(): Color3;
  5554. /**
  5555. * Returns a Color3 value containing a green color
  5556. * @returns a new Color3 object
  5557. */
  5558. static Green(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a blue color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Blue(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a black color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Black(): Color3;
  5569. /**
  5570. * Gets a Color3 value containing a black color that must not be updated
  5571. */
  5572. static get BlackReadOnly(): DeepImmutable<Color3>;
  5573. /**
  5574. * Returns a Color3 value containing a white color
  5575. * @returns a new Color3 object
  5576. */
  5577. static White(): Color3;
  5578. /**
  5579. * Returns a Color3 value containing a purple color
  5580. * @returns a new Color3 object
  5581. */
  5582. static Purple(): Color3;
  5583. /**
  5584. * Returns a Color3 value containing a magenta color
  5585. * @returns a new Color3 object
  5586. */
  5587. static Magenta(): Color3;
  5588. /**
  5589. * Returns a Color3 value containing a yellow color
  5590. * @returns a new Color3 object
  5591. */
  5592. static Yellow(): Color3;
  5593. /**
  5594. * Returns a Color3 value containing a gray color
  5595. * @returns a new Color3 object
  5596. */
  5597. static Gray(): Color3;
  5598. /**
  5599. * Returns a Color3 value containing a teal color
  5600. * @returns a new Color3 object
  5601. */
  5602. static Teal(): Color3;
  5603. /**
  5604. * Returns a Color3 value containing a random color
  5605. * @returns a new Color3 object
  5606. */
  5607. static Random(): Color3;
  5608. }
  5609. /**
  5610. * Class used to hold a RBGA color
  5611. */
  5612. export class Color4 {
  5613. /**
  5614. * Defines the red component (between 0 and 1, default is 0)
  5615. */
  5616. r: number;
  5617. /**
  5618. * Defines the green component (between 0 and 1, default is 0)
  5619. */
  5620. g: number;
  5621. /**
  5622. * Defines the blue component (between 0 and 1, default is 0)
  5623. */
  5624. b: number;
  5625. /**
  5626. * Defines the alpha component (between 0 and 1, default is 1)
  5627. */
  5628. a: number;
  5629. /**
  5630. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5631. * @param r defines the red component (between 0 and 1, default is 0)
  5632. * @param g defines the green component (between 0 and 1, default is 0)
  5633. * @param b defines the blue component (between 0 and 1, default is 0)
  5634. * @param a defines the alpha component (between 0 and 1, default is 1)
  5635. */
  5636. constructor(
  5637. /**
  5638. * Defines the red component (between 0 and 1, default is 0)
  5639. */
  5640. r?: number,
  5641. /**
  5642. * Defines the green component (between 0 and 1, default is 0)
  5643. */
  5644. g?: number,
  5645. /**
  5646. * Defines the blue component (between 0 and 1, default is 0)
  5647. */
  5648. b?: number,
  5649. /**
  5650. * Defines the alpha component (between 0 and 1, default is 1)
  5651. */
  5652. a?: number);
  5653. /**
  5654. * Adds in place the given Color4 values to the current Color4 object
  5655. * @param right defines the second operand
  5656. * @returns the current updated Color4 object
  5657. */
  5658. addInPlace(right: DeepImmutable<Color4>): Color4;
  5659. /**
  5660. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5661. * @returns the new array
  5662. */
  5663. asArray(): number[];
  5664. /**
  5665. * Stores from the starting index in the given array the Color4 successive values
  5666. * @param array defines the array where to store the r,g,b components
  5667. * @param index defines an optional index in the target array to define where to start storing values
  5668. * @returns the current Color4 object
  5669. */
  5670. toArray(array: number[], index?: number): Color4;
  5671. /**
  5672. * Determines equality between Color4 objects
  5673. * @param otherColor defines the second operand
  5674. * @returns true if the rgba values are equal to the given ones
  5675. */
  5676. equals(otherColor: DeepImmutable<Color4>): boolean;
  5677. /**
  5678. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5679. * @param right defines the second operand
  5680. * @returns a new Color4 object
  5681. */
  5682. add(right: DeepImmutable<Color4>): Color4;
  5683. /**
  5684. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5685. * @param right defines the second operand
  5686. * @returns a new Color4 object
  5687. */
  5688. subtract(right: DeepImmutable<Color4>): Color4;
  5689. /**
  5690. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5691. * @param right defines the second operand
  5692. * @param result defines the Color4 object where to store the result
  5693. * @returns the current Color4 object
  5694. */
  5695. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5696. /**
  5697. * Creates a new Color4 with the current Color4 values multiplied by scale
  5698. * @param scale defines the scaling factor to apply
  5699. * @returns a new Color4 object
  5700. */
  5701. scale(scale: number): Color4;
  5702. /**
  5703. * Multiplies the current Color4 values by scale and stores the result in "result"
  5704. * @param scale defines the scaling factor to apply
  5705. * @param result defines the Color4 object where to store the result
  5706. * @returns the current unmodified Color4
  5707. */
  5708. scaleToRef(scale: number, result: Color4): Color4;
  5709. /**
  5710. * Scale the current Color4 values by a factor and add the result to a given Color4
  5711. * @param scale defines the scale factor
  5712. * @param result defines the Color4 object where to store the result
  5713. * @returns the unmodified current Color4
  5714. */
  5715. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5716. /**
  5717. * Clamps the rgb values by the min and max values and stores the result into "result"
  5718. * @param min defines minimum clamping value (default is 0)
  5719. * @param max defines maximum clamping value (default is 1)
  5720. * @param result defines color to store the result into.
  5721. * @returns the cuurent Color4
  5722. */
  5723. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5724. /**
  5725. * Multipy an Color4 value by another and return a new Color4 object
  5726. * @param color defines the Color4 value to multiply by
  5727. * @returns a new Color4 object
  5728. */
  5729. multiply(color: Color4): Color4;
  5730. /**
  5731. * Multipy a Color4 value by another and push the result in a reference value
  5732. * @param color defines the Color4 value to multiply by
  5733. * @param result defines the Color4 to fill the result in
  5734. * @returns the result Color4
  5735. */
  5736. multiplyToRef(color: Color4, result: Color4): Color4;
  5737. /**
  5738. * Creates a string with the Color4 current values
  5739. * @returns the string representation of the Color4 object
  5740. */
  5741. toString(): string;
  5742. /**
  5743. * Returns the string "Color4"
  5744. * @returns "Color4"
  5745. */
  5746. getClassName(): string;
  5747. /**
  5748. * Compute the Color4 hash code
  5749. * @returns an unique number that can be used to hash Color4 objects
  5750. */
  5751. getHashCode(): number;
  5752. /**
  5753. * Creates a new Color4 copied from the current one
  5754. * @returns a new Color4 object
  5755. */
  5756. clone(): Color4;
  5757. /**
  5758. * Copies the given Color4 values into the current one
  5759. * @param source defines the source Color4 object
  5760. * @returns the current updated Color4 object
  5761. */
  5762. copyFrom(source: Color4): Color4;
  5763. /**
  5764. * Copies the given float values into the current one
  5765. * @param r defines the red component to read from
  5766. * @param g defines the green component to read from
  5767. * @param b defines the blue component to read from
  5768. * @param a defines the alpha component to read from
  5769. * @returns the current updated Color4 object
  5770. */
  5771. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5772. /**
  5773. * Copies the given float values into the current one
  5774. * @param r defines the red component to read from
  5775. * @param g defines the green component to read from
  5776. * @param b defines the blue component to read from
  5777. * @param a defines the alpha component to read from
  5778. * @returns the current updated Color4 object
  5779. */
  5780. set(r: number, g: number, b: number, a: number): Color4;
  5781. /**
  5782. * Compute the Color4 hexadecimal code as a string
  5783. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5784. * @returns a string containing the hexadecimal representation of the Color4 object
  5785. */
  5786. toHexString(returnAsColor3?: boolean): string;
  5787. /**
  5788. * Computes a new Color4 converted from the current one to linear space
  5789. * @returns a new Color4 object
  5790. */
  5791. toLinearSpace(): Color4;
  5792. /**
  5793. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5794. * @param convertedColor defines the Color4 object where to store the linear space version
  5795. * @returns the unmodified Color4
  5796. */
  5797. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5798. /**
  5799. * Computes a new Color4 converted from the current one to gamma space
  5800. * @returns a new Color4 object
  5801. */
  5802. toGammaSpace(): Color4;
  5803. /**
  5804. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5805. * @param convertedColor defines the Color4 object where to store the gamma space version
  5806. * @returns the unmodified Color4
  5807. */
  5808. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5809. /**
  5810. * Creates a new Color4 from the string containing valid hexadecimal values
  5811. * @param hex defines a string containing valid hexadecimal values
  5812. * @returns a new Color4 object
  5813. */
  5814. static FromHexString(hex: string): Color4;
  5815. /**
  5816. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5817. * @param left defines the start value
  5818. * @param right defines the end value
  5819. * @param amount defines the gradient factor
  5820. * @returns a new Color4 object
  5821. */
  5822. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5823. /**
  5824. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5825. * @param left defines the start value
  5826. * @param right defines the end value
  5827. * @param amount defines the gradient factor
  5828. * @param result defines the Color4 object where to store data
  5829. */
  5830. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5831. /**
  5832. * Creates a new Color4 from a Color3 and an alpha value
  5833. * @param color3 defines the source Color3 to read from
  5834. * @param alpha defines the alpha component (1.0 by default)
  5835. * @returns a new Color4 object
  5836. */
  5837. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5838. /**
  5839. * Creates a new Color4 from the starting index element of the given array
  5840. * @param array defines the source array to read from
  5841. * @param offset defines the offset in the source array
  5842. * @returns a new Color4 object
  5843. */
  5844. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5845. /**
  5846. * Creates a new Color3 from integer values (< 256)
  5847. * @param r defines the red component to read from (value between 0 and 255)
  5848. * @param g defines the green component to read from (value between 0 and 255)
  5849. * @param b defines the blue component to read from (value between 0 and 255)
  5850. * @param a defines the alpha component to read from (value between 0 and 255)
  5851. * @returns a new Color3 object
  5852. */
  5853. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5854. /**
  5855. * Check the content of a given array and convert it to an array containing RGBA data
  5856. * If the original array was already containing count * 4 values then it is returned directly
  5857. * @param colors defines the array to check
  5858. * @param count defines the number of RGBA data to expect
  5859. * @returns an array containing count * 4 values (RGBA)
  5860. */
  5861. static CheckColors4(colors: number[], count: number): number[];
  5862. }
  5863. /**
  5864. * @hidden
  5865. */
  5866. export class TmpColors {
  5867. static Color3: Color3[];
  5868. static Color4: Color4[];
  5869. }
  5870. }
  5871. declare module BABYLON {
  5872. /**
  5873. * Defines an interface which represents an animation key frame
  5874. */
  5875. export interface IAnimationKey {
  5876. /**
  5877. * Frame of the key frame
  5878. */
  5879. frame: number;
  5880. /**
  5881. * Value at the specifies key frame
  5882. */
  5883. value: any;
  5884. /**
  5885. * The input tangent for the cubic hermite spline
  5886. */
  5887. inTangent?: any;
  5888. /**
  5889. * The output tangent for the cubic hermite spline
  5890. */
  5891. outTangent?: any;
  5892. /**
  5893. * The animation interpolation type
  5894. */
  5895. interpolation?: AnimationKeyInterpolation;
  5896. }
  5897. /**
  5898. * Enum for the animation key frame interpolation type
  5899. */
  5900. export enum AnimationKeyInterpolation {
  5901. /**
  5902. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5903. */
  5904. STEP = 1
  5905. }
  5906. }
  5907. declare module BABYLON {
  5908. /**
  5909. * Represents the range of an animation
  5910. */
  5911. export class AnimationRange {
  5912. /**The name of the animation range**/
  5913. name: string;
  5914. /**The starting frame of the animation */
  5915. from: number;
  5916. /**The ending frame of the animation*/
  5917. to: number;
  5918. /**
  5919. * Initializes the range of an animation
  5920. * @param name The name of the animation range
  5921. * @param from The starting frame of the animation
  5922. * @param to The ending frame of the animation
  5923. */
  5924. constructor(
  5925. /**The name of the animation range**/
  5926. name: string,
  5927. /**The starting frame of the animation */
  5928. from: number,
  5929. /**The ending frame of the animation*/
  5930. to: number);
  5931. /**
  5932. * Makes a copy of the animation range
  5933. * @returns A copy of the animation range
  5934. */
  5935. clone(): AnimationRange;
  5936. }
  5937. }
  5938. declare module BABYLON {
  5939. /**
  5940. * Composed of a frame, and an action function
  5941. */
  5942. export class AnimationEvent {
  5943. /** The frame for which the event is triggered **/
  5944. frame: number;
  5945. /** The event to perform when triggered **/
  5946. action: (currentFrame: number) => void;
  5947. /** Specifies if the event should be triggered only once**/
  5948. onlyOnce?: boolean | undefined;
  5949. /**
  5950. * Specifies if the animation event is done
  5951. */
  5952. isDone: boolean;
  5953. /**
  5954. * Initializes the animation event
  5955. * @param frame The frame for which the event is triggered
  5956. * @param action The event to perform when triggered
  5957. * @param onlyOnce Specifies if the event should be triggered only once
  5958. */
  5959. constructor(
  5960. /** The frame for which the event is triggered **/
  5961. frame: number,
  5962. /** The event to perform when triggered **/
  5963. action: (currentFrame: number) => void,
  5964. /** Specifies if the event should be triggered only once**/
  5965. onlyOnce?: boolean | undefined);
  5966. /** @hidden */
  5967. _clone(): AnimationEvent;
  5968. }
  5969. }
  5970. declare module BABYLON {
  5971. /**
  5972. * Interface used to define a behavior
  5973. */
  5974. export interface Behavior<T> {
  5975. /** gets or sets behavior's name */
  5976. name: string;
  5977. /**
  5978. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5979. */
  5980. init(): void;
  5981. /**
  5982. * Called when the behavior is attached to a target
  5983. * @param target defines the target where the behavior is attached to
  5984. */
  5985. attach(target: T): void;
  5986. /**
  5987. * Called when the behavior is detached from its target
  5988. */
  5989. detach(): void;
  5990. }
  5991. /**
  5992. * Interface implemented by classes supporting behaviors
  5993. */
  5994. export interface IBehaviorAware<T> {
  5995. /**
  5996. * Attach a behavior
  5997. * @param behavior defines the behavior to attach
  5998. * @returns the current host
  5999. */
  6000. addBehavior(behavior: Behavior<T>): T;
  6001. /**
  6002. * Remove a behavior from the current object
  6003. * @param behavior defines the behavior to detach
  6004. * @returns the current host
  6005. */
  6006. removeBehavior(behavior: Behavior<T>): T;
  6007. /**
  6008. * Gets a behavior using its name to search
  6009. * @param name defines the name to search
  6010. * @returns the behavior or null if not found
  6011. */
  6012. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6013. }
  6014. }
  6015. declare module BABYLON {
  6016. /**
  6017. * Defines an array and its length.
  6018. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6019. */
  6020. export interface ISmartArrayLike<T> {
  6021. /**
  6022. * The data of the array.
  6023. */
  6024. data: Array<T>;
  6025. /**
  6026. * The active length of the array.
  6027. */
  6028. length: number;
  6029. }
  6030. /**
  6031. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6032. */
  6033. export class SmartArray<T> implements ISmartArrayLike<T> {
  6034. /**
  6035. * The full set of data from the array.
  6036. */
  6037. data: Array<T>;
  6038. /**
  6039. * The active length of the array.
  6040. */
  6041. length: number;
  6042. protected _id: number;
  6043. /**
  6044. * Instantiates a Smart Array.
  6045. * @param capacity defines the default capacity of the array.
  6046. */
  6047. constructor(capacity: number);
  6048. /**
  6049. * Pushes a value at the end of the active data.
  6050. * @param value defines the object to push in the array.
  6051. */
  6052. push(value: T): void;
  6053. /**
  6054. * Iterates over the active data and apply the lambda to them.
  6055. * @param func defines the action to apply on each value.
  6056. */
  6057. forEach(func: (content: T) => void): void;
  6058. /**
  6059. * Sorts the full sets of data.
  6060. * @param compareFn defines the comparison function to apply.
  6061. */
  6062. sort(compareFn: (a: T, b: T) => number): void;
  6063. /**
  6064. * Resets the active data to an empty array.
  6065. */
  6066. reset(): void;
  6067. /**
  6068. * Releases all the data from the array as well as the array.
  6069. */
  6070. dispose(): void;
  6071. /**
  6072. * Concats the active data with a given array.
  6073. * @param array defines the data to concatenate with.
  6074. */
  6075. concat(array: any): void;
  6076. /**
  6077. * Returns the position of a value in the active data.
  6078. * @param value defines the value to find the index for
  6079. * @returns the index if found in the active data otherwise -1
  6080. */
  6081. indexOf(value: T): number;
  6082. /**
  6083. * Returns whether an element is part of the active data.
  6084. * @param value defines the value to look for
  6085. * @returns true if found in the active data otherwise false
  6086. */
  6087. contains(value: T): boolean;
  6088. private static _GlobalId;
  6089. }
  6090. /**
  6091. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6092. * The data in this array can only be present once
  6093. */
  6094. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6095. private _duplicateId;
  6096. /**
  6097. * Pushes a value at the end of the active data.
  6098. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6099. * @param value defines the object to push in the array.
  6100. */
  6101. push(value: T): void;
  6102. /**
  6103. * Pushes a value at the end of the active data.
  6104. * If the data is already present, it won t be added again
  6105. * @param value defines the object to push in the array.
  6106. * @returns true if added false if it was already present
  6107. */
  6108. pushNoDuplicate(value: T): boolean;
  6109. /**
  6110. * Resets the active data to an empty array.
  6111. */
  6112. reset(): void;
  6113. /**
  6114. * Concats the active data with a given array.
  6115. * This ensures no dupplicate will be present in the result.
  6116. * @param array defines the data to concatenate with.
  6117. */
  6118. concatWithNoDuplicate(array: any): void;
  6119. }
  6120. }
  6121. declare module BABYLON {
  6122. /**
  6123. * @ignore
  6124. * This is a list of all the different input types that are available in the application.
  6125. * Fo instance: ArcRotateCameraGamepadInput...
  6126. */
  6127. export var CameraInputTypes: {};
  6128. /**
  6129. * This is the contract to implement in order to create a new input class.
  6130. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6131. */
  6132. export interface ICameraInput<TCamera extends Camera> {
  6133. /**
  6134. * Defines the camera the input is attached to.
  6135. */
  6136. camera: Nullable<TCamera>;
  6137. /**
  6138. * Gets the class name of the current intput.
  6139. * @returns the class name
  6140. */
  6141. getClassName(): string;
  6142. /**
  6143. * Get the friendly name associated with the input class.
  6144. * @returns the input friendly name
  6145. */
  6146. getSimpleName(): string;
  6147. /**
  6148. * Attach the input controls to a specific dom element to get the input from.
  6149. * @param element Defines the element the controls should be listened from
  6150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6151. */
  6152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6153. /**
  6154. * Detach the current controls from the specified dom element.
  6155. * @param element Defines the element to stop listening the inputs from
  6156. */
  6157. detachControl(element: Nullable<HTMLElement>): void;
  6158. /**
  6159. * Update the current camera state depending on the inputs that have been used this frame.
  6160. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6161. */
  6162. checkInputs?: () => void;
  6163. }
  6164. /**
  6165. * Represents a map of input types to input instance or input index to input instance.
  6166. */
  6167. export interface CameraInputsMap<TCamera extends Camera> {
  6168. /**
  6169. * Accessor to the input by input type.
  6170. */
  6171. [name: string]: ICameraInput<TCamera>;
  6172. /**
  6173. * Accessor to the input by input index.
  6174. */
  6175. [idx: number]: ICameraInput<TCamera>;
  6176. }
  6177. /**
  6178. * This represents the input manager used within a camera.
  6179. * It helps dealing with all the different kind of input attached to a camera.
  6180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6181. */
  6182. export class CameraInputsManager<TCamera extends Camera> {
  6183. /**
  6184. * Defines the list of inputs attahed to the camera.
  6185. */
  6186. attached: CameraInputsMap<TCamera>;
  6187. /**
  6188. * Defines the dom element the camera is collecting inputs from.
  6189. * This is null if the controls have not been attached.
  6190. */
  6191. attachedElement: Nullable<HTMLElement>;
  6192. /**
  6193. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6194. */
  6195. noPreventDefault: boolean;
  6196. /**
  6197. * Defined the camera the input manager belongs to.
  6198. */
  6199. camera: TCamera;
  6200. /**
  6201. * Update the current camera state depending on the inputs that have been used this frame.
  6202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6203. */
  6204. checkInputs: () => void;
  6205. /**
  6206. * Instantiate a new Camera Input Manager.
  6207. * @param camera Defines the camera the input manager blongs to
  6208. */
  6209. constructor(camera: TCamera);
  6210. /**
  6211. * Add an input method to a camera
  6212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6213. * @param input camera input method
  6214. */
  6215. add(input: ICameraInput<TCamera>): void;
  6216. /**
  6217. * Remove a specific input method from a camera
  6218. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6219. * @param inputToRemove camera input method
  6220. */
  6221. remove(inputToRemove: ICameraInput<TCamera>): void;
  6222. /**
  6223. * Remove a specific input type from a camera
  6224. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6225. * @param inputType the type of the input to remove
  6226. */
  6227. removeByType(inputType: string): void;
  6228. private _addCheckInputs;
  6229. /**
  6230. * Attach the input controls to the currently attached dom element to listen the events from.
  6231. * @param input Defines the input to attach
  6232. */
  6233. attachInput(input: ICameraInput<TCamera>): void;
  6234. /**
  6235. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6236. * @param element Defines the dom element to collect the events from
  6237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6238. */
  6239. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6240. /**
  6241. * Detach the current manager inputs controls from a specific dom element.
  6242. * @param element Defines the dom element to collect the events from
  6243. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6244. */
  6245. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6246. /**
  6247. * Rebuild the dynamic inputCheck function from the current list of
  6248. * defined inputs in the manager.
  6249. */
  6250. rebuildInputCheck(): void;
  6251. /**
  6252. * Remove all attached input methods from a camera
  6253. */
  6254. clear(): void;
  6255. /**
  6256. * Serialize the current input manager attached to a camera.
  6257. * This ensures than once parsed,
  6258. * the input associated to the camera will be identical to the current ones
  6259. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6260. */
  6261. serialize(serializedCamera: any): void;
  6262. /**
  6263. * Parses an input manager serialized JSON to restore the previous list of inputs
  6264. * and states associated to a camera.
  6265. * @param parsedCamera Defines the JSON to parse
  6266. */
  6267. parse(parsedCamera: any): void;
  6268. }
  6269. }
  6270. declare module BABYLON {
  6271. /**
  6272. * Class used to store data that will be store in GPU memory
  6273. */
  6274. export class Buffer {
  6275. private _engine;
  6276. private _buffer;
  6277. /** @hidden */
  6278. _data: Nullable<DataArray>;
  6279. private _updatable;
  6280. private _instanced;
  6281. private _divisor;
  6282. /**
  6283. * Gets the byte stride.
  6284. */
  6285. readonly byteStride: number;
  6286. /**
  6287. * Constructor
  6288. * @param engine the engine
  6289. * @param data the data to use for this buffer
  6290. * @param updatable whether the data is updatable
  6291. * @param stride the stride (optional)
  6292. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6293. * @param instanced whether the buffer is instanced (optional)
  6294. * @param useBytes set to true if the stride in in bytes (optional)
  6295. * @param divisor sets an optional divisor for instances (1 by default)
  6296. */
  6297. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6298. /**
  6299. * Create a new VertexBuffer based on the current buffer
  6300. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6301. * @param offset defines offset in the buffer (0 by default)
  6302. * @param size defines the size in floats of attributes (position is 3 for instance)
  6303. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6304. * @param instanced defines if the vertex buffer contains indexed data
  6305. * @param useBytes defines if the offset and stride are in bytes *
  6306. * @param divisor sets an optional divisor for instances (1 by default)
  6307. * @returns the new vertex buffer
  6308. */
  6309. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6310. /**
  6311. * Gets a boolean indicating if the Buffer is updatable?
  6312. * @returns true if the buffer is updatable
  6313. */
  6314. isUpdatable(): boolean;
  6315. /**
  6316. * Gets current buffer's data
  6317. * @returns a DataArray or null
  6318. */
  6319. getData(): Nullable<DataArray>;
  6320. /**
  6321. * Gets underlying native buffer
  6322. * @returns underlying native buffer
  6323. */
  6324. getBuffer(): Nullable<DataBuffer>;
  6325. /**
  6326. * Gets the stride in float32 units (i.e. byte stride / 4).
  6327. * May not be an integer if the byte stride is not divisible by 4.
  6328. * @returns the stride in float32 units
  6329. * @deprecated Please use byteStride instead.
  6330. */
  6331. getStrideSize(): number;
  6332. /**
  6333. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6334. * @param data defines the data to store
  6335. */
  6336. create(data?: Nullable<DataArray>): void;
  6337. /** @hidden */
  6338. _rebuild(): void;
  6339. /**
  6340. * Update current buffer data
  6341. * @param data defines the data to store
  6342. */
  6343. update(data: DataArray): void;
  6344. /**
  6345. * Updates the data directly.
  6346. * @param data the new data
  6347. * @param offset the new offset
  6348. * @param vertexCount the vertex count (optional)
  6349. * @param useBytes set to true if the offset is in bytes
  6350. */
  6351. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6352. /**
  6353. * Release all resources
  6354. */
  6355. dispose(): void;
  6356. }
  6357. /**
  6358. * Specialized buffer used to store vertex data
  6359. */
  6360. export class VertexBuffer {
  6361. /** @hidden */
  6362. _buffer: Buffer;
  6363. private _kind;
  6364. private _size;
  6365. private _ownsBuffer;
  6366. private _instanced;
  6367. private _instanceDivisor;
  6368. /**
  6369. * The byte type.
  6370. */
  6371. static readonly BYTE: number;
  6372. /**
  6373. * The unsigned byte type.
  6374. */
  6375. static readonly UNSIGNED_BYTE: number;
  6376. /**
  6377. * The short type.
  6378. */
  6379. static readonly SHORT: number;
  6380. /**
  6381. * The unsigned short type.
  6382. */
  6383. static readonly UNSIGNED_SHORT: number;
  6384. /**
  6385. * The integer type.
  6386. */
  6387. static readonly INT: number;
  6388. /**
  6389. * The unsigned integer type.
  6390. */
  6391. static readonly UNSIGNED_INT: number;
  6392. /**
  6393. * The float type.
  6394. */
  6395. static readonly FLOAT: number;
  6396. /**
  6397. * Gets or sets the instance divisor when in instanced mode
  6398. */
  6399. get instanceDivisor(): number;
  6400. set instanceDivisor(value: number);
  6401. /**
  6402. * Gets the byte stride.
  6403. */
  6404. readonly byteStride: number;
  6405. /**
  6406. * Gets the byte offset.
  6407. */
  6408. readonly byteOffset: number;
  6409. /**
  6410. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6411. */
  6412. readonly normalized: boolean;
  6413. /**
  6414. * Gets the data type of each component in the array.
  6415. */
  6416. readonly type: number;
  6417. /**
  6418. * Constructor
  6419. * @param engine the engine
  6420. * @param data the data to use for this vertex buffer
  6421. * @param kind the vertex buffer kind
  6422. * @param updatable whether the data is updatable
  6423. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6424. * @param stride the stride (optional)
  6425. * @param instanced whether the buffer is instanced (optional)
  6426. * @param offset the offset of the data (optional)
  6427. * @param size the number of components (optional)
  6428. * @param type the type of the component (optional)
  6429. * @param normalized whether the data contains normalized data (optional)
  6430. * @param useBytes set to true if stride and offset are in bytes (optional)
  6431. * @param divisor defines the instance divisor to use (1 by default)
  6432. */
  6433. 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);
  6434. /** @hidden */
  6435. _rebuild(): void;
  6436. /**
  6437. * Returns the kind of the VertexBuffer (string)
  6438. * @returns a string
  6439. */
  6440. getKind(): string;
  6441. /**
  6442. * Gets a boolean indicating if the VertexBuffer is updatable?
  6443. * @returns true if the buffer is updatable
  6444. */
  6445. isUpdatable(): boolean;
  6446. /**
  6447. * Gets current buffer's data
  6448. * @returns a DataArray or null
  6449. */
  6450. getData(): Nullable<DataArray>;
  6451. /**
  6452. * Gets underlying native buffer
  6453. * @returns underlying native buffer
  6454. */
  6455. getBuffer(): Nullable<DataBuffer>;
  6456. /**
  6457. * Gets the stride in float32 units (i.e. byte stride / 4).
  6458. * May not be an integer if the byte stride is not divisible by 4.
  6459. * @returns the stride in float32 units
  6460. * @deprecated Please use byteStride instead.
  6461. */
  6462. getStrideSize(): number;
  6463. /**
  6464. * Returns the offset as a multiple of the type byte length.
  6465. * @returns the offset in bytes
  6466. * @deprecated Please use byteOffset instead.
  6467. */
  6468. getOffset(): number;
  6469. /**
  6470. * Returns the number of components per vertex attribute (integer)
  6471. * @returns the size in float
  6472. */
  6473. getSize(): number;
  6474. /**
  6475. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6476. * @returns true if this buffer is instanced
  6477. */
  6478. getIsInstanced(): boolean;
  6479. /**
  6480. * Returns the instancing divisor, zero for non-instanced (integer).
  6481. * @returns a number
  6482. */
  6483. getInstanceDivisor(): number;
  6484. /**
  6485. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6486. * @param data defines the data to store
  6487. */
  6488. create(data?: DataArray): void;
  6489. /**
  6490. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6491. * This function will create a new buffer if the current one is not updatable
  6492. * @param data defines the data to store
  6493. */
  6494. update(data: DataArray): void;
  6495. /**
  6496. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6497. * Returns the directly updated WebGLBuffer.
  6498. * @param data the new data
  6499. * @param offset the new offset
  6500. * @param useBytes set to true if the offset is in bytes
  6501. */
  6502. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6503. /**
  6504. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6505. */
  6506. dispose(): void;
  6507. /**
  6508. * Enumerates each value of this vertex buffer as numbers.
  6509. * @param count the number of values to enumerate
  6510. * @param callback the callback function called for each value
  6511. */
  6512. forEach(count: number, callback: (value: number, index: number) => void): void;
  6513. /**
  6514. * Positions
  6515. */
  6516. static readonly PositionKind: string;
  6517. /**
  6518. * Normals
  6519. */
  6520. static readonly NormalKind: string;
  6521. /**
  6522. * Tangents
  6523. */
  6524. static readonly TangentKind: string;
  6525. /**
  6526. * Texture coordinates
  6527. */
  6528. static readonly UVKind: string;
  6529. /**
  6530. * Texture coordinates 2
  6531. */
  6532. static readonly UV2Kind: string;
  6533. /**
  6534. * Texture coordinates 3
  6535. */
  6536. static readonly UV3Kind: string;
  6537. /**
  6538. * Texture coordinates 4
  6539. */
  6540. static readonly UV4Kind: string;
  6541. /**
  6542. * Texture coordinates 5
  6543. */
  6544. static readonly UV5Kind: string;
  6545. /**
  6546. * Texture coordinates 6
  6547. */
  6548. static readonly UV6Kind: string;
  6549. /**
  6550. * Colors
  6551. */
  6552. static readonly ColorKind: string;
  6553. /**
  6554. * Matrix indices (for bones)
  6555. */
  6556. static readonly MatricesIndicesKind: string;
  6557. /**
  6558. * Matrix weights (for bones)
  6559. */
  6560. static readonly MatricesWeightsKind: string;
  6561. /**
  6562. * Additional matrix indices (for bones)
  6563. */
  6564. static readonly MatricesIndicesExtraKind: string;
  6565. /**
  6566. * Additional matrix weights (for bones)
  6567. */
  6568. static readonly MatricesWeightsExtraKind: string;
  6569. /**
  6570. * Deduces the stride given a kind.
  6571. * @param kind The kind string to deduce
  6572. * @returns The deduced stride
  6573. */
  6574. static DeduceStride(kind: string): number;
  6575. /**
  6576. * Gets the byte length of the given type.
  6577. * @param type the type
  6578. * @returns the number of bytes
  6579. */
  6580. static GetTypeByteLength(type: number): number;
  6581. /**
  6582. * Enumerates each value of the given parameters as numbers.
  6583. * @param data the data to enumerate
  6584. * @param byteOffset the byte offset of the data
  6585. * @param byteStride the byte stride of the data
  6586. * @param componentCount the number of components per element
  6587. * @param componentType the type of the component
  6588. * @param count the number of values to enumerate
  6589. * @param normalized whether the data is normalized
  6590. * @param callback the callback function called for each value
  6591. */
  6592. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6593. private static _GetFloatValue;
  6594. }
  6595. }
  6596. declare module BABYLON {
  6597. /**
  6598. * @hidden
  6599. */
  6600. export class IntersectionInfo {
  6601. bu: Nullable<number>;
  6602. bv: Nullable<number>;
  6603. distance: number;
  6604. faceId: number;
  6605. subMeshId: number;
  6606. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6607. }
  6608. }
  6609. declare module BABYLON {
  6610. /**
  6611. * Represens a plane by the equation ax + by + cz + d = 0
  6612. */
  6613. export class Plane {
  6614. private static _TmpMatrix;
  6615. /**
  6616. * Normal of the plane (a,b,c)
  6617. */
  6618. normal: Vector3;
  6619. /**
  6620. * d component of the plane
  6621. */
  6622. d: number;
  6623. /**
  6624. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6625. * @param a a component of the plane
  6626. * @param b b component of the plane
  6627. * @param c c component of the plane
  6628. * @param d d component of the plane
  6629. */
  6630. constructor(a: number, b: number, c: number, d: number);
  6631. /**
  6632. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6633. */
  6634. asArray(): number[];
  6635. /**
  6636. * @returns a new plane copied from the current Plane.
  6637. */
  6638. clone(): Plane;
  6639. /**
  6640. * @returns the string "Plane".
  6641. */
  6642. getClassName(): string;
  6643. /**
  6644. * @returns the Plane hash code.
  6645. */
  6646. getHashCode(): number;
  6647. /**
  6648. * Normalize the current Plane in place.
  6649. * @returns the updated Plane.
  6650. */
  6651. normalize(): Plane;
  6652. /**
  6653. * Applies a transformation the plane and returns the result
  6654. * @param transformation the transformation matrix to be applied to the plane
  6655. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6656. */
  6657. transform(transformation: DeepImmutable<Matrix>): Plane;
  6658. /**
  6659. * Calcualtte the dot product between the point and the plane normal
  6660. * @param point point to calculate the dot product with
  6661. * @returns the dot product (float) of the point coordinates and the plane normal.
  6662. */
  6663. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6664. /**
  6665. * Updates the current Plane from the plane defined by the three given points.
  6666. * @param point1 one of the points used to contruct the plane
  6667. * @param point2 one of the points used to contruct the plane
  6668. * @param point3 one of the points used to contruct the plane
  6669. * @returns the updated Plane.
  6670. */
  6671. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6672. /**
  6673. * Checks if the plane is facing a given direction
  6674. * @param direction the direction to check if the plane is facing
  6675. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6676. * @returns True is the vector "direction" is the same side than the plane normal.
  6677. */
  6678. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6679. /**
  6680. * Calculates the distance to a point
  6681. * @param point point to calculate distance to
  6682. * @returns the signed distance (float) from the given point to the Plane.
  6683. */
  6684. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6685. /**
  6686. * Creates a plane from an array
  6687. * @param array the array to create a plane from
  6688. * @returns a new Plane from the given array.
  6689. */
  6690. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6691. /**
  6692. * Creates a plane from three points
  6693. * @param point1 point used to create the plane
  6694. * @param point2 point used to create the plane
  6695. * @param point3 point used to create the plane
  6696. * @returns a new Plane defined by the three given points.
  6697. */
  6698. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6699. /**
  6700. * Creates a plane from an origin point and a normal
  6701. * @param origin origin of the plane to be constructed
  6702. * @param normal normal of the plane to be constructed
  6703. * @returns a new Plane the normal vector to this plane at the given origin point.
  6704. * Note : the vector "normal" is updated because normalized.
  6705. */
  6706. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6707. /**
  6708. * Calculates the distance from a plane and a point
  6709. * @param origin origin of the plane to be constructed
  6710. * @param normal normal of the plane to be constructed
  6711. * @param point point to calculate distance to
  6712. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6713. */
  6714. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6715. }
  6716. }
  6717. declare module BABYLON {
  6718. /**
  6719. * Class used to store bounding sphere information
  6720. */
  6721. export class BoundingSphere {
  6722. /**
  6723. * Gets the center of the bounding sphere in local space
  6724. */
  6725. readonly center: Vector3;
  6726. /**
  6727. * Radius of the bounding sphere in local space
  6728. */
  6729. radius: number;
  6730. /**
  6731. * Gets the center of the bounding sphere in world space
  6732. */
  6733. readonly centerWorld: Vector3;
  6734. /**
  6735. * Radius of the bounding sphere in world space
  6736. */
  6737. radiusWorld: number;
  6738. /**
  6739. * Gets the minimum vector in local space
  6740. */
  6741. readonly minimum: Vector3;
  6742. /**
  6743. * Gets the maximum vector in local space
  6744. */
  6745. readonly maximum: Vector3;
  6746. private _worldMatrix;
  6747. private static readonly TmpVector3;
  6748. /**
  6749. * Creates a new bounding sphere
  6750. * @param min defines the minimum vector (in local space)
  6751. * @param max defines the maximum vector (in local space)
  6752. * @param worldMatrix defines the new world matrix
  6753. */
  6754. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6755. /**
  6756. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6757. * @param min defines the new minimum vector (in local space)
  6758. * @param max defines the new maximum vector (in local space)
  6759. * @param worldMatrix defines the new world matrix
  6760. */
  6761. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6762. /**
  6763. * Scale the current bounding sphere by applying a scale factor
  6764. * @param factor defines the scale factor to apply
  6765. * @returns the current bounding box
  6766. */
  6767. scale(factor: number): BoundingSphere;
  6768. /**
  6769. * Gets the world matrix of the bounding box
  6770. * @returns a matrix
  6771. */
  6772. getWorldMatrix(): DeepImmutable<Matrix>;
  6773. /** @hidden */
  6774. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6775. /**
  6776. * Tests if the bounding sphere is intersecting the frustum planes
  6777. * @param frustumPlanes defines the frustum planes to test
  6778. * @returns true if there is an intersection
  6779. */
  6780. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6781. /**
  6782. * Tests if the bounding sphere center is in between the frustum planes.
  6783. * Used for optimistic fast inclusion.
  6784. * @param frustumPlanes defines the frustum planes to test
  6785. * @returns true if the sphere center is in between the frustum planes
  6786. */
  6787. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6788. /**
  6789. * Tests if a point is inside the bounding sphere
  6790. * @param point defines the point to test
  6791. * @returns true if the point is inside the bounding sphere
  6792. */
  6793. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6794. /**
  6795. * Checks if two sphere intersct
  6796. * @param sphere0 sphere 0
  6797. * @param sphere1 sphere 1
  6798. * @returns true if the speres intersect
  6799. */
  6800. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6801. }
  6802. }
  6803. declare module BABYLON {
  6804. /**
  6805. * Class used to store bounding box information
  6806. */
  6807. export class BoundingBox implements ICullable {
  6808. /**
  6809. * Gets the 8 vectors representing the bounding box in local space
  6810. */
  6811. readonly vectors: Vector3[];
  6812. /**
  6813. * Gets the center of the bounding box in local space
  6814. */
  6815. readonly center: Vector3;
  6816. /**
  6817. * Gets the center of the bounding box in world space
  6818. */
  6819. readonly centerWorld: Vector3;
  6820. /**
  6821. * Gets the extend size in local space
  6822. */
  6823. readonly extendSize: Vector3;
  6824. /**
  6825. * Gets the extend size in world space
  6826. */
  6827. readonly extendSizeWorld: Vector3;
  6828. /**
  6829. * Gets the OBB (object bounding box) directions
  6830. */
  6831. readonly directions: Vector3[];
  6832. /**
  6833. * Gets the 8 vectors representing the bounding box in world space
  6834. */
  6835. readonly vectorsWorld: Vector3[];
  6836. /**
  6837. * Gets the minimum vector in world space
  6838. */
  6839. readonly minimumWorld: Vector3;
  6840. /**
  6841. * Gets the maximum vector in world space
  6842. */
  6843. readonly maximumWorld: Vector3;
  6844. /**
  6845. * Gets the minimum vector in local space
  6846. */
  6847. readonly minimum: Vector3;
  6848. /**
  6849. * Gets the maximum vector in local space
  6850. */
  6851. readonly maximum: Vector3;
  6852. private _worldMatrix;
  6853. private static readonly TmpVector3;
  6854. /**
  6855. * @hidden
  6856. */
  6857. _tag: number;
  6858. /**
  6859. * Creates a new bounding box
  6860. * @param min defines the minimum vector (in local space)
  6861. * @param max defines the maximum vector (in local space)
  6862. * @param worldMatrix defines the new world matrix
  6863. */
  6864. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6865. /**
  6866. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6867. * @param min defines the new minimum vector (in local space)
  6868. * @param max defines the new maximum vector (in local space)
  6869. * @param worldMatrix defines the new world matrix
  6870. */
  6871. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6872. /**
  6873. * Scale the current bounding box by applying a scale factor
  6874. * @param factor defines the scale factor to apply
  6875. * @returns the current bounding box
  6876. */
  6877. scale(factor: number): BoundingBox;
  6878. /**
  6879. * Gets the world matrix of the bounding box
  6880. * @returns a matrix
  6881. */
  6882. getWorldMatrix(): DeepImmutable<Matrix>;
  6883. /** @hidden */
  6884. _update(world: DeepImmutable<Matrix>): void;
  6885. /**
  6886. * Tests if the bounding box is intersecting the frustum planes
  6887. * @param frustumPlanes defines the frustum planes to test
  6888. * @returns true if there is an intersection
  6889. */
  6890. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6891. /**
  6892. * Tests if the bounding box is entirely inside the frustum planes
  6893. * @param frustumPlanes defines the frustum planes to test
  6894. * @returns true if there is an inclusion
  6895. */
  6896. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6897. /**
  6898. * Tests if a point is inside the bounding box
  6899. * @param point defines the point to test
  6900. * @returns true if the point is inside the bounding box
  6901. */
  6902. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6903. /**
  6904. * Tests if the bounding box intersects with a bounding sphere
  6905. * @param sphere defines the sphere to test
  6906. * @returns true if there is an intersection
  6907. */
  6908. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6909. /**
  6910. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6911. * @param min defines the min vector to use
  6912. * @param max defines the max vector to use
  6913. * @returns true if there is an intersection
  6914. */
  6915. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6916. /**
  6917. * Tests if two bounding boxes are intersections
  6918. * @param box0 defines the first box to test
  6919. * @param box1 defines the second box to test
  6920. * @returns true if there is an intersection
  6921. */
  6922. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6923. /**
  6924. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6925. * @param minPoint defines the minimum vector of the bounding box
  6926. * @param maxPoint defines the maximum vector of the bounding box
  6927. * @param sphereCenter defines the sphere center
  6928. * @param sphereRadius defines the sphere radius
  6929. * @returns true if there is an intersection
  6930. */
  6931. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6932. /**
  6933. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6934. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6935. * @param frustumPlanes defines the frustum planes to test
  6936. * @return true if there is an inclusion
  6937. */
  6938. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6939. /**
  6940. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6941. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @return true if there is an intersection
  6944. */
  6945. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. }
  6947. }
  6948. declare module BABYLON {
  6949. /** @hidden */
  6950. export class Collider {
  6951. /** Define if a collision was found */
  6952. collisionFound: boolean;
  6953. /**
  6954. * Define last intersection point in local space
  6955. */
  6956. intersectionPoint: Vector3;
  6957. /**
  6958. * Define last collided mesh
  6959. */
  6960. collidedMesh: Nullable<AbstractMesh>;
  6961. private _collisionPoint;
  6962. private _planeIntersectionPoint;
  6963. private _tempVector;
  6964. private _tempVector2;
  6965. private _tempVector3;
  6966. private _tempVector4;
  6967. private _edge;
  6968. private _baseToVertex;
  6969. private _destinationPoint;
  6970. private _slidePlaneNormal;
  6971. private _displacementVector;
  6972. /** @hidden */
  6973. _radius: Vector3;
  6974. /** @hidden */
  6975. _retry: number;
  6976. private _velocity;
  6977. private _basePoint;
  6978. private _epsilon;
  6979. /** @hidden */
  6980. _velocityWorldLength: number;
  6981. /** @hidden */
  6982. _basePointWorld: Vector3;
  6983. private _velocityWorld;
  6984. private _normalizedVelocity;
  6985. /** @hidden */
  6986. _initialVelocity: Vector3;
  6987. /** @hidden */
  6988. _initialPosition: Vector3;
  6989. private _nearestDistance;
  6990. private _collisionMask;
  6991. get collisionMask(): number;
  6992. set collisionMask(mask: number);
  6993. /**
  6994. * Gets the plane normal used to compute the sliding response (in local space)
  6995. */
  6996. get slidePlaneNormal(): Vector3;
  6997. /** @hidden */
  6998. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6999. /** @hidden */
  7000. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7001. /** @hidden */
  7002. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7003. /** @hidden */
  7004. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7005. /** @hidden */
  7006. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7007. /** @hidden */
  7008. _getResponse(pos: Vector3, vel: Vector3): void;
  7009. }
  7010. }
  7011. declare module BABYLON {
  7012. /**
  7013. * Interface for cullable objects
  7014. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7015. */
  7016. export interface ICullable {
  7017. /**
  7018. * Checks if the object or part of the object is in the frustum
  7019. * @param frustumPlanes Camera near/planes
  7020. * @returns true if the object is in frustum otherwise false
  7021. */
  7022. isInFrustum(frustumPlanes: Plane[]): boolean;
  7023. /**
  7024. * Checks if a cullable object (mesh...) is in the camera frustum
  7025. * Unlike isInFrustum this cheks the full bounding box
  7026. * @param frustumPlanes Camera near/planes
  7027. * @returns true if the object is in frustum otherwise false
  7028. */
  7029. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7030. }
  7031. /**
  7032. * Info for a bounding data of a mesh
  7033. */
  7034. export class BoundingInfo implements ICullable {
  7035. /**
  7036. * Bounding box for the mesh
  7037. */
  7038. readonly boundingBox: BoundingBox;
  7039. /**
  7040. * Bounding sphere for the mesh
  7041. */
  7042. readonly boundingSphere: BoundingSphere;
  7043. private _isLocked;
  7044. private static readonly TmpVector3;
  7045. /**
  7046. * Constructs bounding info
  7047. * @param minimum min vector of the bounding box/sphere
  7048. * @param maximum max vector of the bounding box/sphere
  7049. * @param worldMatrix defines the new world matrix
  7050. */
  7051. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7052. /**
  7053. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7054. * @param min defines the new minimum vector (in local space)
  7055. * @param max defines the new maximum vector (in local space)
  7056. * @param worldMatrix defines the new world matrix
  7057. */
  7058. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7059. /**
  7060. * min vector of the bounding box/sphere
  7061. */
  7062. get minimum(): Vector3;
  7063. /**
  7064. * max vector of the bounding box/sphere
  7065. */
  7066. get maximum(): Vector3;
  7067. /**
  7068. * If the info is locked and won't be updated to avoid perf overhead
  7069. */
  7070. get isLocked(): boolean;
  7071. set isLocked(value: boolean);
  7072. /**
  7073. * Updates the bounding sphere and box
  7074. * @param world world matrix to be used to update
  7075. */
  7076. update(world: DeepImmutable<Matrix>): void;
  7077. /**
  7078. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7079. * @param center New center of the bounding info
  7080. * @param extend New extend of the bounding info
  7081. * @returns the current bounding info
  7082. */
  7083. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7084. /**
  7085. * Scale the current bounding info by applying a scale factor
  7086. * @param factor defines the scale factor to apply
  7087. * @returns the current bounding info
  7088. */
  7089. scale(factor: number): BoundingInfo;
  7090. /**
  7091. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7092. * @param frustumPlanes defines the frustum to test
  7093. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7094. * @returns true if the bounding info is in the frustum planes
  7095. */
  7096. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7097. /**
  7098. * Gets the world distance between the min and max points of the bounding box
  7099. */
  7100. get diagonalLength(): number;
  7101. /**
  7102. * Checks if a cullable object (mesh...) is in the camera frustum
  7103. * Unlike isInFrustum this cheks the full bounding box
  7104. * @param frustumPlanes Camera near/planes
  7105. * @returns true if the object is in frustum otherwise false
  7106. */
  7107. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7108. /** @hidden */
  7109. _checkCollision(collider: Collider): boolean;
  7110. /**
  7111. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7112. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7113. * @param point the point to check intersection with
  7114. * @returns if the point intersects
  7115. */
  7116. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7117. /**
  7118. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7119. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7120. * @param boundingInfo the bounding info to check intersection with
  7121. * @param precise if the intersection should be done using OBB
  7122. * @returns if the bounding info intersects
  7123. */
  7124. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7125. }
  7126. }
  7127. declare module BABYLON {
  7128. /**
  7129. * Extracts minimum and maximum values from a list of indexed positions
  7130. * @param positions defines the positions to use
  7131. * @param indices defines the indices to the positions
  7132. * @param indexStart defines the start index
  7133. * @param indexCount defines the end index
  7134. * @param bias defines bias value to add to the result
  7135. * @return minimum and maximum values
  7136. */
  7137. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7138. minimum: Vector3;
  7139. maximum: Vector3;
  7140. };
  7141. /**
  7142. * Extracts minimum and maximum values from a list of positions
  7143. * @param positions defines the positions to use
  7144. * @param start defines the start index in the positions array
  7145. * @param count defines the number of positions to handle
  7146. * @param bias defines bias value to add to the result
  7147. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7148. * @return minimum and maximum values
  7149. */
  7150. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7151. minimum: Vector3;
  7152. maximum: Vector3;
  7153. };
  7154. }
  7155. declare module BABYLON {
  7156. /** @hidden */
  7157. export class WebGLDataBuffer extends DataBuffer {
  7158. private _buffer;
  7159. constructor(resource: WebGLBuffer);
  7160. get underlyingResource(): any;
  7161. }
  7162. }
  7163. declare module BABYLON {
  7164. /** @hidden */
  7165. export class WebGLPipelineContext implements IPipelineContext {
  7166. engine: ThinEngine;
  7167. program: Nullable<WebGLProgram>;
  7168. context?: WebGLRenderingContext;
  7169. vertexShader?: WebGLShader;
  7170. fragmentShader?: WebGLShader;
  7171. isParallelCompiled: boolean;
  7172. onCompiled?: () => void;
  7173. transformFeedback?: WebGLTransformFeedback | null;
  7174. vertexCompilationError: Nullable<string>;
  7175. fragmentCompilationError: Nullable<string>;
  7176. programLinkError: Nullable<string>;
  7177. programValidationError: Nullable<string>;
  7178. get isAsync(): boolean;
  7179. get isReady(): boolean;
  7180. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7181. _getVertexShaderCode(): string | null;
  7182. _getFragmentShaderCode(): string | null;
  7183. }
  7184. }
  7185. declare module BABYLON {
  7186. interface ThinEngine {
  7187. /**
  7188. * Create an uniform buffer
  7189. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7190. * @param elements defines the content of the uniform buffer
  7191. * @returns the webGL uniform buffer
  7192. */
  7193. createUniformBuffer(elements: FloatArray): DataBuffer;
  7194. /**
  7195. * Create a dynamic uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param elements defines the content of the uniform buffer
  7198. * @returns the webGL uniform buffer
  7199. */
  7200. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7201. /**
  7202. * Update an existing uniform buffer
  7203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7204. * @param uniformBuffer defines the target uniform buffer
  7205. * @param elements defines the content to update
  7206. * @param offset defines the offset in the uniform buffer where update should start
  7207. * @param count defines the size of the data to update
  7208. */
  7209. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7210. /**
  7211. * Bind an uniform buffer to the current webGL context
  7212. * @param buffer defines the buffer to bind
  7213. */
  7214. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7215. /**
  7216. * Bind a buffer to the current webGL context at a given location
  7217. * @param buffer defines the buffer to bind
  7218. * @param location defines the index where to bind the buffer
  7219. */
  7220. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7221. /**
  7222. * Bind a specific block at a given index in a specific shader program
  7223. * @param pipelineContext defines the pipeline context to use
  7224. * @param blockName defines the block name
  7225. * @param index defines the index where to bind the block
  7226. */
  7227. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7228. }
  7229. }
  7230. declare module BABYLON {
  7231. /**
  7232. * Uniform buffer objects.
  7233. *
  7234. * Handles blocks of uniform on the GPU.
  7235. *
  7236. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7237. *
  7238. * For more information, please refer to :
  7239. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7240. */
  7241. export class UniformBuffer {
  7242. private _engine;
  7243. private _buffer;
  7244. private _data;
  7245. private _bufferData;
  7246. private _dynamic?;
  7247. private _uniformLocations;
  7248. private _uniformSizes;
  7249. private _uniformLocationPointer;
  7250. private _needSync;
  7251. private _noUBO;
  7252. private _currentEffect;
  7253. /** @hidden */
  7254. _alreadyBound: boolean;
  7255. private static _MAX_UNIFORM_SIZE;
  7256. private static _tempBuffer;
  7257. /**
  7258. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7259. * This is dynamic to allow compat with webgl 1 and 2.
  7260. * You will need to pass the name of the uniform as well as the value.
  7261. */
  7262. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7263. /**
  7264. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7265. * This is dynamic to allow compat with webgl 1 and 2.
  7266. * You will need to pass the name of the uniform as well as the value.
  7267. */
  7268. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7269. /**
  7270. * Lambda to Update a single float in a uniform buffer.
  7271. * This is dynamic to allow compat with webgl 1 and 2.
  7272. * You will need to pass the name of the uniform as well as the value.
  7273. */
  7274. updateFloat: (name: string, x: number) => void;
  7275. /**
  7276. * Lambda to Update a vec2 of float in a uniform buffer.
  7277. * This is dynamic to allow compat with webgl 1 and 2.
  7278. * You will need to pass the name of the uniform as well as the value.
  7279. */
  7280. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7281. /**
  7282. * Lambda to Update a vec3 of float in a uniform buffer.
  7283. * This is dynamic to allow compat with webgl 1 and 2.
  7284. * You will need to pass the name of the uniform as well as the value.
  7285. */
  7286. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7287. /**
  7288. * Lambda to Update a vec4 of float in a uniform buffer.
  7289. * This is dynamic to allow compat with webgl 1 and 2.
  7290. * You will need to pass the name of the uniform as well as the value.
  7291. */
  7292. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7293. /**
  7294. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7295. * This is dynamic to allow compat with webgl 1 and 2.
  7296. * You will need to pass the name of the uniform as well as the value.
  7297. */
  7298. updateMatrix: (name: string, mat: Matrix) => void;
  7299. /**
  7300. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7301. * This is dynamic to allow compat with webgl 1 and 2.
  7302. * You will need to pass the name of the uniform as well as the value.
  7303. */
  7304. updateVector3: (name: string, vector: Vector3) => void;
  7305. /**
  7306. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7307. * This is dynamic to allow compat with webgl 1 and 2.
  7308. * You will need to pass the name of the uniform as well as the value.
  7309. */
  7310. updateVector4: (name: string, vector: Vector4) => void;
  7311. /**
  7312. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7313. * This is dynamic to allow compat with webgl 1 and 2.
  7314. * You will need to pass the name of the uniform as well as the value.
  7315. */
  7316. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7317. /**
  7318. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7319. * This is dynamic to allow compat with webgl 1 and 2.
  7320. * You will need to pass the name of the uniform as well as the value.
  7321. */
  7322. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7323. /**
  7324. * Instantiates a new Uniform buffer objects.
  7325. *
  7326. * Handles blocks of uniform on the GPU.
  7327. *
  7328. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7329. *
  7330. * For more information, please refer to :
  7331. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7332. * @param engine Define the engine the buffer is associated with
  7333. * @param data Define the data contained in the buffer
  7334. * @param dynamic Define if the buffer is updatable
  7335. */
  7336. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7337. /**
  7338. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7339. * or just falling back on setUniformXXX calls.
  7340. */
  7341. get useUbo(): boolean;
  7342. /**
  7343. * Indicates if the WebGL underlying uniform buffer is in sync
  7344. * with the javascript cache data.
  7345. */
  7346. get isSync(): boolean;
  7347. /**
  7348. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7349. * Also, a dynamic UniformBuffer will disable cache verification and always
  7350. * update the underlying WebGL uniform buffer to the GPU.
  7351. * @returns if Dynamic, otherwise false
  7352. */
  7353. isDynamic(): boolean;
  7354. /**
  7355. * The data cache on JS side.
  7356. * @returns the underlying data as a float array
  7357. */
  7358. getData(): Float32Array;
  7359. /**
  7360. * The underlying WebGL Uniform buffer.
  7361. * @returns the webgl buffer
  7362. */
  7363. getBuffer(): Nullable<DataBuffer>;
  7364. /**
  7365. * std140 layout specifies how to align data within an UBO structure.
  7366. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7367. * for specs.
  7368. */
  7369. private _fillAlignment;
  7370. /**
  7371. * Adds an uniform in the buffer.
  7372. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7373. * for the layout to be correct !
  7374. * @param name Name of the uniform, as used in the uniform block in the shader.
  7375. * @param size Data size, or data directly.
  7376. */
  7377. addUniform(name: string, size: number | number[]): void;
  7378. /**
  7379. * Adds a Matrix 4x4 to the uniform buffer.
  7380. * @param name Name of the uniform, as used in the uniform block in the shader.
  7381. * @param mat A 4x4 matrix.
  7382. */
  7383. addMatrix(name: string, mat: Matrix): void;
  7384. /**
  7385. * Adds a vec2 to the uniform buffer.
  7386. * @param name Name of the uniform, as used in the uniform block in the shader.
  7387. * @param x Define the x component value of the vec2
  7388. * @param y Define the y component value of the vec2
  7389. */
  7390. addFloat2(name: string, x: number, y: number): void;
  7391. /**
  7392. * Adds a vec3 to the uniform buffer.
  7393. * @param name Name of the uniform, as used in the uniform block in the shader.
  7394. * @param x Define the x component value of the vec3
  7395. * @param y Define the y component value of the vec3
  7396. * @param z Define the z component value of the vec3
  7397. */
  7398. addFloat3(name: string, x: number, y: number, z: number): void;
  7399. /**
  7400. * Adds a vec3 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. * @param color Define the vec3 from a Color
  7403. */
  7404. addColor3(name: string, color: Color3): void;
  7405. /**
  7406. * Adds a vec4 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param color Define the rgb components from a Color
  7409. * @param alpha Define the a component of the vec4
  7410. */
  7411. addColor4(name: string, color: Color3, alpha: number): void;
  7412. /**
  7413. * Adds a vec3 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param vector Define the vec3 components from a Vector
  7416. */
  7417. addVector3(name: string, vector: Vector3): void;
  7418. /**
  7419. * Adds a Matrix 3x3 to the uniform buffer.
  7420. * @param name Name of the uniform, as used in the uniform block in the shader.
  7421. */
  7422. addMatrix3x3(name: string): void;
  7423. /**
  7424. * Adds a Matrix 2x2 to the uniform buffer.
  7425. * @param name Name of the uniform, as used in the uniform block in the shader.
  7426. */
  7427. addMatrix2x2(name: string): void;
  7428. /**
  7429. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7430. */
  7431. create(): void;
  7432. /** @hidden */
  7433. _rebuild(): void;
  7434. /**
  7435. * Updates the WebGL Uniform Buffer on the GPU.
  7436. * If the `dynamic` flag is set to true, no cache comparison is done.
  7437. * Otherwise, the buffer will be updated only if the cache differs.
  7438. */
  7439. update(): void;
  7440. /**
  7441. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7442. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7443. * @param data Define the flattened data
  7444. * @param size Define the size of the data.
  7445. */
  7446. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7447. private _valueCache;
  7448. private _cacheMatrix;
  7449. private _updateMatrix3x3ForUniform;
  7450. private _updateMatrix3x3ForEffect;
  7451. private _updateMatrix2x2ForEffect;
  7452. private _updateMatrix2x2ForUniform;
  7453. private _updateFloatForEffect;
  7454. private _updateFloatForUniform;
  7455. private _updateFloat2ForEffect;
  7456. private _updateFloat2ForUniform;
  7457. private _updateFloat3ForEffect;
  7458. private _updateFloat3ForUniform;
  7459. private _updateFloat4ForEffect;
  7460. private _updateFloat4ForUniform;
  7461. private _updateMatrixForEffect;
  7462. private _updateMatrixForUniform;
  7463. private _updateVector3ForEffect;
  7464. private _updateVector3ForUniform;
  7465. private _updateVector4ForEffect;
  7466. private _updateVector4ForUniform;
  7467. private _updateColor3ForEffect;
  7468. private _updateColor3ForUniform;
  7469. private _updateColor4ForEffect;
  7470. private _updateColor4ForUniform;
  7471. /**
  7472. * Sets a sampler uniform on the effect.
  7473. * @param name Define the name of the sampler.
  7474. * @param texture Define the texture to set in the sampler
  7475. */
  7476. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7477. /**
  7478. * Directly updates the value of the uniform in the cache AND on the GPU.
  7479. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7480. * @param data Define the flattened data
  7481. */
  7482. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7483. /**
  7484. * Binds this uniform buffer to an effect.
  7485. * @param effect Define the effect to bind the buffer to
  7486. * @param name Name of the uniform block in the shader.
  7487. */
  7488. bindToEffect(effect: Effect, name: string): void;
  7489. /**
  7490. * Disposes the uniform buffer.
  7491. */
  7492. dispose(): void;
  7493. }
  7494. }
  7495. declare module BABYLON {
  7496. /**
  7497. * Enum that determines the text-wrapping mode to use.
  7498. */
  7499. export enum InspectableType {
  7500. /**
  7501. * Checkbox for booleans
  7502. */
  7503. Checkbox = 0,
  7504. /**
  7505. * Sliders for numbers
  7506. */
  7507. Slider = 1,
  7508. /**
  7509. * Vector3
  7510. */
  7511. Vector3 = 2,
  7512. /**
  7513. * Quaternions
  7514. */
  7515. Quaternion = 3,
  7516. /**
  7517. * Color3
  7518. */
  7519. Color3 = 4,
  7520. /**
  7521. * String
  7522. */
  7523. String = 5
  7524. }
  7525. /**
  7526. * Interface used to define custom inspectable properties.
  7527. * This interface is used by the inspector to display custom property grids
  7528. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7529. */
  7530. export interface IInspectable {
  7531. /**
  7532. * Gets the label to display
  7533. */
  7534. label: string;
  7535. /**
  7536. * Gets the name of the property to edit
  7537. */
  7538. propertyName: string;
  7539. /**
  7540. * Gets the type of the editor to use
  7541. */
  7542. type: InspectableType;
  7543. /**
  7544. * Gets the minimum value of the property when using in "slider" mode
  7545. */
  7546. min?: number;
  7547. /**
  7548. * Gets the maximum value of the property when using in "slider" mode
  7549. */
  7550. max?: number;
  7551. /**
  7552. * Gets the setp to use when using in "slider" mode
  7553. */
  7554. step?: number;
  7555. }
  7556. }
  7557. declare module BABYLON {
  7558. /**
  7559. * Class used to provide helper for timing
  7560. */
  7561. export class TimingTools {
  7562. /**
  7563. * Polyfill for setImmediate
  7564. * @param action defines the action to execute after the current execution block
  7565. */
  7566. static SetImmediate(action: () => void): void;
  7567. }
  7568. }
  7569. declare module BABYLON {
  7570. /**
  7571. * Class used to enable instatition of objects by class name
  7572. */
  7573. export class InstantiationTools {
  7574. /**
  7575. * Use this object to register external classes like custom textures or material
  7576. * to allow the laoders to instantiate them
  7577. */
  7578. static RegisteredExternalClasses: {
  7579. [key: string]: Object;
  7580. };
  7581. /**
  7582. * Tries to instantiate a new object from a given class name
  7583. * @param className defines the class name to instantiate
  7584. * @returns the new object or null if the system was not able to do the instantiation
  7585. */
  7586. static Instantiate(className: string): any;
  7587. }
  7588. }
  7589. declare module BABYLON {
  7590. /**
  7591. * Define options used to create a depth texture
  7592. */
  7593. export class DepthTextureCreationOptions {
  7594. /** Specifies whether or not a stencil should be allocated in the texture */
  7595. generateStencil?: boolean;
  7596. /** Specifies whether or not bilinear filtering is enable on the texture */
  7597. bilinearFiltering?: boolean;
  7598. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7599. comparisonFunction?: number;
  7600. /** Specifies if the created texture is a cube texture */
  7601. isCube?: boolean;
  7602. }
  7603. }
  7604. declare module BABYLON {
  7605. interface ThinEngine {
  7606. /**
  7607. * Creates a depth stencil cube texture.
  7608. * This is only available in WebGL 2.
  7609. * @param size The size of face edge in the cube texture.
  7610. * @param options The options defining the cube texture.
  7611. * @returns The cube texture
  7612. */
  7613. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7614. /**
  7615. * Creates a cube texture
  7616. * @param rootUrl defines the url where the files to load is located
  7617. * @param scene defines the current scene
  7618. * @param files defines the list of files to load (1 per face)
  7619. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7620. * @param onLoad defines an optional callback raised when the texture is loaded
  7621. * @param onError defines an optional callback raised if there is an issue to load the texture
  7622. * @param format defines the format of the data
  7623. * @param forcedExtension defines the extension to use to pick the right loader
  7624. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7625. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7626. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7627. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7628. * @returns the cube texture as an InternalTexture
  7629. */
  7630. 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;
  7631. /**
  7632. * Creates a cube texture
  7633. * @param rootUrl defines the url where the files to load is located
  7634. * @param scene defines the current scene
  7635. * @param files defines the list of files to load (1 per face)
  7636. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7637. * @param onLoad defines an optional callback raised when the texture is loaded
  7638. * @param onError defines an optional callback raised if there is an issue to load the texture
  7639. * @param format defines the format of the data
  7640. * @param forcedExtension defines the extension to use to pick the right loader
  7641. * @returns the cube texture as an InternalTexture
  7642. */
  7643. 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;
  7644. /**
  7645. * Creates a cube texture
  7646. * @param rootUrl defines the url where the files to load is located
  7647. * @param scene defines the current scene
  7648. * @param files defines the list of files to load (1 per face)
  7649. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7650. * @param onLoad defines an optional callback raised when the texture is loaded
  7651. * @param onError defines an optional callback raised if there is an issue to load the texture
  7652. * @param format defines the format of the data
  7653. * @param forcedExtension defines the extension to use to pick the right loader
  7654. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7655. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7656. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7657. * @returns the cube texture as an InternalTexture
  7658. */
  7659. 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;
  7660. /** @hidden */
  7661. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7662. /** @hidden */
  7663. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7664. /** @hidden */
  7665. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7666. /** @hidden */
  7667. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7668. /**
  7669. * @hidden
  7670. */
  7671. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7672. }
  7673. }
  7674. declare module BABYLON {
  7675. /**
  7676. * Class for creating a cube texture
  7677. */
  7678. export class CubeTexture extends BaseTexture {
  7679. private _delayedOnLoad;
  7680. /**
  7681. * Observable triggered once the texture has been loaded.
  7682. */
  7683. onLoadObservable: Observable<CubeTexture>;
  7684. /**
  7685. * The url of the texture
  7686. */
  7687. url: string;
  7688. /**
  7689. * Gets or sets the center of the bounding box associated with the cube texture.
  7690. * It must define where the camera used to render the texture was set
  7691. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7692. */
  7693. boundingBoxPosition: Vector3;
  7694. private _boundingBoxSize;
  7695. /**
  7696. * Gets or sets the size of the bounding box associated with the cube texture
  7697. * When defined, the cubemap will switch to local mode
  7698. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7699. * @example https://www.babylonjs-playground.com/#RNASML
  7700. */
  7701. set boundingBoxSize(value: Vector3);
  7702. /**
  7703. * Returns the bounding box size
  7704. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7705. */
  7706. get boundingBoxSize(): Vector3;
  7707. protected _rotationY: number;
  7708. /**
  7709. * Sets texture matrix rotation angle around Y axis in radians.
  7710. */
  7711. set rotationY(value: number);
  7712. /**
  7713. * Gets texture matrix rotation angle around Y axis radians.
  7714. */
  7715. get rotationY(): number;
  7716. /**
  7717. * Are mip maps generated for this texture or not.
  7718. */
  7719. get noMipmap(): boolean;
  7720. private _noMipmap;
  7721. private _files;
  7722. protected _forcedExtension: Nullable<string>;
  7723. private _extensions;
  7724. private _textureMatrix;
  7725. private _format;
  7726. private _createPolynomials;
  7727. /** @hidden */
  7728. _prefiltered: boolean;
  7729. /**
  7730. * Creates a cube texture from an array of image urls
  7731. * @param files defines an array of image urls
  7732. * @param scene defines the hosting scene
  7733. * @param noMipmap specifies if mip maps are not used
  7734. * @returns a cube texture
  7735. */
  7736. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7737. /**
  7738. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7739. * @param url defines the url of the prefiltered texture
  7740. * @param scene defines the scene the texture is attached to
  7741. * @param forcedExtension defines the extension of the file if different from the url
  7742. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7743. * @return the prefiltered texture
  7744. */
  7745. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7746. /**
  7747. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7748. * as prefiltered data.
  7749. * @param rootUrl defines the url of the texture or the root name of the six images
  7750. * @param scene defines the scene the texture is attached to
  7751. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7752. * @param noMipmap defines if mipmaps should be created or not
  7753. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7754. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7755. * @param onError defines a callback triggered in case of error during load
  7756. * @param format defines the internal format to use for the texture once loaded
  7757. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7758. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7759. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7760. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7761. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7762. * @return the cube texture
  7763. */
  7764. 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);
  7765. /**
  7766. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7767. */
  7768. get isPrefiltered(): boolean;
  7769. /**
  7770. * Get the current class name of the texture useful for serialization or dynamic coding.
  7771. * @returns "CubeTexture"
  7772. */
  7773. getClassName(): string;
  7774. /**
  7775. * Update the url (and optional buffer) of this texture if url was null during construction.
  7776. * @param url the url of the texture
  7777. * @param forcedExtension defines the extension to use
  7778. * @param onLoad callback called when the texture is loaded (defaults to null)
  7779. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7780. */
  7781. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7782. /**
  7783. * Delays loading of the cube texture
  7784. * @param forcedExtension defines the extension to use
  7785. */
  7786. delayLoad(forcedExtension?: string): void;
  7787. /**
  7788. * Returns the reflection texture matrix
  7789. * @returns the reflection texture matrix
  7790. */
  7791. getReflectionTextureMatrix(): Matrix;
  7792. /**
  7793. * Sets the reflection texture matrix
  7794. * @param value Reflection texture matrix
  7795. */
  7796. setReflectionTextureMatrix(value: Matrix): void;
  7797. /**
  7798. * Parses text to create a cube texture
  7799. * @param parsedTexture define the serialized text to read from
  7800. * @param scene defines the hosting scene
  7801. * @param rootUrl defines the root url of the cube texture
  7802. * @returns a cube texture
  7803. */
  7804. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7805. /**
  7806. * Makes a clone, or deep copy, of the cube texture
  7807. * @returns a new cube texture
  7808. */
  7809. clone(): CubeTexture;
  7810. }
  7811. }
  7812. declare module BABYLON {
  7813. /**
  7814. * Manages the defines for the Material
  7815. */
  7816. export class MaterialDefines {
  7817. /** @hidden */
  7818. protected _keys: string[];
  7819. private _isDirty;
  7820. /** @hidden */
  7821. _renderId: number;
  7822. /** @hidden */
  7823. _areLightsDirty: boolean;
  7824. /** @hidden */
  7825. _areLightsDisposed: boolean;
  7826. /** @hidden */
  7827. _areAttributesDirty: boolean;
  7828. /** @hidden */
  7829. _areTexturesDirty: boolean;
  7830. /** @hidden */
  7831. _areFresnelDirty: boolean;
  7832. /** @hidden */
  7833. _areMiscDirty: boolean;
  7834. /** @hidden */
  7835. _areImageProcessingDirty: boolean;
  7836. /** @hidden */
  7837. _normals: boolean;
  7838. /** @hidden */
  7839. _uvs: boolean;
  7840. /** @hidden */
  7841. _needNormals: boolean;
  7842. /** @hidden */
  7843. _needUVs: boolean;
  7844. [id: string]: any;
  7845. /**
  7846. * Specifies if the material needs to be re-calculated
  7847. */
  7848. get isDirty(): boolean;
  7849. /**
  7850. * Marks the material to indicate that it has been re-calculated
  7851. */
  7852. markAsProcessed(): void;
  7853. /**
  7854. * Marks the material to indicate that it needs to be re-calculated
  7855. */
  7856. markAsUnprocessed(): void;
  7857. /**
  7858. * Marks the material to indicate all of its defines need to be re-calculated
  7859. */
  7860. markAllAsDirty(): void;
  7861. /**
  7862. * Marks the material to indicate that image processing needs to be re-calculated
  7863. */
  7864. markAsImageProcessingDirty(): void;
  7865. /**
  7866. * Marks the material to indicate the lights need to be re-calculated
  7867. * @param disposed Defines whether the light is dirty due to dispose or not
  7868. */
  7869. markAsLightDirty(disposed?: boolean): void;
  7870. /**
  7871. * Marks the attribute state as changed
  7872. */
  7873. markAsAttributesDirty(): void;
  7874. /**
  7875. * Marks the texture state as changed
  7876. */
  7877. markAsTexturesDirty(): void;
  7878. /**
  7879. * Marks the fresnel state as changed
  7880. */
  7881. markAsFresnelDirty(): void;
  7882. /**
  7883. * Marks the misc state as changed
  7884. */
  7885. markAsMiscDirty(): void;
  7886. /**
  7887. * Rebuilds the material defines
  7888. */
  7889. rebuild(): void;
  7890. /**
  7891. * Specifies if two material defines are equal
  7892. * @param other - A material define instance to compare to
  7893. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7894. */
  7895. isEqual(other: MaterialDefines): boolean;
  7896. /**
  7897. * Clones this instance's defines to another instance
  7898. * @param other - material defines to clone values to
  7899. */
  7900. cloneTo(other: MaterialDefines): void;
  7901. /**
  7902. * Resets the material define values
  7903. */
  7904. reset(): void;
  7905. /**
  7906. * Converts the material define values to a string
  7907. * @returns - String of material define information
  7908. */
  7909. toString(): string;
  7910. }
  7911. }
  7912. declare module BABYLON {
  7913. /**
  7914. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7915. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7916. * 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;
  7917. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7918. */
  7919. export class ColorCurves {
  7920. private _dirty;
  7921. private _tempColor;
  7922. private _globalCurve;
  7923. private _highlightsCurve;
  7924. private _midtonesCurve;
  7925. private _shadowsCurve;
  7926. private _positiveCurve;
  7927. private _negativeCurve;
  7928. private _globalHue;
  7929. private _globalDensity;
  7930. private _globalSaturation;
  7931. private _globalExposure;
  7932. /**
  7933. * Gets the global Hue value.
  7934. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7935. */
  7936. get globalHue(): number;
  7937. /**
  7938. * Sets 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. set globalHue(value: number);
  7942. /**
  7943. * Gets the global Density value.
  7944. * 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.
  7945. * Values less than zero provide a filter of opposite hue.
  7946. */
  7947. get globalDensity(): number;
  7948. /**
  7949. * Sets the global Density value.
  7950. * 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.
  7951. * Values less than zero provide a filter of opposite hue.
  7952. */
  7953. set globalDensity(value: number);
  7954. /**
  7955. * Gets the global Saturation value.
  7956. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7957. */
  7958. get globalSaturation(): number;
  7959. /**
  7960. * Sets 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. set globalSaturation(value: number);
  7964. /**
  7965. * Gets the global Exposure value.
  7966. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7967. */
  7968. get globalExposure(): number;
  7969. /**
  7970. * Sets 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. set globalExposure(value: number);
  7974. private _highlightsHue;
  7975. private _highlightsDensity;
  7976. private _highlightsSaturation;
  7977. private _highlightsExposure;
  7978. /**
  7979. * Gets the highlights Hue value.
  7980. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7981. */
  7982. get highlightsHue(): number;
  7983. /**
  7984. * Sets 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. set highlightsHue(value: number);
  7988. /**
  7989. * Gets the highlights Density value.
  7990. * 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.
  7991. * Values less than zero provide a filter of opposite hue.
  7992. */
  7993. get highlightsDensity(): number;
  7994. /**
  7995. * Sets the highlights Density value.
  7996. * 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.
  7997. * Values less than zero provide a filter of opposite hue.
  7998. */
  7999. set highlightsDensity(value: number);
  8000. /**
  8001. * Gets the highlights Saturation value.
  8002. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8003. */
  8004. get highlightsSaturation(): number;
  8005. /**
  8006. * Sets 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. set highlightsSaturation(value: number);
  8010. /**
  8011. * Gets the highlights Exposure value.
  8012. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8013. */
  8014. get highlightsExposure(): number;
  8015. /**
  8016. * Sets 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. set highlightsExposure(value: number);
  8020. private _midtonesHue;
  8021. private _midtonesDensity;
  8022. private _midtonesSaturation;
  8023. private _midtonesExposure;
  8024. /**
  8025. * Gets the midtones Hue value.
  8026. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8027. */
  8028. get midtonesHue(): number;
  8029. /**
  8030. * Sets 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. set midtonesHue(value: number);
  8034. /**
  8035. * Gets the midtones Density value.
  8036. * 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.
  8037. * Values less than zero provide a filter of opposite hue.
  8038. */
  8039. get midtonesDensity(): number;
  8040. /**
  8041. * Sets the midtones Density value.
  8042. * 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.
  8043. * Values less than zero provide a filter of opposite hue.
  8044. */
  8045. set midtonesDensity(value: number);
  8046. /**
  8047. * Gets the midtones Saturation value.
  8048. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8049. */
  8050. get midtonesSaturation(): number;
  8051. /**
  8052. * Sets 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. set midtonesSaturation(value: number);
  8056. /**
  8057. * Gets the midtones Exposure value.
  8058. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8059. */
  8060. get midtonesExposure(): number;
  8061. /**
  8062. * Sets 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. set midtonesExposure(value: number);
  8066. private _shadowsHue;
  8067. private _shadowsDensity;
  8068. private _shadowsSaturation;
  8069. private _shadowsExposure;
  8070. /**
  8071. * Gets the shadows Hue value.
  8072. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8073. */
  8074. get shadowsHue(): number;
  8075. /**
  8076. * Sets 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. set shadowsHue(value: number);
  8080. /**
  8081. * Gets the shadows Density value.
  8082. * 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.
  8083. * Values less than zero provide a filter of opposite hue.
  8084. */
  8085. get shadowsDensity(): number;
  8086. /**
  8087. * Sets the shadows Density value.
  8088. * 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.
  8089. * Values less than zero provide a filter of opposite hue.
  8090. */
  8091. set shadowsDensity(value: number);
  8092. /**
  8093. * Gets the shadows Saturation value.
  8094. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8095. */
  8096. get shadowsSaturation(): number;
  8097. /**
  8098. * Sets 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. set shadowsSaturation(value: number);
  8102. /**
  8103. * Gets the shadows Exposure value.
  8104. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8105. */
  8106. get shadowsExposure(): number;
  8107. /**
  8108. * Sets 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. set shadowsExposure(value: number);
  8112. /**
  8113. * Returns the class name
  8114. * @returns The class name
  8115. */
  8116. getClassName(): string;
  8117. /**
  8118. * Binds the color curves to the shader.
  8119. * @param colorCurves The color curve to bind
  8120. * @param effect The effect to bind to
  8121. * @param positiveUniform The positive uniform shader parameter
  8122. * @param neutralUniform The neutral uniform shader parameter
  8123. * @param negativeUniform The negative uniform shader parameter
  8124. */
  8125. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8126. /**
  8127. * Prepare the list of uniforms associated with the ColorCurves effects.
  8128. * @param uniformsList The list of uniforms used in the effect
  8129. */
  8130. static PrepareUniforms(uniformsList: string[]): void;
  8131. /**
  8132. * Returns color grading data based on a hue, density, saturation and exposure value.
  8133. * @param filterHue The hue of the color filter.
  8134. * @param filterDensity The density of the color filter.
  8135. * @param saturation The saturation.
  8136. * @param exposure The exposure.
  8137. * @param result The result data container.
  8138. */
  8139. private getColorGradingDataToRef;
  8140. /**
  8141. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8142. * @param value The input slider value in range [-100,100].
  8143. * @returns Adjusted value.
  8144. */
  8145. private static applyColorGradingSliderNonlinear;
  8146. /**
  8147. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8148. * @param hue The hue (H) input.
  8149. * @param saturation The saturation (S) input.
  8150. * @param brightness The brightness (B) input.
  8151. * @result An RGBA color represented as Vector4.
  8152. */
  8153. private static fromHSBToRef;
  8154. /**
  8155. * Returns a value clamped between min and max
  8156. * @param value The value to clamp
  8157. * @param min The minimum of value
  8158. * @param max The maximum of value
  8159. * @returns The clamped value.
  8160. */
  8161. private static clamp;
  8162. /**
  8163. * Clones the current color curve instance.
  8164. * @return The cloned curves
  8165. */
  8166. clone(): ColorCurves;
  8167. /**
  8168. * Serializes the current color curve instance to a json representation.
  8169. * @return a JSON representation
  8170. */
  8171. serialize(): any;
  8172. /**
  8173. * Parses the color curve from a json representation.
  8174. * @param source the JSON source to parse
  8175. * @return The parsed curves
  8176. */
  8177. static Parse(source: any): ColorCurves;
  8178. }
  8179. }
  8180. declare module BABYLON {
  8181. /**
  8182. * Interface to follow in your material defines to integrate easily the
  8183. * Image proccessing functions.
  8184. * @hidden
  8185. */
  8186. export interface IImageProcessingConfigurationDefines {
  8187. IMAGEPROCESSING: boolean;
  8188. VIGNETTE: boolean;
  8189. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8190. VIGNETTEBLENDMODEOPAQUE: boolean;
  8191. TONEMAPPING: boolean;
  8192. TONEMAPPING_ACES: boolean;
  8193. CONTRAST: boolean;
  8194. EXPOSURE: boolean;
  8195. COLORCURVES: boolean;
  8196. COLORGRADING: boolean;
  8197. COLORGRADING3D: boolean;
  8198. SAMPLER3DGREENDEPTH: boolean;
  8199. SAMPLER3DBGRMAP: boolean;
  8200. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8201. }
  8202. /**
  8203. * @hidden
  8204. */
  8205. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8206. IMAGEPROCESSING: boolean;
  8207. VIGNETTE: boolean;
  8208. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8209. VIGNETTEBLENDMODEOPAQUE: boolean;
  8210. TONEMAPPING: boolean;
  8211. TONEMAPPING_ACES: boolean;
  8212. CONTRAST: boolean;
  8213. COLORCURVES: boolean;
  8214. COLORGRADING: boolean;
  8215. COLORGRADING3D: boolean;
  8216. SAMPLER3DGREENDEPTH: boolean;
  8217. SAMPLER3DBGRMAP: boolean;
  8218. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8219. EXPOSURE: boolean;
  8220. constructor();
  8221. }
  8222. /**
  8223. * This groups together the common properties used for image processing either in direct forward pass
  8224. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8225. * or not.
  8226. */
  8227. export class ImageProcessingConfiguration {
  8228. /**
  8229. * Default tone mapping applied in BabylonJS.
  8230. */
  8231. static readonly TONEMAPPING_STANDARD: number;
  8232. /**
  8233. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8234. * to other engines rendering to increase portability.
  8235. */
  8236. static readonly TONEMAPPING_ACES: number;
  8237. /**
  8238. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8239. */
  8240. colorCurves: Nullable<ColorCurves>;
  8241. private _colorCurvesEnabled;
  8242. /**
  8243. * Gets wether the color curves effect is enabled.
  8244. */
  8245. get colorCurvesEnabled(): boolean;
  8246. /**
  8247. * Sets wether the color curves effect is enabled.
  8248. */
  8249. set colorCurvesEnabled(value: boolean);
  8250. private _colorGradingTexture;
  8251. /**
  8252. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8253. */
  8254. get colorGradingTexture(): Nullable<BaseTexture>;
  8255. /**
  8256. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8257. */
  8258. set colorGradingTexture(value: Nullable<BaseTexture>);
  8259. private _colorGradingEnabled;
  8260. /**
  8261. * Gets wether the color grading effect is enabled.
  8262. */
  8263. get colorGradingEnabled(): boolean;
  8264. /**
  8265. * Sets wether the color grading effect is enabled.
  8266. */
  8267. set colorGradingEnabled(value: boolean);
  8268. private _colorGradingWithGreenDepth;
  8269. /**
  8270. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8271. */
  8272. get colorGradingWithGreenDepth(): boolean;
  8273. /**
  8274. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8275. */
  8276. set colorGradingWithGreenDepth(value: boolean);
  8277. private _colorGradingBGR;
  8278. /**
  8279. * Gets wether the color grading texture contains BGR values.
  8280. */
  8281. get colorGradingBGR(): boolean;
  8282. /**
  8283. * Sets wether the color grading texture contains BGR values.
  8284. */
  8285. set colorGradingBGR(value: boolean);
  8286. /** @hidden */
  8287. _exposure: number;
  8288. /**
  8289. * Gets the Exposure used in the effect.
  8290. */
  8291. get exposure(): number;
  8292. /**
  8293. * Sets the Exposure used in the effect.
  8294. */
  8295. set exposure(value: number);
  8296. private _toneMappingEnabled;
  8297. /**
  8298. * Gets wether the tone mapping effect is enabled.
  8299. */
  8300. get toneMappingEnabled(): boolean;
  8301. /**
  8302. * Sets wether the tone mapping effect is enabled.
  8303. */
  8304. set toneMappingEnabled(value: boolean);
  8305. private _toneMappingType;
  8306. /**
  8307. * Gets the type of tone mapping effect.
  8308. */
  8309. get toneMappingType(): number;
  8310. /**
  8311. * Sets the type of tone mapping effect used in BabylonJS.
  8312. */
  8313. set toneMappingType(value: number);
  8314. protected _contrast: number;
  8315. /**
  8316. * Gets the contrast used in the effect.
  8317. */
  8318. get contrast(): number;
  8319. /**
  8320. * Sets the contrast used in the effect.
  8321. */
  8322. set contrast(value: number);
  8323. /**
  8324. * Vignette stretch size.
  8325. */
  8326. vignetteStretch: number;
  8327. /**
  8328. * Vignette centre X Offset.
  8329. */
  8330. vignetteCentreX: number;
  8331. /**
  8332. * Vignette centre Y Offset.
  8333. */
  8334. vignetteCentreY: number;
  8335. /**
  8336. * Vignette weight or intensity of the vignette effect.
  8337. */
  8338. vignetteWeight: number;
  8339. /**
  8340. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8341. * if vignetteEnabled is set to true.
  8342. */
  8343. vignetteColor: Color4;
  8344. /**
  8345. * Camera field of view used by the Vignette effect.
  8346. */
  8347. vignetteCameraFov: number;
  8348. private _vignetteBlendMode;
  8349. /**
  8350. * Gets the vignette blend mode allowing different kind of effect.
  8351. */
  8352. get vignetteBlendMode(): number;
  8353. /**
  8354. * Sets the vignette blend mode allowing different kind of effect.
  8355. */
  8356. set vignetteBlendMode(value: number);
  8357. private _vignetteEnabled;
  8358. /**
  8359. * Gets wether the vignette effect is enabled.
  8360. */
  8361. get vignetteEnabled(): boolean;
  8362. /**
  8363. * Sets wether the vignette effect is enabled.
  8364. */
  8365. set vignetteEnabled(value: boolean);
  8366. private _applyByPostProcess;
  8367. /**
  8368. * Gets wether the image processing is applied through a post process or not.
  8369. */
  8370. get applyByPostProcess(): boolean;
  8371. /**
  8372. * Sets wether the image processing is applied through a post process or not.
  8373. */
  8374. set applyByPostProcess(value: boolean);
  8375. private _isEnabled;
  8376. /**
  8377. * Gets wether the image processing is enabled or not.
  8378. */
  8379. get isEnabled(): boolean;
  8380. /**
  8381. * Sets wether the image processing is enabled or not.
  8382. */
  8383. set isEnabled(value: boolean);
  8384. /**
  8385. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8386. */
  8387. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8388. /**
  8389. * Method called each time the image processing information changes requires to recompile the effect.
  8390. */
  8391. protected _updateParameters(): void;
  8392. /**
  8393. * Gets the current class name.
  8394. * @return "ImageProcessingConfiguration"
  8395. */
  8396. getClassName(): string;
  8397. /**
  8398. * Prepare the list of uniforms associated with the Image Processing effects.
  8399. * @param uniforms The list of uniforms used in the effect
  8400. * @param defines the list of defines currently in use
  8401. */
  8402. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8403. /**
  8404. * Prepare the list of samplers associated with the Image Processing effects.
  8405. * @param samplersList The list of uniforms used in the effect
  8406. * @param defines the list of defines currently in use
  8407. */
  8408. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8409. /**
  8410. * Prepare the list of defines associated to the shader.
  8411. * @param defines the list of defines to complete
  8412. * @param forPostProcess Define if we are currently in post process mode or not
  8413. */
  8414. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8415. /**
  8416. * Returns true if all the image processing information are ready.
  8417. * @returns True if ready, otherwise, false
  8418. */
  8419. isReady(): boolean;
  8420. /**
  8421. * Binds the image processing to the shader.
  8422. * @param effect The effect to bind to
  8423. * @param overrideAspectRatio Override the aspect ratio of the effect
  8424. */
  8425. bind(effect: Effect, overrideAspectRatio?: number): void;
  8426. /**
  8427. * Clones the current image processing instance.
  8428. * @return The cloned image processing
  8429. */
  8430. clone(): ImageProcessingConfiguration;
  8431. /**
  8432. * Serializes the current image processing instance to a json representation.
  8433. * @return a JSON representation
  8434. */
  8435. serialize(): any;
  8436. /**
  8437. * Parses the image processing from a json representation.
  8438. * @param source the JSON source to parse
  8439. * @return The parsed image processing
  8440. */
  8441. static Parse(source: any): ImageProcessingConfiguration;
  8442. private static _VIGNETTEMODE_MULTIPLY;
  8443. private static _VIGNETTEMODE_OPAQUE;
  8444. /**
  8445. * Used to apply the vignette as a mix with the pixel color.
  8446. */
  8447. static get VIGNETTEMODE_MULTIPLY(): number;
  8448. /**
  8449. * Used to apply the vignette as a replacement of the pixel color.
  8450. */
  8451. static get VIGNETTEMODE_OPAQUE(): number;
  8452. }
  8453. }
  8454. declare module BABYLON {
  8455. /** @hidden */
  8456. export var postprocessVertexShader: {
  8457. name: string;
  8458. shader: string;
  8459. };
  8460. }
  8461. declare module BABYLON {
  8462. interface ThinEngine {
  8463. /**
  8464. * Creates a new render target texture
  8465. * @param size defines the size of the texture
  8466. * @param options defines the options used to create the texture
  8467. * @returns a new render target texture stored in an InternalTexture
  8468. */
  8469. createRenderTargetTexture(size: number | {
  8470. width: number;
  8471. height: number;
  8472. layers?: number;
  8473. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8474. /**
  8475. * Creates a depth stencil texture.
  8476. * This is only available in WebGL 2 or with the depth texture extension available.
  8477. * @param size The size of face edge in the texture.
  8478. * @param options The options defining the texture.
  8479. * @returns The texture
  8480. */
  8481. createDepthStencilTexture(size: number | {
  8482. width: number;
  8483. height: number;
  8484. layers?: number;
  8485. }, options: DepthTextureCreationOptions): InternalTexture;
  8486. /** @hidden */
  8487. _createDepthStencilTexture(size: number | {
  8488. width: number;
  8489. height: number;
  8490. layers?: number;
  8491. }, options: DepthTextureCreationOptions): InternalTexture;
  8492. }
  8493. }
  8494. declare module BABYLON {
  8495. /** Defines supported spaces */
  8496. export enum Space {
  8497. /** Local (object) space */
  8498. LOCAL = 0,
  8499. /** World space */
  8500. WORLD = 1,
  8501. /** Bone space */
  8502. BONE = 2
  8503. }
  8504. /** Defines the 3 main axes */
  8505. export class Axis {
  8506. /** X axis */
  8507. static X: Vector3;
  8508. /** Y axis */
  8509. static Y: Vector3;
  8510. /** Z axis */
  8511. static Z: Vector3;
  8512. }
  8513. }
  8514. declare module BABYLON {
  8515. /**
  8516. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8517. * This is the base of the follow, arc rotate cameras and Free camera
  8518. * @see http://doc.babylonjs.com/features/cameras
  8519. */
  8520. export class TargetCamera extends Camera {
  8521. private static _RigCamTransformMatrix;
  8522. private static _TargetTransformMatrix;
  8523. private static _TargetFocalPoint;
  8524. /**
  8525. * Define the current direction the camera is moving to
  8526. */
  8527. cameraDirection: Vector3;
  8528. /**
  8529. * Define the current rotation the camera is rotating to
  8530. */
  8531. cameraRotation: Vector2;
  8532. /**
  8533. * When set, the up vector of the camera will be updated by the rotation of the camera
  8534. */
  8535. updateUpVectorFromRotation: boolean;
  8536. private _tmpQuaternion;
  8537. /**
  8538. * Define the current rotation of the camera
  8539. */
  8540. rotation: Vector3;
  8541. /**
  8542. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8543. */
  8544. rotationQuaternion: Quaternion;
  8545. /**
  8546. * Define the current speed of the camera
  8547. */
  8548. speed: number;
  8549. /**
  8550. * Add constraint to the camera to prevent it to move freely in all directions and
  8551. * around all axis.
  8552. */
  8553. noRotationConstraint: boolean;
  8554. /**
  8555. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8556. * panning
  8557. */
  8558. invertRotation: boolean;
  8559. /**
  8560. * Speed multiplier for inverse camera panning
  8561. */
  8562. inverseRotationSpeed: number;
  8563. /**
  8564. * Define the current target of the camera as an object or a position.
  8565. */
  8566. lockedTarget: any;
  8567. /** @hidden */
  8568. _currentTarget: Vector3;
  8569. /** @hidden */
  8570. _initialFocalDistance: number;
  8571. /** @hidden */
  8572. _viewMatrix: Matrix;
  8573. /** @hidden */
  8574. _camMatrix: Matrix;
  8575. /** @hidden */
  8576. _cameraTransformMatrix: Matrix;
  8577. /** @hidden */
  8578. _cameraRotationMatrix: Matrix;
  8579. /** @hidden */
  8580. _referencePoint: Vector3;
  8581. /** @hidden */
  8582. _transformedReferencePoint: Vector3;
  8583. protected _globalCurrentTarget: Vector3;
  8584. protected _globalCurrentUpVector: Vector3;
  8585. /** @hidden */
  8586. _reset: () => void;
  8587. private _defaultUp;
  8588. /**
  8589. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8590. * This is the base of the follow, arc rotate cameras and Free camera
  8591. * @see http://doc.babylonjs.com/features/cameras
  8592. * @param name Defines the name of the camera in the scene
  8593. * @param position Defines the start position of the camera in the scene
  8594. * @param scene Defines the scene the camera belongs to
  8595. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8596. */
  8597. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8598. /**
  8599. * Gets the position in front of the camera at a given distance.
  8600. * @param distance The distance from the camera we want the position to be
  8601. * @returns the position
  8602. */
  8603. getFrontPosition(distance: number): Vector3;
  8604. /** @hidden */
  8605. _getLockedTargetPosition(): Nullable<Vector3>;
  8606. private _storedPosition;
  8607. private _storedRotation;
  8608. private _storedRotationQuaternion;
  8609. /**
  8610. * Store current camera state of the camera (fov, position, rotation, etc..)
  8611. * @returns the camera
  8612. */
  8613. storeState(): Camera;
  8614. /**
  8615. * Restored camera state. You must call storeState() first
  8616. * @returns whether it was successful or not
  8617. * @hidden
  8618. */
  8619. _restoreStateValues(): boolean;
  8620. /** @hidden */
  8621. _initCache(): void;
  8622. /** @hidden */
  8623. _updateCache(ignoreParentClass?: boolean): void;
  8624. /** @hidden */
  8625. _isSynchronizedViewMatrix(): boolean;
  8626. /** @hidden */
  8627. _computeLocalCameraSpeed(): number;
  8628. /**
  8629. * Defines the target the camera should look at.
  8630. * @param target Defines the new target as a Vector or a mesh
  8631. */
  8632. setTarget(target: Vector3): void;
  8633. /**
  8634. * Return the current target position of the camera. This value is expressed in local space.
  8635. * @returns the target position
  8636. */
  8637. getTarget(): Vector3;
  8638. /** @hidden */
  8639. _decideIfNeedsToMove(): boolean;
  8640. /** @hidden */
  8641. _updatePosition(): void;
  8642. /** @hidden */
  8643. _checkInputs(): void;
  8644. protected _updateCameraRotationMatrix(): void;
  8645. /**
  8646. * 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)
  8647. * @returns the current camera
  8648. */
  8649. private _rotateUpVectorWithCameraRotationMatrix;
  8650. private _cachedRotationZ;
  8651. private _cachedQuaternionRotationZ;
  8652. /** @hidden */
  8653. _getViewMatrix(): Matrix;
  8654. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8655. /**
  8656. * @hidden
  8657. */
  8658. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8659. /**
  8660. * @hidden
  8661. */
  8662. _updateRigCameras(): void;
  8663. private _getRigCamPositionAndTarget;
  8664. /**
  8665. * Gets the current object class name.
  8666. * @return the class name
  8667. */
  8668. getClassName(): string;
  8669. }
  8670. }
  8671. declare module BABYLON {
  8672. /**
  8673. * Gather the list of keyboard event types as constants.
  8674. */
  8675. export class KeyboardEventTypes {
  8676. /**
  8677. * The keydown event is fired when a key becomes active (pressed).
  8678. */
  8679. static readonly KEYDOWN: number;
  8680. /**
  8681. * The keyup event is fired when a key has been released.
  8682. */
  8683. static readonly KEYUP: number;
  8684. }
  8685. /**
  8686. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8687. */
  8688. export class KeyboardInfo {
  8689. /**
  8690. * Defines the type of event (KeyboardEventTypes)
  8691. */
  8692. type: number;
  8693. /**
  8694. * Defines the related dom event
  8695. */
  8696. event: KeyboardEvent;
  8697. /**
  8698. * Instantiates a new keyboard info.
  8699. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8700. * @param type Defines the type of event (KeyboardEventTypes)
  8701. * @param event Defines the related dom event
  8702. */
  8703. constructor(
  8704. /**
  8705. * Defines the type of event (KeyboardEventTypes)
  8706. */
  8707. type: number,
  8708. /**
  8709. * Defines the related dom event
  8710. */
  8711. event: KeyboardEvent);
  8712. }
  8713. /**
  8714. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8715. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8716. */
  8717. export class KeyboardInfoPre extends KeyboardInfo {
  8718. /**
  8719. * Defines the type of event (KeyboardEventTypes)
  8720. */
  8721. type: number;
  8722. /**
  8723. * Defines the related dom event
  8724. */
  8725. event: KeyboardEvent;
  8726. /**
  8727. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8728. */
  8729. skipOnPointerObservable: boolean;
  8730. /**
  8731. * Instantiates a new keyboard pre info.
  8732. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8733. * @param type Defines the type of event (KeyboardEventTypes)
  8734. * @param event Defines the related dom event
  8735. */
  8736. constructor(
  8737. /**
  8738. * Defines the type of event (KeyboardEventTypes)
  8739. */
  8740. type: number,
  8741. /**
  8742. * Defines the related dom event
  8743. */
  8744. event: KeyboardEvent);
  8745. }
  8746. }
  8747. declare module BABYLON {
  8748. /**
  8749. * Manage the keyboard inputs to control the movement of a free camera.
  8750. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8751. */
  8752. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8753. /**
  8754. * Defines the camera the input is attached to.
  8755. */
  8756. camera: FreeCamera;
  8757. /**
  8758. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8759. */
  8760. keysUp: number[];
  8761. /**
  8762. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8763. */
  8764. keysUpward: number[];
  8765. /**
  8766. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8767. */
  8768. keysDown: number[];
  8769. /**
  8770. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8771. */
  8772. keysDownward: number[];
  8773. /**
  8774. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8775. */
  8776. keysLeft: number[];
  8777. /**
  8778. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8779. */
  8780. keysRight: number[];
  8781. private _keys;
  8782. private _onCanvasBlurObserver;
  8783. private _onKeyboardObserver;
  8784. private _engine;
  8785. private _scene;
  8786. /**
  8787. * Attach the input controls to a specific dom element to get the input from.
  8788. * @param element Defines the element the controls should be listened from
  8789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8790. */
  8791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8792. /**
  8793. * Detach the current controls from the specified dom element.
  8794. * @param element Defines the element to stop listening the inputs from
  8795. */
  8796. detachControl(element: Nullable<HTMLElement>): void;
  8797. /**
  8798. * Update the current camera state depending on the inputs that have been used this frame.
  8799. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8800. */
  8801. checkInputs(): void;
  8802. /**
  8803. * Gets the class name of the current intput.
  8804. * @returns the class name
  8805. */
  8806. getClassName(): string;
  8807. /** @hidden */
  8808. _onLostFocus(): void;
  8809. /**
  8810. * Get the friendly name associated with the input class.
  8811. * @returns the input friendly name
  8812. */
  8813. getSimpleName(): string;
  8814. }
  8815. }
  8816. declare module BABYLON {
  8817. /**
  8818. * Interface describing all the common properties and methods a shadow light needs to implement.
  8819. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8820. * as well as binding the different shadow properties to the effects.
  8821. */
  8822. export interface IShadowLight extends Light {
  8823. /**
  8824. * The light id in the scene (used in scene.findLighById for instance)
  8825. */
  8826. id: string;
  8827. /**
  8828. * The position the shdow will be casted from.
  8829. */
  8830. position: Vector3;
  8831. /**
  8832. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8833. */
  8834. direction: Vector3;
  8835. /**
  8836. * The transformed position. Position of the light in world space taking parenting in account.
  8837. */
  8838. transformedPosition: Vector3;
  8839. /**
  8840. * The transformed direction. Direction of the light in world space taking parenting in account.
  8841. */
  8842. transformedDirection: Vector3;
  8843. /**
  8844. * The friendly name of the light in the scene.
  8845. */
  8846. name: string;
  8847. /**
  8848. * Defines the shadow projection clipping minimum z value.
  8849. */
  8850. shadowMinZ: number;
  8851. /**
  8852. * Defines the shadow projection clipping maximum z value.
  8853. */
  8854. shadowMaxZ: number;
  8855. /**
  8856. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8857. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8858. */
  8859. computeTransformedInformation(): boolean;
  8860. /**
  8861. * Gets the scene the light belongs to.
  8862. * @returns The scene
  8863. */
  8864. getScene(): Scene;
  8865. /**
  8866. * Callback defining a custom Projection Matrix Builder.
  8867. * This can be used to override the default projection matrix computation.
  8868. */
  8869. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8870. /**
  8871. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8872. * @param matrix The materix to updated with the projection information
  8873. * @param viewMatrix The transform matrix of the light
  8874. * @param renderList The list of mesh to render in the map
  8875. * @returns The current light
  8876. */
  8877. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8878. /**
  8879. * Gets the current depth scale used in ESM.
  8880. * @returns The scale
  8881. */
  8882. getDepthScale(): number;
  8883. /**
  8884. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8885. * @returns true if a cube texture needs to be use
  8886. */
  8887. needCube(): boolean;
  8888. /**
  8889. * Detects if the projection matrix requires to be recomputed this frame.
  8890. * @returns true if it requires to be recomputed otherwise, false.
  8891. */
  8892. needProjectionMatrixCompute(): boolean;
  8893. /**
  8894. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8895. */
  8896. forceProjectionMatrixCompute(): void;
  8897. /**
  8898. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8899. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8900. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8901. */
  8902. getShadowDirection(faceIndex?: number): Vector3;
  8903. /**
  8904. * Gets the minZ used for shadow according to both the scene and the light.
  8905. * @param activeCamera The camera we are returning the min for
  8906. * @returns the depth min z
  8907. */
  8908. getDepthMinZ(activeCamera: Camera): number;
  8909. /**
  8910. * Gets the maxZ used for shadow according to both the scene and the light.
  8911. * @param activeCamera The camera we are returning the max for
  8912. * @returns the depth max z
  8913. */
  8914. getDepthMaxZ(activeCamera: Camera): number;
  8915. }
  8916. /**
  8917. * Base implementation IShadowLight
  8918. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8919. */
  8920. export abstract class ShadowLight extends Light implements IShadowLight {
  8921. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8922. protected _position: Vector3;
  8923. protected _setPosition(value: Vector3): void;
  8924. /**
  8925. * Sets the position the shadow will be casted from. Also use as the light position for both
  8926. * point and spot lights.
  8927. */
  8928. get position(): Vector3;
  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. set position(value: Vector3);
  8934. protected _direction: Vector3;
  8935. protected _setDirection(value: Vector3): void;
  8936. /**
  8937. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8938. * Also use as the light direction on spot and directional lights.
  8939. */
  8940. get direction(): Vector3;
  8941. /**
  8942. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8943. * Also use as the light direction on spot and directional lights.
  8944. */
  8945. set direction(value: Vector3);
  8946. protected _shadowMinZ: number;
  8947. /**
  8948. * Gets the shadow projection clipping minimum z value.
  8949. */
  8950. get shadowMinZ(): number;
  8951. /**
  8952. * Sets the shadow projection clipping minimum z value.
  8953. */
  8954. set shadowMinZ(value: number);
  8955. protected _shadowMaxZ: number;
  8956. /**
  8957. * Sets the shadow projection clipping maximum z value.
  8958. */
  8959. get shadowMaxZ(): number;
  8960. /**
  8961. * Gets the shadow projection clipping maximum z value.
  8962. */
  8963. set shadowMaxZ(value: number);
  8964. /**
  8965. * Callback defining a custom Projection Matrix Builder.
  8966. * This can be used to override the default projection matrix computation.
  8967. */
  8968. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8969. /**
  8970. * The transformed position. Position of the light in world space taking parenting in account.
  8971. */
  8972. transformedPosition: Vector3;
  8973. /**
  8974. * The transformed direction. Direction of the light in world space taking parenting in account.
  8975. */
  8976. transformedDirection: Vector3;
  8977. private _needProjectionMatrixCompute;
  8978. /**
  8979. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8980. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8981. */
  8982. computeTransformedInformation(): boolean;
  8983. /**
  8984. * Return the depth scale used for the shadow map.
  8985. * @returns the depth scale.
  8986. */
  8987. getDepthScale(): number;
  8988. /**
  8989. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8990. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8991. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8992. */
  8993. getShadowDirection(faceIndex?: number): Vector3;
  8994. /**
  8995. * Returns the ShadowLight absolute position in the World.
  8996. * @returns the position vector in world space
  8997. */
  8998. getAbsolutePosition(): Vector3;
  8999. /**
  9000. * Sets the ShadowLight direction toward the passed target.
  9001. * @param target The point to target in local space
  9002. * @returns the updated ShadowLight direction
  9003. */
  9004. setDirectionToTarget(target: Vector3): Vector3;
  9005. /**
  9006. * Returns the light rotation in euler definition.
  9007. * @returns the x y z rotation in local space.
  9008. */
  9009. getRotation(): Vector3;
  9010. /**
  9011. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9012. * @returns true if a cube texture needs to be use
  9013. */
  9014. needCube(): boolean;
  9015. /**
  9016. * Detects if the projection matrix requires to be recomputed this frame.
  9017. * @returns true if it requires to be recomputed otherwise, false.
  9018. */
  9019. needProjectionMatrixCompute(): boolean;
  9020. /**
  9021. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9022. */
  9023. forceProjectionMatrixCompute(): void;
  9024. /** @hidden */
  9025. _initCache(): void;
  9026. /** @hidden */
  9027. _isSynchronized(): boolean;
  9028. /**
  9029. * Computes the world matrix of the node
  9030. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9031. * @returns the world matrix
  9032. */
  9033. computeWorldMatrix(force?: boolean): Matrix;
  9034. /**
  9035. * Gets the minZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the min for
  9037. * @returns the depth min z
  9038. */
  9039. getDepthMinZ(activeCamera: Camera): number;
  9040. /**
  9041. * Gets the maxZ used for shadow according to both the scene and the light.
  9042. * @param activeCamera The camera we are returning the max for
  9043. * @returns the depth max z
  9044. */
  9045. getDepthMaxZ(activeCamera: Camera): number;
  9046. /**
  9047. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9048. * @param matrix The materix to updated with the projection information
  9049. * @param viewMatrix The transform matrix of the light
  9050. * @param renderList The list of mesh to render in the map
  9051. * @returns The current light
  9052. */
  9053. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9054. }
  9055. }
  9056. declare module BABYLON {
  9057. /**
  9058. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9059. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9060. */
  9061. export class EffectFallbacks implements IEffectFallbacks {
  9062. private _defines;
  9063. private _currentRank;
  9064. private _maxRank;
  9065. private _mesh;
  9066. /**
  9067. * Removes the fallback from the bound mesh.
  9068. */
  9069. unBindMesh(): void;
  9070. /**
  9071. * Adds a fallback on the specified property.
  9072. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9073. * @param define The name of the define in the shader
  9074. */
  9075. addFallback(rank: number, define: string): void;
  9076. /**
  9077. * Sets the mesh to use CPU skinning when needing to fallback.
  9078. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9079. * @param mesh The mesh to use the fallbacks.
  9080. */
  9081. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9082. /**
  9083. * Checks to see if more fallbacks are still availible.
  9084. */
  9085. get hasMoreFallbacks(): boolean;
  9086. /**
  9087. * Removes the defines that should be removed when falling back.
  9088. * @param currentDefines defines the current define statements for the shader.
  9089. * @param effect defines the current effect we try to compile
  9090. * @returns The resulting defines with defines of the current rank removed.
  9091. */
  9092. reduce(currentDefines: string, effect: Effect): string;
  9093. }
  9094. }
  9095. declare module BABYLON {
  9096. /**
  9097. * "Static Class" containing the most commonly used helper while dealing with material for
  9098. * rendering purpose.
  9099. *
  9100. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9101. *
  9102. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9103. */
  9104. export class MaterialHelper {
  9105. /**
  9106. * Bind the current view position to an effect.
  9107. * @param effect The effect to be bound
  9108. * @param scene The scene the eyes position is used from
  9109. */
  9110. static BindEyePosition(effect: Effect, scene: Scene): void;
  9111. /**
  9112. * Helps preparing the defines values about the UVs in used in the effect.
  9113. * UVs are shared as much as we can accross channels in the shaders.
  9114. * @param texture The texture we are preparing the UVs for
  9115. * @param defines The defines to update
  9116. * @param key The channel key "diffuse", "specular"... used in the shader
  9117. */
  9118. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9119. /**
  9120. * Binds a texture matrix value to its corrsponding uniform
  9121. * @param texture The texture to bind the matrix for
  9122. * @param uniformBuffer The uniform buffer receivin the data
  9123. * @param key The channel key "diffuse", "specular"... used in the shader
  9124. */
  9125. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9126. /**
  9127. * Gets the current status of the fog (should it be enabled?)
  9128. * @param mesh defines the mesh to evaluate for fog support
  9129. * @param scene defines the hosting scene
  9130. * @returns true if fog must be enabled
  9131. */
  9132. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9133. /**
  9134. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9135. * @param mesh defines the current mesh
  9136. * @param scene defines the current scene
  9137. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9138. * @param pointsCloud defines if point cloud rendering has to be turned on
  9139. * @param fogEnabled defines if fog has to be turned on
  9140. * @param alphaTest defines if alpha testing has to be turned on
  9141. * @param defines defines the current list of defines
  9142. */
  9143. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9144. /**
  9145. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9146. * @param scene defines the current scene
  9147. * @param engine defines the current engine
  9148. * @param defines specifies the list of active defines
  9149. * @param useInstances defines if instances have to be turned on
  9150. * @param useClipPlane defines if clip plane have to be turned on
  9151. */
  9152. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9153. /**
  9154. * Prepares the defines for bones
  9155. * @param mesh The mesh containing the geometry data we will draw
  9156. * @param defines The defines to update
  9157. */
  9158. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9159. /**
  9160. * Prepares the defines for morph targets
  9161. * @param mesh The mesh containing the geometry data we will draw
  9162. * @param defines The defines to update
  9163. */
  9164. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9165. /**
  9166. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9167. * @param mesh The mesh containing the geometry data we will draw
  9168. * @param defines The defines to update
  9169. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9170. * @param useBones Precise whether bones should be used or not (override mesh info)
  9171. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9172. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9173. * @returns false if defines are considered not dirty and have not been checked
  9174. */
  9175. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9176. /**
  9177. * Prepares the defines related to multiview
  9178. * @param scene The scene we are intending to draw
  9179. * @param defines The defines to update
  9180. */
  9181. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9182. /**
  9183. * Prepares the defines related to the light information passed in parameter
  9184. * @param scene The scene we are intending to draw
  9185. * @param mesh The mesh the effect is compiling for
  9186. * @param light The light the effect is compiling for
  9187. * @param lightIndex The index of the light
  9188. * @param defines The defines to update
  9189. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9190. * @param state Defines the current state regarding what is needed (normals, etc...)
  9191. */
  9192. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9193. needNormals: boolean;
  9194. needRebuild: boolean;
  9195. shadowEnabled: boolean;
  9196. specularEnabled: boolean;
  9197. lightmapMode: boolean;
  9198. }): void;
  9199. /**
  9200. * Prepares the defines related to the light information passed in parameter
  9201. * @param scene The scene we are intending to draw
  9202. * @param mesh The mesh the effect is compiling for
  9203. * @param defines The defines to update
  9204. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9205. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9206. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9207. * @returns true if normals will be required for the rest of the effect
  9208. */
  9209. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9210. /**
  9211. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9212. * @param lightIndex defines the light index
  9213. * @param uniformsList The uniform list
  9214. * @param samplersList The sampler list
  9215. * @param projectedLightTexture defines if projected texture must be used
  9216. * @param uniformBuffersList defines an optional list of uniform buffers
  9217. */
  9218. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9219. /**
  9220. * Prepares the uniforms and samplers list to be used in the effect
  9221. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9222. * @param samplersList The sampler list
  9223. * @param defines The defines helping in the list generation
  9224. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9225. */
  9226. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9227. /**
  9228. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9229. * @param defines The defines to update while falling back
  9230. * @param fallbacks The authorized effect fallbacks
  9231. * @param maxSimultaneousLights The maximum number of lights allowed
  9232. * @param rank the current rank of the Effect
  9233. * @returns The newly affected rank
  9234. */
  9235. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9236. private static _TmpMorphInfluencers;
  9237. /**
  9238. * Prepares the list of attributes required for morph targets according to the effect defines.
  9239. * @param attribs The current list of supported attribs
  9240. * @param mesh The mesh to prepare the morph targets attributes for
  9241. * @param influencers The number of influencers
  9242. */
  9243. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9244. /**
  9245. * Prepares the list of attributes required for morph targets according to the effect defines.
  9246. * @param attribs The current list of supported attribs
  9247. * @param mesh The mesh to prepare the morph targets attributes for
  9248. * @param defines The current Defines of the effect
  9249. */
  9250. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9251. /**
  9252. * Prepares the list of attributes required for bones according to the effect defines.
  9253. * @param attribs The current list of supported attribs
  9254. * @param mesh The mesh to prepare the bones attributes for
  9255. * @param defines The current Defines of the effect
  9256. * @param fallbacks The current efffect fallback strategy
  9257. */
  9258. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9259. /**
  9260. * Check and prepare the list of attributes required for instances according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param defines The current MaterialDefines of the effect
  9263. */
  9264. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9265. /**
  9266. * Add the list of attributes required for instances to the attribs array.
  9267. * @param attribs The current list of supported attribs
  9268. */
  9269. static PushAttributesForInstances(attribs: string[]): void;
  9270. /**
  9271. * Binds the light information to the effect.
  9272. * @param light The light containing the generator
  9273. * @param effect The effect we are binding the data to
  9274. * @param lightIndex The light index in the effect used to render
  9275. */
  9276. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9277. /**
  9278. * Binds the lights information from the scene to the effect for the given mesh.
  9279. * @param light Light to bind
  9280. * @param lightIndex Light index
  9281. * @param scene The scene where the light belongs to
  9282. * @param effect The effect we are binding the data to
  9283. * @param useSpecular Defines if specular is supported
  9284. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9285. */
  9286. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9287. /**
  9288. * Binds the lights information from the scene to the effect for the given mesh.
  9289. * @param scene The scene the lights belongs to
  9290. * @param mesh The mesh we are binding the information to render
  9291. * @param effect The effect we are binding the data to
  9292. * @param defines The generated defines for the effect
  9293. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9294. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9295. */
  9296. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9297. private static _tempFogColor;
  9298. /**
  9299. * Binds the fog information from the scene to the effect for the given mesh.
  9300. * @param scene The scene the lights belongs to
  9301. * @param mesh The mesh we are binding the information to render
  9302. * @param effect The effect we are binding the data to
  9303. * @param linearSpace Defines if the fog effect is applied in linear space
  9304. */
  9305. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9306. /**
  9307. * Binds the bones information from the mesh to the effect.
  9308. * @param mesh The mesh we are binding the information to render
  9309. * @param effect The effect we are binding the data to
  9310. */
  9311. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9312. /**
  9313. * Binds the morph targets information from the mesh to the effect.
  9314. * @param abstractMesh The mesh we are binding the information to render
  9315. * @param effect The effect we are binding the data to
  9316. */
  9317. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9318. /**
  9319. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9320. * @param defines The generated defines used in the effect
  9321. * @param effect The effect we are binding the data to
  9322. * @param scene The scene we are willing to render with logarithmic scale for
  9323. */
  9324. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9325. /**
  9326. * Binds the clip plane information from the scene to the effect.
  9327. * @param scene The scene the clip plane information are extracted from
  9328. * @param effect The effect we are binding the data to
  9329. */
  9330. static BindClipPlane(effect: Effect, scene: Scene): void;
  9331. }
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var packingFunctions: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var clipPlaneFragmentDeclaration: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var clipPlaneFragment: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var shadowMapPixelShader: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var bonesDeclaration: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var morphTargetsVertexGlobalDeclaration: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var morphTargetsVertexDeclaration: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var instancesDeclaration: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /** @hidden */
  9391. export var helperFunctions: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module BABYLON {
  9397. /** @hidden */
  9398. export var clipPlaneVertexDeclaration: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module BABYLON {
  9404. /** @hidden */
  9405. export var morphTargetsVertex: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module BABYLON {
  9411. /** @hidden */
  9412. export var instancesVertex: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module BABYLON {
  9418. /** @hidden */
  9419. export var bonesVertex: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module BABYLON {
  9425. /** @hidden */
  9426. export var clipPlaneVertex: {
  9427. name: string;
  9428. shader: string;
  9429. };
  9430. }
  9431. declare module BABYLON {
  9432. /** @hidden */
  9433. export var shadowMapVertexShader: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module BABYLON {
  9439. /** @hidden */
  9440. export var depthBoxBlurPixelShader: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module BABYLON {
  9446. /**
  9447. * Class representing a ray with position and direction
  9448. */
  9449. export class Ray {
  9450. /** origin point */
  9451. origin: Vector3;
  9452. /** direction */
  9453. direction: Vector3;
  9454. /** length of the ray */
  9455. length: number;
  9456. private static readonly TmpVector3;
  9457. private _tmpRay;
  9458. /**
  9459. * Creates a new ray
  9460. * @param origin origin point
  9461. * @param direction direction
  9462. * @param length length of the ray
  9463. */
  9464. constructor(
  9465. /** origin point */
  9466. origin: Vector3,
  9467. /** direction */
  9468. direction: Vector3,
  9469. /** length of the ray */
  9470. length?: number);
  9471. /**
  9472. * Checks if the ray intersects a box
  9473. * @param minimum bound of the box
  9474. * @param maximum bound of the box
  9475. * @param intersectionTreshold extra extend to be added to the box in all direction
  9476. * @returns if the box was hit
  9477. */
  9478. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9479. /**
  9480. * Checks if the ray intersects a box
  9481. * @param box the bounding box to check
  9482. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9483. * @returns if the box was hit
  9484. */
  9485. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9486. /**
  9487. * If the ray hits a sphere
  9488. * @param sphere the bounding sphere to check
  9489. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9490. * @returns true if it hits the sphere
  9491. */
  9492. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9493. /**
  9494. * If the ray hits a triange
  9495. * @param vertex0 triangle vertex
  9496. * @param vertex1 triangle vertex
  9497. * @param vertex2 triangle vertex
  9498. * @returns intersection information if hit
  9499. */
  9500. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9501. /**
  9502. * Checks if ray intersects a plane
  9503. * @param plane the plane to check
  9504. * @returns the distance away it was hit
  9505. */
  9506. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9507. /**
  9508. * Calculate the intercept of a ray on a given axis
  9509. * @param axis to check 'x' | 'y' | 'z'
  9510. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9511. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9512. */
  9513. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9514. /**
  9515. * Checks if ray intersects a mesh
  9516. * @param mesh the mesh to check
  9517. * @param fastCheck if only the bounding box should checked
  9518. * @returns picking info of the intersecton
  9519. */
  9520. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9521. /**
  9522. * Checks if ray intersects a mesh
  9523. * @param meshes the meshes to check
  9524. * @param fastCheck if only the bounding box should checked
  9525. * @param results array to store result in
  9526. * @returns Array of picking infos
  9527. */
  9528. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9529. private _comparePickingInfo;
  9530. private static smallnum;
  9531. private static rayl;
  9532. /**
  9533. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9534. * @param sega the first point of the segment to test the intersection against
  9535. * @param segb the second point of the segment to test the intersection against
  9536. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9537. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9538. */
  9539. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9540. /**
  9541. * Update the ray from viewport position
  9542. * @param x position
  9543. * @param y y position
  9544. * @param viewportWidth viewport width
  9545. * @param viewportHeight viewport height
  9546. * @param world world matrix
  9547. * @param view view matrix
  9548. * @param projection projection matrix
  9549. * @returns this ray updated
  9550. */
  9551. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9552. /**
  9553. * Creates a ray with origin and direction of 0,0,0
  9554. * @returns the new ray
  9555. */
  9556. static Zero(): Ray;
  9557. /**
  9558. * Creates a new ray from screen space and viewport
  9559. * @param x position
  9560. * @param y y position
  9561. * @param viewportWidth viewport width
  9562. * @param viewportHeight viewport height
  9563. * @param world world matrix
  9564. * @param view view matrix
  9565. * @param projection projection matrix
  9566. * @returns new ray
  9567. */
  9568. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9569. /**
  9570. * 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
  9571. * transformed to the given world matrix.
  9572. * @param origin The origin point
  9573. * @param end The end point
  9574. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9575. * @returns the new ray
  9576. */
  9577. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9578. /**
  9579. * Transforms a ray by a matrix
  9580. * @param ray ray to transform
  9581. * @param matrix matrix to apply
  9582. * @returns the resulting new ray
  9583. */
  9584. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9585. /**
  9586. * Transforms a ray by a matrix
  9587. * @param ray ray to transform
  9588. * @param matrix matrix to apply
  9589. * @param result ray to store result in
  9590. */
  9591. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9592. /**
  9593. * Unproject a ray from screen space to object space
  9594. * @param sourceX defines the screen space x coordinate to use
  9595. * @param sourceY defines the screen space y coordinate to use
  9596. * @param viewportWidth defines the current width of the viewport
  9597. * @param viewportHeight defines the current height of the viewport
  9598. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9599. * @param view defines the view matrix to use
  9600. * @param projection defines the projection matrix to use
  9601. */
  9602. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9603. }
  9604. /**
  9605. * Type used to define predicate used to select faces when a mesh intersection is detected
  9606. */
  9607. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9608. interface Scene {
  9609. /** @hidden */
  9610. _tempPickingRay: Nullable<Ray>;
  9611. /** @hidden */
  9612. _cachedRayForTransform: Ray;
  9613. /** @hidden */
  9614. _pickWithRayInverseMatrix: Matrix;
  9615. /** @hidden */
  9616. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9617. /** @hidden */
  9618. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9619. }
  9620. }
  9621. declare module BABYLON {
  9622. /**
  9623. * Groups all the scene component constants in one place to ease maintenance.
  9624. * @hidden
  9625. */
  9626. export class SceneComponentConstants {
  9627. static readonly NAME_EFFECTLAYER: string;
  9628. static readonly NAME_LAYER: string;
  9629. static readonly NAME_LENSFLARESYSTEM: string;
  9630. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9631. static readonly NAME_PARTICLESYSTEM: string;
  9632. static readonly NAME_GAMEPAD: string;
  9633. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9634. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9635. static readonly NAME_DEPTHRENDERER: string;
  9636. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9637. static readonly NAME_SPRITE: string;
  9638. static readonly NAME_OUTLINERENDERER: string;
  9639. static readonly NAME_PROCEDURALTEXTURE: string;
  9640. static readonly NAME_SHADOWGENERATOR: string;
  9641. static readonly NAME_OCTREE: string;
  9642. static readonly NAME_PHYSICSENGINE: string;
  9643. static readonly NAME_AUDIO: string;
  9644. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9645. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9646. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9647. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9648. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9649. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9650. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9651. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9652. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9653. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9654. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9655. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9656. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9657. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9658. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9659. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9660. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9661. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9662. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9663. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9664. static readonly STEP_AFTERRENDER_AUDIO: number;
  9665. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9666. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9667. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9668. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9669. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9670. static readonly STEP_POINTERMOVE_SPRITE: number;
  9671. static readonly STEP_POINTERDOWN_SPRITE: number;
  9672. static readonly STEP_POINTERUP_SPRITE: number;
  9673. }
  9674. /**
  9675. * This represents a scene component.
  9676. *
  9677. * This is used to decouple the dependency the scene is having on the different workloads like
  9678. * layers, post processes...
  9679. */
  9680. export interface ISceneComponent {
  9681. /**
  9682. * The name of the component. Each component must have a unique name.
  9683. */
  9684. name: string;
  9685. /**
  9686. * The scene the component belongs to.
  9687. */
  9688. scene: Scene;
  9689. /**
  9690. * Register the component to one instance of a scene.
  9691. */
  9692. register(): void;
  9693. /**
  9694. * Rebuilds the elements related to this component in case of
  9695. * context lost for instance.
  9696. */
  9697. rebuild(): void;
  9698. /**
  9699. * Disposes the component and the associated ressources.
  9700. */
  9701. dispose(): void;
  9702. }
  9703. /**
  9704. * This represents a SERIALIZABLE scene component.
  9705. *
  9706. * This extends Scene Component to add Serialization methods on top.
  9707. */
  9708. export interface ISceneSerializableComponent extends ISceneComponent {
  9709. /**
  9710. * Adds all the elements from the container to the scene
  9711. * @param container the container holding the elements
  9712. */
  9713. addFromContainer(container: AbstractScene): void;
  9714. /**
  9715. * Removes all the elements in the container from the scene
  9716. * @param container contains the elements to remove
  9717. * @param dispose if the removed element should be disposed (default: false)
  9718. */
  9719. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9720. /**
  9721. * Serializes the component data to the specified json object
  9722. * @param serializationObject The object to serialize to
  9723. */
  9724. serialize(serializationObject: any): void;
  9725. }
  9726. /**
  9727. * Strong typing of a Mesh related stage step action
  9728. */
  9729. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9730. /**
  9731. * Strong typing of a Evaluate Sub Mesh related stage step action
  9732. */
  9733. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9734. /**
  9735. * Strong typing of a Active Mesh related stage step action
  9736. */
  9737. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9738. /**
  9739. * Strong typing of a Camera related stage step action
  9740. */
  9741. export type CameraStageAction = (camera: Camera) => void;
  9742. /**
  9743. * Strong typing of a Camera Frame buffer related stage step action
  9744. */
  9745. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9746. /**
  9747. * Strong typing of a Render Target related stage step action
  9748. */
  9749. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9750. /**
  9751. * Strong typing of a RenderingGroup related stage step action
  9752. */
  9753. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9754. /**
  9755. * Strong typing of a Mesh Render related stage step action
  9756. */
  9757. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9758. /**
  9759. * Strong typing of a simple stage step action
  9760. */
  9761. export type SimpleStageAction = () => void;
  9762. /**
  9763. * Strong typing of a render target action.
  9764. */
  9765. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9766. /**
  9767. * Strong typing of a pointer move action.
  9768. */
  9769. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9770. /**
  9771. * Strong typing of a pointer up/down action.
  9772. */
  9773. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9774. /**
  9775. * Representation of a stage in the scene (Basically a list of ordered steps)
  9776. * @hidden
  9777. */
  9778. export class Stage<T extends Function> extends Array<{
  9779. index: number;
  9780. component: ISceneComponent;
  9781. action: T;
  9782. }> {
  9783. /**
  9784. * Hide ctor from the rest of the world.
  9785. * @param items The items to add.
  9786. */
  9787. private constructor();
  9788. /**
  9789. * Creates a new Stage.
  9790. * @returns A new instance of a Stage
  9791. */
  9792. static Create<T extends Function>(): Stage<T>;
  9793. /**
  9794. * Registers a step in an ordered way in the targeted stage.
  9795. * @param index Defines the position to register the step in
  9796. * @param component Defines the component attached to the step
  9797. * @param action Defines the action to launch during the step
  9798. */
  9799. registerStep(index: number, component: ISceneComponent, action: T): void;
  9800. /**
  9801. * Clears all the steps from the stage.
  9802. */
  9803. clear(): void;
  9804. }
  9805. }
  9806. declare module BABYLON {
  9807. interface Scene {
  9808. /** @hidden */
  9809. _pointerOverSprite: Nullable<Sprite>;
  9810. /** @hidden */
  9811. _pickedDownSprite: Nullable<Sprite>;
  9812. /** @hidden */
  9813. _tempSpritePickingRay: Nullable<Ray>;
  9814. /**
  9815. * All of the sprite managers added to this scene
  9816. * @see http://doc.babylonjs.com/babylon101/sprites
  9817. */
  9818. spriteManagers: Array<ISpriteManager>;
  9819. /**
  9820. * An event triggered when sprites rendering is about to start
  9821. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9822. */
  9823. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9824. /**
  9825. * An event triggered when sprites rendering is done
  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. onAfterSpritesRenderingObservable: Observable<Scene>;
  9829. /** @hidden */
  9830. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9831. /** Launch a ray to try to pick a sprite in the scene
  9832. * @param x position on screen
  9833. * @param y position on screen
  9834. * @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
  9835. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9836. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9837. * @returns a PickingInfo
  9838. */
  9839. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9840. /** Use the given ray to pick a sprite in the scene
  9841. * @param ray The ray (in world space) to use to pick meshes
  9842. * @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
  9843. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9844. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9845. * @returns a PickingInfo
  9846. */
  9847. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9848. /** @hidden */
  9849. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9850. /** Launch a ray to try to pick sprites in the scene
  9851. * @param x position on screen
  9852. * @param y position on screen
  9853. * @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
  9854. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9855. * @returns a PickingInfo array
  9856. */
  9857. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9858. /** Use the given ray to pick sprites in the scene
  9859. * @param ray The ray (in world space) to use to pick meshes
  9860. * @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
  9861. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9862. * @returns a PickingInfo array
  9863. */
  9864. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9865. /**
  9866. * Force the sprite under the pointer
  9867. * @param sprite defines the sprite to use
  9868. */
  9869. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9870. /**
  9871. * Gets the sprite under the pointer
  9872. * @returns a Sprite or null if no sprite is under the pointer
  9873. */
  9874. getPointerOverSprite(): Nullable<Sprite>;
  9875. }
  9876. /**
  9877. * Defines the sprite scene component responsible to manage sprites
  9878. * in a given scene.
  9879. */
  9880. export class SpriteSceneComponent implements ISceneComponent {
  9881. /**
  9882. * The component name helpfull to identify the component in the list of scene components.
  9883. */
  9884. readonly name: string;
  9885. /**
  9886. * The scene the component belongs to.
  9887. */
  9888. scene: Scene;
  9889. /** @hidden */
  9890. private _spritePredicate;
  9891. /**
  9892. * Creates a new instance of the component for the given scene
  9893. * @param scene Defines the scene to register the component in
  9894. */
  9895. constructor(scene: Scene);
  9896. /**
  9897. * Registers the component in a given scene
  9898. */
  9899. register(): void;
  9900. /**
  9901. * Rebuilds the elements related to this component in case of
  9902. * context lost for instance.
  9903. */
  9904. rebuild(): void;
  9905. /**
  9906. * Disposes the component and the associated ressources.
  9907. */
  9908. dispose(): void;
  9909. private _pickSpriteButKeepRay;
  9910. private _pointerMove;
  9911. private _pointerDown;
  9912. private _pointerUp;
  9913. }
  9914. }
  9915. declare module BABYLON {
  9916. /** @hidden */
  9917. export var fogFragmentDeclaration: {
  9918. name: string;
  9919. shader: string;
  9920. };
  9921. }
  9922. declare module BABYLON {
  9923. /** @hidden */
  9924. export var fogFragment: {
  9925. name: string;
  9926. shader: string;
  9927. };
  9928. }
  9929. declare module BABYLON {
  9930. /** @hidden */
  9931. export var spritesPixelShader: {
  9932. name: string;
  9933. shader: string;
  9934. };
  9935. }
  9936. declare module BABYLON {
  9937. /** @hidden */
  9938. export var fogVertexDeclaration: {
  9939. name: string;
  9940. shader: string;
  9941. };
  9942. }
  9943. declare module BABYLON {
  9944. /** @hidden */
  9945. export var spritesVertexShader: {
  9946. name: string;
  9947. shader: string;
  9948. };
  9949. }
  9950. declare module BABYLON {
  9951. /**
  9952. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9953. */
  9954. export interface ISpriteManager extends IDisposable {
  9955. /**
  9956. * Restricts the camera to viewing objects with the same layerMask.
  9957. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9958. */
  9959. layerMask: number;
  9960. /**
  9961. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9962. */
  9963. isPickable: boolean;
  9964. /**
  9965. * Specifies the rendering group id for this mesh (0 by default)
  9966. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9967. */
  9968. renderingGroupId: number;
  9969. /**
  9970. * Defines the list of sprites managed by the manager.
  9971. */
  9972. sprites: Array<Sprite>;
  9973. /**
  9974. * Tests the intersection of a sprite with a specific ray.
  9975. * @param ray The ray we are sending to test the collision
  9976. * @param camera The camera space we are sending rays in
  9977. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9978. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9979. * @returns picking info or null.
  9980. */
  9981. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9982. /**
  9983. * Intersects the sprites with a ray
  9984. * @param ray defines the ray to intersect with
  9985. * @param camera defines the current active camera
  9986. * @param predicate defines a predicate used to select candidate sprites
  9987. * @returns null if no hit or a PickingInfo array
  9988. */
  9989. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9990. /**
  9991. * Renders the list of sprites on screen.
  9992. */
  9993. render(): void;
  9994. }
  9995. /**
  9996. * Class used to manage multiple sprites on the same spritesheet
  9997. * @see http://doc.babylonjs.com/babylon101/sprites
  9998. */
  9999. export class SpriteManager implements ISpriteManager {
  10000. /** defines the manager's name */
  10001. name: string;
  10002. /** Gets the list of sprites */
  10003. sprites: Sprite[];
  10004. /** Gets or sets the rendering group id (0 by default) */
  10005. renderingGroupId: number;
  10006. /** Gets or sets camera layer mask */
  10007. layerMask: number;
  10008. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10009. fogEnabled: boolean;
  10010. /** Gets or sets a boolean indicating if the sprites are pickable */
  10011. isPickable: boolean;
  10012. /** Defines the default width of a cell in the spritesheet */
  10013. cellWidth: number;
  10014. /** Defines the default height of a cell in the spritesheet */
  10015. cellHeight: number;
  10016. /** Associative array from JSON sprite data file */
  10017. private _cellData;
  10018. /** Array of sprite names from JSON sprite data file */
  10019. private _spriteMap;
  10020. /** True when packed cell data from JSON file is ready*/
  10021. private _packedAndReady;
  10022. /**
  10023. * An event triggered when the manager is disposed.
  10024. */
  10025. onDisposeObservable: Observable<SpriteManager>;
  10026. private _onDisposeObserver;
  10027. /**
  10028. * Callback called when the manager is disposed
  10029. */
  10030. set onDispose(callback: () => void);
  10031. private _capacity;
  10032. private _fromPacked;
  10033. private _spriteTexture;
  10034. private _epsilon;
  10035. private _scene;
  10036. private _vertexData;
  10037. private _buffer;
  10038. private _vertexBuffers;
  10039. private _indexBuffer;
  10040. private _effectBase;
  10041. private _effectFog;
  10042. /**
  10043. * Gets or sets the spritesheet texture
  10044. */
  10045. get texture(): Texture;
  10046. set texture(value: Texture);
  10047. private _blendMode;
  10048. /**
  10049. * Blend mode use to render the particle, it can be any of
  10050. * the static Constants.ALPHA_x properties provided in this class.
  10051. * Default value is Constants.ALPHA_COMBINE
  10052. */
  10053. get blendMode(): number;
  10054. set blendMode(blendMode: number);
  10055. /** Disables writing to the depth buffer when rendering the sprites.
  10056. * It can be handy to disable depth writing when using textures without alpha channel
  10057. * and setting some specific blend modes.
  10058. */
  10059. disableDepthWrite: boolean;
  10060. /**
  10061. * Creates a new sprite manager
  10062. * @param name defines the manager's name
  10063. * @param imgUrl defines the sprite sheet url
  10064. * @param capacity defines the maximum allowed number of sprites
  10065. * @param cellSize defines the size of a sprite cell
  10066. * @param scene defines the hosting scene
  10067. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10068. * @param samplingMode defines the smapling mode to use with spritesheet
  10069. * @param fromPacked set to false; do not alter
  10070. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10071. */
  10072. constructor(
  10073. /** defines the manager's name */
  10074. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10075. private _makePacked;
  10076. private _appendSpriteVertex;
  10077. /**
  10078. * Intersects the sprites with a ray
  10079. * @param ray defines the ray to intersect with
  10080. * @param camera defines the current active camera
  10081. * @param predicate defines a predicate used to select candidate sprites
  10082. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10083. * @returns null if no hit or a PickingInfo
  10084. */
  10085. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10086. /**
  10087. * Intersects the sprites with a ray
  10088. * @param ray defines the ray to intersect with
  10089. * @param camera defines the current active camera
  10090. * @param predicate defines a predicate used to select candidate sprites
  10091. * @returns null if no hit or a PickingInfo array
  10092. */
  10093. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10094. /**
  10095. * Render all child sprites
  10096. */
  10097. render(): void;
  10098. /**
  10099. * Release associated resources
  10100. */
  10101. dispose(): void;
  10102. }
  10103. }
  10104. declare module BABYLON {
  10105. /** Interface used by value gradients (color, factor, ...) */
  10106. export interface IValueGradient {
  10107. /**
  10108. * Gets or sets the gradient value (between 0 and 1)
  10109. */
  10110. gradient: number;
  10111. }
  10112. /** Class used to store color4 gradient */
  10113. export class ColorGradient implements IValueGradient {
  10114. /**
  10115. * Gets or sets the gradient value (between 0 and 1)
  10116. */
  10117. gradient: number;
  10118. /**
  10119. * Gets or sets first associated color
  10120. */
  10121. color1: Color4;
  10122. /**
  10123. * Gets or sets second associated color
  10124. */
  10125. color2?: Color4 | undefined;
  10126. /**
  10127. * Creates a new color4 gradient
  10128. * @param gradient gets or sets the gradient value (between 0 and 1)
  10129. * @param color1 gets or sets first associated color
  10130. * @param color2 gets or sets first second color
  10131. */
  10132. constructor(
  10133. /**
  10134. * Gets or sets the gradient value (between 0 and 1)
  10135. */
  10136. gradient: number,
  10137. /**
  10138. * Gets or sets first associated color
  10139. */
  10140. color1: Color4,
  10141. /**
  10142. * Gets or sets second associated color
  10143. */
  10144. color2?: Color4 | undefined);
  10145. /**
  10146. * Will get a color picked randomly between color1 and color2.
  10147. * If color2 is undefined then color1 will be used
  10148. * @param result defines the target Color4 to store the result in
  10149. */
  10150. getColorToRef(result: Color4): void;
  10151. }
  10152. /** Class used to store color 3 gradient */
  10153. export class Color3Gradient implements IValueGradient {
  10154. /**
  10155. * Gets or sets the gradient value (between 0 and 1)
  10156. */
  10157. gradient: number;
  10158. /**
  10159. * Gets or sets the associated color
  10160. */
  10161. color: Color3;
  10162. /**
  10163. * Creates a new color3 gradient
  10164. * @param gradient gets or sets the gradient value (between 0 and 1)
  10165. * @param color gets or sets associated color
  10166. */
  10167. constructor(
  10168. /**
  10169. * Gets or sets the gradient value (between 0 and 1)
  10170. */
  10171. gradient: number,
  10172. /**
  10173. * Gets or sets the associated color
  10174. */
  10175. color: Color3);
  10176. }
  10177. /** Class used to store factor gradient */
  10178. export class FactorGradient implements IValueGradient {
  10179. /**
  10180. * Gets or sets the gradient value (between 0 and 1)
  10181. */
  10182. gradient: number;
  10183. /**
  10184. * Gets or sets first associated factor
  10185. */
  10186. factor1: number;
  10187. /**
  10188. * Gets or sets second associated factor
  10189. */
  10190. factor2?: number | undefined;
  10191. /**
  10192. * Creates a new factor gradient
  10193. * @param gradient gets or sets the gradient value (between 0 and 1)
  10194. * @param factor1 gets or sets first associated factor
  10195. * @param factor2 gets or sets second associated factor
  10196. */
  10197. constructor(
  10198. /**
  10199. * Gets or sets the gradient value (between 0 and 1)
  10200. */
  10201. gradient: number,
  10202. /**
  10203. * Gets or sets first associated factor
  10204. */
  10205. factor1: number,
  10206. /**
  10207. * Gets or sets second associated factor
  10208. */
  10209. factor2?: number | undefined);
  10210. /**
  10211. * Will get a number picked randomly between factor1 and factor2.
  10212. * If factor2 is undefined then factor1 will be used
  10213. * @returns the picked number
  10214. */
  10215. getFactor(): number;
  10216. }
  10217. /**
  10218. * Helper used to simplify some generic gradient tasks
  10219. */
  10220. export class GradientHelper {
  10221. /**
  10222. * Gets the current gradient from an array of IValueGradient
  10223. * @param ratio defines the current ratio to get
  10224. * @param gradients defines the array of IValueGradient
  10225. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10226. */
  10227. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10228. }
  10229. }
  10230. declare module BABYLON {
  10231. /**
  10232. * Interface for the size containing width and height
  10233. */
  10234. export interface ISize {
  10235. /**
  10236. * Width
  10237. */
  10238. width: number;
  10239. /**
  10240. * Heighht
  10241. */
  10242. height: number;
  10243. }
  10244. /**
  10245. * Size containing widht and height
  10246. */
  10247. export class Size implements ISize {
  10248. /**
  10249. * Width
  10250. */
  10251. width: number;
  10252. /**
  10253. * Height
  10254. */
  10255. height: number;
  10256. /**
  10257. * Creates a Size object from the given width and height (floats).
  10258. * @param width width of the new size
  10259. * @param height height of the new size
  10260. */
  10261. constructor(width: number, height: number);
  10262. /**
  10263. * Returns a string with the Size width and height
  10264. * @returns a string with the Size width and height
  10265. */
  10266. toString(): string;
  10267. /**
  10268. * "Size"
  10269. * @returns the string "Size"
  10270. */
  10271. getClassName(): string;
  10272. /**
  10273. * Returns the Size hash code.
  10274. * @returns a hash code for a unique width and height
  10275. */
  10276. getHashCode(): number;
  10277. /**
  10278. * Updates the current size from the given one.
  10279. * @param src the given size
  10280. */
  10281. copyFrom(src: Size): void;
  10282. /**
  10283. * Updates in place the current Size from the given floats.
  10284. * @param width width of the new size
  10285. * @param height height of the new size
  10286. * @returns the updated Size.
  10287. */
  10288. copyFromFloats(width: number, height: number): Size;
  10289. /**
  10290. * Updates in place the current Size from the given floats.
  10291. * @param width width to set
  10292. * @param height height to set
  10293. * @returns the updated Size.
  10294. */
  10295. set(width: number, height: number): Size;
  10296. /**
  10297. * Multiplies the width and height by numbers
  10298. * @param w factor to multiple the width by
  10299. * @param h factor to multiple the height by
  10300. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10301. */
  10302. multiplyByFloats(w: number, h: number): Size;
  10303. /**
  10304. * Clones the size
  10305. * @returns a new Size copied from the given one.
  10306. */
  10307. clone(): Size;
  10308. /**
  10309. * True if the current Size and the given one width and height are strictly equal.
  10310. * @param other the other size to compare against
  10311. * @returns True if the current Size and the given one width and height are strictly equal.
  10312. */
  10313. equals(other: Size): boolean;
  10314. /**
  10315. * The surface of the Size : width * height (float).
  10316. */
  10317. get surface(): number;
  10318. /**
  10319. * Create a new size of zero
  10320. * @returns a new Size set to (0.0, 0.0)
  10321. */
  10322. static Zero(): Size;
  10323. /**
  10324. * Sums the width and height of two sizes
  10325. * @param otherSize size to add to this size
  10326. * @returns a new Size set as the addition result of the current Size and the given one.
  10327. */
  10328. add(otherSize: Size): Size;
  10329. /**
  10330. * Subtracts the width and height of two
  10331. * @param otherSize size to subtract to this size
  10332. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10333. */
  10334. subtract(otherSize: Size): Size;
  10335. /**
  10336. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10337. * @param start starting size to lerp between
  10338. * @param end end size to lerp between
  10339. * @param amount amount to lerp between the start and end values
  10340. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10341. */
  10342. static Lerp(start: Size, end: Size, amount: number): Size;
  10343. }
  10344. }
  10345. declare module BABYLON {
  10346. interface ThinEngine {
  10347. /**
  10348. * Creates a dynamic texture
  10349. * @param width defines the width of the texture
  10350. * @param height defines the height of the texture
  10351. * @param generateMipMaps defines if the engine should generate the mip levels
  10352. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10353. * @returns the dynamic texture inside an InternalTexture
  10354. */
  10355. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10356. /**
  10357. * Update the content of a dynamic texture
  10358. * @param texture defines the texture to update
  10359. * @param canvas defines the canvas containing the source
  10360. * @param invertY defines if data must be stored with Y axis inverted
  10361. * @param premulAlpha defines if alpha is stored as premultiplied
  10362. * @param format defines the format of the data
  10363. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10364. */
  10365. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10366. }
  10367. }
  10368. declare module BABYLON {
  10369. /**
  10370. * Helper class used to generate a canvas to manipulate images
  10371. */
  10372. export class CanvasGenerator {
  10373. /**
  10374. * Create a new canvas (or offscreen canvas depending on the context)
  10375. * @param width defines the expected width
  10376. * @param height defines the expected height
  10377. * @return a new canvas or offscreen canvas
  10378. */
  10379. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10380. }
  10381. }
  10382. declare module BABYLON {
  10383. /**
  10384. * A class extending Texture allowing drawing on a texture
  10385. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10386. */
  10387. export class DynamicTexture extends Texture {
  10388. private _generateMipMaps;
  10389. private _canvas;
  10390. private _context;
  10391. private _engine;
  10392. /**
  10393. * Creates a DynamicTexture
  10394. * @param name defines the name of the texture
  10395. * @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
  10396. * @param scene defines the scene where you want the texture
  10397. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10398. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10399. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10400. */
  10401. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10402. /**
  10403. * Get the current class name of the texture useful for serialization or dynamic coding.
  10404. * @returns "DynamicTexture"
  10405. */
  10406. getClassName(): string;
  10407. /**
  10408. * Gets the current state of canRescale
  10409. */
  10410. get canRescale(): boolean;
  10411. private _recreate;
  10412. /**
  10413. * Scales the texture
  10414. * @param ratio the scale factor to apply to both width and height
  10415. */
  10416. scale(ratio: number): void;
  10417. /**
  10418. * Resizes the texture
  10419. * @param width the new width
  10420. * @param height the new height
  10421. */
  10422. scaleTo(width: number, height: number): void;
  10423. /**
  10424. * Gets the context of the canvas used by the texture
  10425. * @returns the canvas context of the dynamic texture
  10426. */
  10427. getContext(): CanvasRenderingContext2D;
  10428. /**
  10429. * Clears the texture
  10430. */
  10431. clear(): void;
  10432. /**
  10433. * Updates the texture
  10434. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10435. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10436. */
  10437. update(invertY?: boolean, premulAlpha?: boolean): void;
  10438. /**
  10439. * Draws text onto the texture
  10440. * @param text defines the text to be drawn
  10441. * @param x defines the placement of the text from the left
  10442. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10443. * @param font defines the font to be used with font-style, font-size, font-name
  10444. * @param color defines the color used for the text
  10445. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10446. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10447. * @param update defines whether texture is immediately update (default is true)
  10448. */
  10449. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10450. /**
  10451. * Clones the texture
  10452. * @returns the clone of the texture.
  10453. */
  10454. clone(): DynamicTexture;
  10455. /**
  10456. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10457. * @returns a serialized dynamic texture object
  10458. */
  10459. serialize(): any;
  10460. /** @hidden */
  10461. _rebuild(): void;
  10462. }
  10463. }
  10464. declare module BABYLON {
  10465. interface Engine {
  10466. /**
  10467. * Creates a raw texture
  10468. * @param data defines the data to store in the texture
  10469. * @param width defines the width of the texture
  10470. * @param height defines the height of the texture
  10471. * @param format defines the format of the data
  10472. * @param generateMipMaps defines if the engine should generate the mip levels
  10473. * @param invertY defines if data must be stored with Y axis inverted
  10474. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10475. * @param compression defines the compression used (null by default)
  10476. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10477. * @returns the raw texture inside an InternalTexture
  10478. */
  10479. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10480. /**
  10481. * Update a raw texture
  10482. * @param texture defines the texture to update
  10483. * @param data defines the data to store in the texture
  10484. * @param format defines the format of the data
  10485. * @param invertY defines if data must be stored with Y axis inverted
  10486. */
  10487. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10488. /**
  10489. * Update a raw texture
  10490. * @param texture defines the texture to update
  10491. * @param data defines the data to store in the texture
  10492. * @param format defines the format of the data
  10493. * @param invertY defines if data must be stored with Y axis inverted
  10494. * @param compression defines the compression used (null by default)
  10495. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10496. */
  10497. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10498. /**
  10499. * Creates a new raw cube texture
  10500. * @param data defines the array of data to use to create each face
  10501. * @param size defines the size of the textures
  10502. * @param format defines the format of the data
  10503. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10504. * @param generateMipMaps defines if the engine should generate the mip levels
  10505. * @param invertY defines if data must be stored with Y axis inverted
  10506. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10507. * @param compression defines the compression used (null by default)
  10508. * @returns the cube texture as an InternalTexture
  10509. */
  10510. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10511. /**
  10512. * Update a raw cube texture
  10513. * @param texture defines the texture to udpdate
  10514. * @param data defines the data to store
  10515. * @param format defines the data format
  10516. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10517. * @param invertY defines if data must be stored with Y axis inverted
  10518. */
  10519. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10520. /**
  10521. * Update a raw cube texture
  10522. * @param texture defines the texture to udpdate
  10523. * @param data defines the data to store
  10524. * @param format defines the data format
  10525. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10526. * @param invertY defines if data must be stored with Y axis inverted
  10527. * @param compression defines the compression used (null by default)
  10528. */
  10529. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10530. /**
  10531. * Update a raw cube texture
  10532. * @param texture defines the texture to udpdate
  10533. * @param data defines the data to store
  10534. * @param format defines the data format
  10535. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10536. * @param invertY defines if data must be stored with Y axis inverted
  10537. * @param compression defines the compression used (null by default)
  10538. * @param level defines which level of the texture to update
  10539. */
  10540. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10541. /**
  10542. * Creates a new raw cube texture from a specified url
  10543. * @param url defines the url where the data is located
  10544. * @param scene defines the current scene
  10545. * @param size defines the size of the textures
  10546. * @param format defines the format of the data
  10547. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10548. * @param noMipmap defines if the engine should avoid generating the mip levels
  10549. * @param callback defines a callback used to extract texture data from loaded data
  10550. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10551. * @param onLoad defines a callback called when texture is loaded
  10552. * @param onError defines a callback called if there is an error
  10553. * @returns the cube texture as an InternalTexture
  10554. */
  10555. 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;
  10556. /**
  10557. * Creates a new raw cube texture from a specified url
  10558. * @param url defines the url where the data is located
  10559. * @param scene defines the current scene
  10560. * @param size defines the size of the textures
  10561. * @param format defines the format of the data
  10562. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10563. * @param noMipmap defines if the engine should avoid generating the mip levels
  10564. * @param callback defines a callback used to extract texture data from loaded data
  10565. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10566. * @param onLoad defines a callback called when texture is loaded
  10567. * @param onError defines a callback called if there is an error
  10568. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10569. * @param invertY defines if data must be stored with Y axis inverted
  10570. * @returns the cube texture as an InternalTexture
  10571. */
  10572. 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;
  10573. /**
  10574. * Creates a new raw 3D texture
  10575. * @param data defines the data used to create the texture
  10576. * @param width defines the width of the texture
  10577. * @param height defines the height of the texture
  10578. * @param depth defines the depth of the texture
  10579. * @param format defines the format of the texture
  10580. * @param generateMipMaps defines if the engine must generate mip levels
  10581. * @param invertY defines if data must be stored with Y axis inverted
  10582. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10583. * @param compression defines the compressed used (can be null)
  10584. * @param textureType defines the compressed used (can be null)
  10585. * @returns a new raw 3D texture (stored in an InternalTexture)
  10586. */
  10587. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10588. /**
  10589. * Update a raw 3D texture
  10590. * @param texture defines the texture to update
  10591. * @param data defines the data to store
  10592. * @param format defines the data format
  10593. * @param invertY defines if data must be stored with Y axis inverted
  10594. */
  10595. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10596. /**
  10597. * Update a raw 3D texture
  10598. * @param texture defines the texture to update
  10599. * @param data defines the data to store
  10600. * @param format defines the data format
  10601. * @param invertY defines if data must be stored with Y axis inverted
  10602. * @param compression defines the used compression (can be null)
  10603. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10604. */
  10605. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10606. /**
  10607. * Creates a new raw 2D array texture
  10608. * @param data defines the data used to create the texture
  10609. * @param width defines the width of the texture
  10610. * @param height defines the height of the texture
  10611. * @param depth defines the number of layers of the texture
  10612. * @param format defines the format of the texture
  10613. * @param generateMipMaps defines if the engine must generate mip levels
  10614. * @param invertY defines if data must be stored with Y axis inverted
  10615. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10616. * @param compression defines the compressed used (can be null)
  10617. * @param textureType defines the compressed used (can be null)
  10618. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10619. */
  10620. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10621. /**
  10622. * Update a raw 2D array texture
  10623. * @param texture defines the texture to update
  10624. * @param data defines the data to store
  10625. * @param format defines the data format
  10626. * @param invertY defines if data must be stored with Y axis inverted
  10627. */
  10628. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10629. /**
  10630. * Update a raw 2D array texture
  10631. * @param texture defines the texture to update
  10632. * @param data defines the data to store
  10633. * @param format defines the data format
  10634. * @param invertY defines if data must be stored with Y axis inverted
  10635. * @param compression defines the used compression (can be null)
  10636. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10637. */
  10638. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10639. }
  10640. }
  10641. declare module BABYLON {
  10642. /**
  10643. * Raw texture can help creating a texture directly from an array of data.
  10644. * This can be super useful if you either get the data from an uncompressed source or
  10645. * if you wish to create your texture pixel by pixel.
  10646. */
  10647. export class RawTexture extends Texture {
  10648. /**
  10649. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10650. */
  10651. format: number;
  10652. private _engine;
  10653. /**
  10654. * Instantiates a new RawTexture.
  10655. * Raw texture can help creating a texture directly from an array of data.
  10656. * This can be super useful if you either get the data from an uncompressed source or
  10657. * if you wish to create your texture pixel by pixel.
  10658. * @param data define the array of data to use to create the texture
  10659. * @param width define the width of the texture
  10660. * @param height define the height of the texture
  10661. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10662. * @param scene define the scene the texture belongs to
  10663. * @param generateMipMaps define whether mip maps should be generated or not
  10664. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10665. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10666. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10667. */
  10668. constructor(data: ArrayBufferView, width: number, height: number,
  10669. /**
  10670. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10671. */
  10672. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10673. /**
  10674. * Updates the texture underlying data.
  10675. * @param data Define the new data of the texture
  10676. */
  10677. update(data: ArrayBufferView): void;
  10678. /**
  10679. * Creates a luminance texture from some data.
  10680. * @param data Define the texture data
  10681. * @param width Define the width of the texture
  10682. * @param height Define the height of the texture
  10683. * @param scene Define the scene the texture belongs to
  10684. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10685. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10686. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10687. * @returns the luminance texture
  10688. */
  10689. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10690. /**
  10691. * Creates a luminance alpha texture from some data.
  10692. * @param data Define the texture data
  10693. * @param width Define the width of the texture
  10694. * @param height Define the height of the texture
  10695. * @param scene Define the scene the texture belongs to
  10696. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10697. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10698. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10699. * @returns the luminance alpha texture
  10700. */
  10701. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10702. /**
  10703. * Creates an alpha texture from some data.
  10704. * @param data Define the texture data
  10705. * @param width Define the width of the texture
  10706. * @param height Define the height of the texture
  10707. * @param scene Define the scene the texture belongs to
  10708. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10709. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10710. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10711. * @returns the alpha texture
  10712. */
  10713. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10714. /**
  10715. * Creates a RGB texture from some data.
  10716. * @param data Define the texture data
  10717. * @param width Define the width of the texture
  10718. * @param height Define the height of the texture
  10719. * @param scene Define the scene the texture belongs to
  10720. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10721. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10722. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10723. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10724. * @returns the RGB alpha texture
  10725. */
  10726. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10727. /**
  10728. * Creates a RGBA texture from some data.
  10729. * @param data Define the texture data
  10730. * @param width Define the width of the texture
  10731. * @param height Define the height of the texture
  10732. * @param scene Define the scene the texture belongs to
  10733. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10734. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10735. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10736. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10737. * @returns the RGBA texture
  10738. */
  10739. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10740. /**
  10741. * Creates a R texture from some data.
  10742. * @param data Define the texture data
  10743. * @param width Define the width of the texture
  10744. * @param height Define the height of the texture
  10745. * @param scene Define the scene the texture belongs to
  10746. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10747. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10748. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10749. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10750. * @returns the R texture
  10751. */
  10752. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10753. }
  10754. }
  10755. declare module BABYLON {
  10756. interface AbstractScene {
  10757. /**
  10758. * The list of procedural textures added to the scene
  10759. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10760. */
  10761. proceduralTextures: Array<ProceduralTexture>;
  10762. }
  10763. /**
  10764. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10765. * in a given scene.
  10766. */
  10767. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10768. /**
  10769. * The component name helpfull to identify the component in the list of scene components.
  10770. */
  10771. readonly name: string;
  10772. /**
  10773. * The scene the component belongs to.
  10774. */
  10775. scene: Scene;
  10776. /**
  10777. * Creates a new instance of the component for the given scene
  10778. * @param scene Defines the scene to register the component in
  10779. */
  10780. constructor(scene: Scene);
  10781. /**
  10782. * Registers the component in a given scene
  10783. */
  10784. register(): void;
  10785. /**
  10786. * Rebuilds the elements related to this component in case of
  10787. * context lost for instance.
  10788. */
  10789. rebuild(): void;
  10790. /**
  10791. * Disposes the component and the associated ressources.
  10792. */
  10793. dispose(): void;
  10794. private _beforeClear;
  10795. }
  10796. }
  10797. declare module BABYLON {
  10798. interface ThinEngine {
  10799. /**
  10800. * Creates a new render target cube texture
  10801. * @param size defines the size of the texture
  10802. * @param options defines the options used to create the texture
  10803. * @returns a new render target cube texture stored in an InternalTexture
  10804. */
  10805. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10806. }
  10807. }
  10808. declare module BABYLON {
  10809. /** @hidden */
  10810. export var proceduralVertexShader: {
  10811. name: string;
  10812. shader: string;
  10813. };
  10814. }
  10815. declare module BABYLON {
  10816. /**
  10817. * 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.
  10818. * This is the base class of any Procedural texture and contains most of the shareable code.
  10819. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10820. */
  10821. export class ProceduralTexture extends Texture {
  10822. isCube: boolean;
  10823. /**
  10824. * Define if the texture is enabled or not (disabled texture will not render)
  10825. */
  10826. isEnabled: boolean;
  10827. /**
  10828. * Define if the texture must be cleared before rendering (default is true)
  10829. */
  10830. autoClear: boolean;
  10831. /**
  10832. * Callback called when the texture is generated
  10833. */
  10834. onGenerated: () => void;
  10835. /**
  10836. * Event raised when the texture is generated
  10837. */
  10838. onGeneratedObservable: Observable<ProceduralTexture>;
  10839. /** @hidden */
  10840. _generateMipMaps: boolean;
  10841. /** @hidden **/
  10842. _effect: Effect;
  10843. /** @hidden */
  10844. _textures: {
  10845. [key: string]: Texture;
  10846. };
  10847. /** @hidden */
  10848. protected _fallbackTexture: Nullable<Texture>;
  10849. private _size;
  10850. private _currentRefreshId;
  10851. private _frameId;
  10852. private _refreshRate;
  10853. private _vertexBuffers;
  10854. private _indexBuffer;
  10855. private _uniforms;
  10856. private _samplers;
  10857. private _fragment;
  10858. private _floats;
  10859. private _ints;
  10860. private _floatsArrays;
  10861. private _colors3;
  10862. private _colors4;
  10863. private _vectors2;
  10864. private _vectors3;
  10865. private _matrices;
  10866. private _fallbackTextureUsed;
  10867. private _engine;
  10868. private _cachedDefines;
  10869. private _contentUpdateId;
  10870. private _contentData;
  10871. /**
  10872. * Instantiates a new procedural texture.
  10873. * 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.
  10874. * This is the base class of any Procedural texture and contains most of the shareable code.
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10876. * @param name Define the name of the texture
  10877. * @param size Define the size of the texture to create
  10878. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10879. * @param scene Define the scene the texture belongs to
  10880. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10881. * @param generateMipMaps Define if the texture should creates mip maps or not
  10882. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10883. */
  10884. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10885. /**
  10886. * The effect that is created when initializing the post process.
  10887. * @returns The created effect corresponding the the postprocess.
  10888. */
  10889. getEffect(): Effect;
  10890. /**
  10891. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10892. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10893. */
  10894. getContent(): Nullable<ArrayBufferView>;
  10895. private _createIndexBuffer;
  10896. /** @hidden */
  10897. _rebuild(): void;
  10898. /**
  10899. * Resets the texture in order to recreate its associated resources.
  10900. * This can be called in case of context loss
  10901. */
  10902. reset(): void;
  10903. protected _getDefines(): string;
  10904. /**
  10905. * Is the texture ready to be used ? (rendered at least once)
  10906. * @returns true if ready, otherwise, false.
  10907. */
  10908. isReady(): boolean;
  10909. /**
  10910. * Resets the refresh counter of the texture and start bak from scratch.
  10911. * Could be useful to regenerate the texture if it is setup to render only once.
  10912. */
  10913. resetRefreshCounter(): void;
  10914. /**
  10915. * Set the fragment shader to use in order to render the texture.
  10916. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10917. */
  10918. setFragment(fragment: any): void;
  10919. /**
  10920. * Define the refresh rate of the texture or the rendering frequency.
  10921. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10922. */
  10923. get refreshRate(): number;
  10924. set refreshRate(value: number);
  10925. /** @hidden */
  10926. _shouldRender(): boolean;
  10927. /**
  10928. * Get the size the texture is rendering at.
  10929. * @returns the size (texture is always squared)
  10930. */
  10931. getRenderSize(): number;
  10932. /**
  10933. * Resize the texture to new value.
  10934. * @param size Define the new size the texture should have
  10935. * @param generateMipMaps Define whether the new texture should create mip maps
  10936. */
  10937. resize(size: number, generateMipMaps: boolean): void;
  10938. private _checkUniform;
  10939. /**
  10940. * Set a texture in the shader program used to render.
  10941. * @param name Define the name of the uniform samplers as defined in the shader
  10942. * @param texture Define the texture to bind to this sampler
  10943. * @return the texture itself allowing "fluent" like uniform updates
  10944. */
  10945. setTexture(name: string, texture: Texture): ProceduralTexture;
  10946. /**
  10947. * Set a float in the shader.
  10948. * @param name Define the name of the uniform as defined in the shader
  10949. * @param value Define the value to give to the uniform
  10950. * @return the texture itself allowing "fluent" like uniform updates
  10951. */
  10952. setFloat(name: string, value: number): ProceduralTexture;
  10953. /**
  10954. * Set a int in the shader.
  10955. * @param name Define the name of the uniform as defined in the shader
  10956. * @param value Define the value to give to the uniform
  10957. * @return the texture itself allowing "fluent" like uniform updates
  10958. */
  10959. setInt(name: string, value: number): ProceduralTexture;
  10960. /**
  10961. * Set an array of floats in the shader.
  10962. * @param name Define the name of the uniform as defined in the shader
  10963. * @param value Define the value to give to the uniform
  10964. * @return the texture itself allowing "fluent" like uniform updates
  10965. */
  10966. setFloats(name: string, value: number[]): ProceduralTexture;
  10967. /**
  10968. * Set a vec3 in the shader from a Color3.
  10969. * @param name Define the name of the uniform as defined in the shader
  10970. * @param value Define the value to give to the uniform
  10971. * @return the texture itself allowing "fluent" like uniform updates
  10972. */
  10973. setColor3(name: string, value: Color3): ProceduralTexture;
  10974. /**
  10975. * Set a vec4 in the shader from a Color4.
  10976. * @param name Define the name of the uniform as defined in the shader
  10977. * @param value Define the value to give to the uniform
  10978. * @return the texture itself allowing "fluent" like uniform updates
  10979. */
  10980. setColor4(name: string, value: Color4): ProceduralTexture;
  10981. /**
  10982. * Set a vec2 in the shader from a Vector2.
  10983. * @param name Define the name of the uniform as defined in the shader
  10984. * @param value Define the value to give to the uniform
  10985. * @return the texture itself allowing "fluent" like uniform updates
  10986. */
  10987. setVector2(name: string, value: Vector2): ProceduralTexture;
  10988. /**
  10989. * Set a vec3 in the shader from a Vector3.
  10990. * @param name Define the name of the uniform as defined in the shader
  10991. * @param value Define the value to give to the uniform
  10992. * @return the texture itself allowing "fluent" like uniform updates
  10993. */
  10994. setVector3(name: string, value: Vector3): ProceduralTexture;
  10995. /**
  10996. * Set a mat4 in the shader from a MAtrix.
  10997. * @param name Define the name of the uniform as defined in the shader
  10998. * @param value Define the value to give to the uniform
  10999. * @return the texture itself allowing "fluent" like uniform updates
  11000. */
  11001. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11002. /**
  11003. * Render the texture to its associated render target.
  11004. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11005. */
  11006. render(useCameraPostProcess?: boolean): void;
  11007. /**
  11008. * Clone the texture.
  11009. * @returns the cloned texture
  11010. */
  11011. clone(): ProceduralTexture;
  11012. /**
  11013. * Dispose the texture and release its asoociated resources.
  11014. */
  11015. dispose(): void;
  11016. }
  11017. }
  11018. declare module BABYLON {
  11019. /**
  11020. * This represents the base class for particle system in Babylon.
  11021. * 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.
  11022. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11023. * @example https://doc.babylonjs.com/babylon101/particles
  11024. */
  11025. export class BaseParticleSystem {
  11026. /**
  11027. * Source color is added to the destination color without alpha affecting the result
  11028. */
  11029. static BLENDMODE_ONEONE: number;
  11030. /**
  11031. * Blend current color and particle color using particle’s alpha
  11032. */
  11033. static BLENDMODE_STANDARD: number;
  11034. /**
  11035. * Add current color and particle color multiplied by particle’s alpha
  11036. */
  11037. static BLENDMODE_ADD: number;
  11038. /**
  11039. * Multiply current color with particle color
  11040. */
  11041. static BLENDMODE_MULTIPLY: number;
  11042. /**
  11043. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11044. */
  11045. static BLENDMODE_MULTIPLYADD: number;
  11046. /**
  11047. * List of animations used by the particle system.
  11048. */
  11049. animations: Animation[];
  11050. /**
  11051. * Gets or sets the unique id of the particle system
  11052. */
  11053. uniqueId: number;
  11054. /**
  11055. * The id of the Particle system.
  11056. */
  11057. id: string;
  11058. /**
  11059. * The friendly name of the Particle system.
  11060. */
  11061. name: string;
  11062. /**
  11063. * Snippet ID if the particle system was created from the snippet server
  11064. */
  11065. snippetId: string;
  11066. /**
  11067. * The rendering group used by the Particle system to chose when to render.
  11068. */
  11069. renderingGroupId: number;
  11070. /**
  11071. * The emitter represents the Mesh or position we are attaching the particle system to.
  11072. */
  11073. emitter: Nullable<AbstractMesh | Vector3>;
  11074. /**
  11075. * The maximum number of particles to emit per frame
  11076. */
  11077. emitRate: number;
  11078. /**
  11079. * If you want to launch only a few particles at once, that can be done, as well.
  11080. */
  11081. manualEmitCount: number;
  11082. /**
  11083. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11084. */
  11085. updateSpeed: number;
  11086. /**
  11087. * The amount of time the particle system is running (depends of the overall update speed).
  11088. */
  11089. targetStopDuration: number;
  11090. /**
  11091. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11092. */
  11093. disposeOnStop: boolean;
  11094. /**
  11095. * Minimum power of emitting particles.
  11096. */
  11097. minEmitPower: number;
  11098. /**
  11099. * Maximum power of emitting particles.
  11100. */
  11101. maxEmitPower: number;
  11102. /**
  11103. * Minimum life time of emitting particles.
  11104. */
  11105. minLifeTime: number;
  11106. /**
  11107. * Maximum life time of emitting particles.
  11108. */
  11109. maxLifeTime: number;
  11110. /**
  11111. * Minimum Size of emitting particles.
  11112. */
  11113. minSize: number;
  11114. /**
  11115. * Maximum Size of emitting particles.
  11116. */
  11117. maxSize: number;
  11118. /**
  11119. * Minimum scale of emitting particles on X axis.
  11120. */
  11121. minScaleX: number;
  11122. /**
  11123. * Maximum scale of emitting particles on X axis.
  11124. */
  11125. maxScaleX: number;
  11126. /**
  11127. * Minimum scale of emitting particles on Y axis.
  11128. */
  11129. minScaleY: number;
  11130. /**
  11131. * Maximum scale of emitting particles on Y axis.
  11132. */
  11133. maxScaleY: number;
  11134. /**
  11135. * Gets or sets the minimal initial rotation in radians.
  11136. */
  11137. minInitialRotation: number;
  11138. /**
  11139. * Gets or sets the maximal initial rotation in radians.
  11140. */
  11141. maxInitialRotation: number;
  11142. /**
  11143. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11144. */
  11145. minAngularSpeed: number;
  11146. /**
  11147. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11148. */
  11149. maxAngularSpeed: number;
  11150. /**
  11151. * The texture used to render each particle. (this can be a spritesheet)
  11152. */
  11153. particleTexture: Nullable<Texture>;
  11154. /**
  11155. * The layer mask we are rendering the particles through.
  11156. */
  11157. layerMask: number;
  11158. /**
  11159. * This can help using your own shader to render the particle system.
  11160. * The according effect will be created
  11161. */
  11162. customShader: any;
  11163. /**
  11164. * By default particle system starts as soon as they are created. This prevents the
  11165. * automatic start to happen and let you decide when to start emitting particles.
  11166. */
  11167. preventAutoStart: boolean;
  11168. private _noiseTexture;
  11169. /**
  11170. * Gets or sets a texture used to add random noise to particle positions
  11171. */
  11172. get noiseTexture(): Nullable<ProceduralTexture>;
  11173. set noiseTexture(value: Nullable<ProceduralTexture>);
  11174. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11175. noiseStrength: Vector3;
  11176. /**
  11177. * Callback triggered when the particle animation is ending.
  11178. */
  11179. onAnimationEnd: Nullable<() => void>;
  11180. /**
  11181. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11182. */
  11183. blendMode: number;
  11184. /**
  11185. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11186. * to override the particles.
  11187. */
  11188. forceDepthWrite: boolean;
  11189. /** 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 */
  11190. preWarmCycles: number;
  11191. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11192. preWarmStepOffset: number;
  11193. /**
  11194. * 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)
  11195. */
  11196. spriteCellChangeSpeed: number;
  11197. /**
  11198. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11199. */
  11200. startSpriteCellID: number;
  11201. /**
  11202. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11203. */
  11204. endSpriteCellID: number;
  11205. /**
  11206. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11207. */
  11208. spriteCellWidth: number;
  11209. /**
  11210. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11211. */
  11212. spriteCellHeight: number;
  11213. /**
  11214. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11215. */
  11216. spriteRandomStartCell: boolean;
  11217. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11218. translationPivot: Vector2;
  11219. /** @hidden */
  11220. protected _isAnimationSheetEnabled: boolean;
  11221. /**
  11222. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11223. */
  11224. beginAnimationOnStart: boolean;
  11225. /**
  11226. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11227. */
  11228. beginAnimationFrom: number;
  11229. /**
  11230. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11231. */
  11232. beginAnimationTo: number;
  11233. /**
  11234. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11235. */
  11236. beginAnimationLoop: boolean;
  11237. /**
  11238. * Gets or sets a world offset applied to all particles
  11239. */
  11240. worldOffset: Vector3;
  11241. /**
  11242. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11243. */
  11244. get isAnimationSheetEnabled(): boolean;
  11245. set isAnimationSheetEnabled(value: boolean);
  11246. /**
  11247. * Get hosting scene
  11248. * @returns the scene
  11249. */
  11250. getScene(): Scene;
  11251. /**
  11252. * You can use gravity if you want to give an orientation to your particles.
  11253. */
  11254. gravity: Vector3;
  11255. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11256. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11257. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11258. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11259. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11260. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11261. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11262. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11263. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11264. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11265. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11266. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11267. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11268. /**
  11269. * Defines the delay in milliseconds before starting the system (0 by default)
  11270. */
  11271. startDelay: number;
  11272. /**
  11273. * Gets the current list of drag gradients.
  11274. * You must use addDragGradient and removeDragGradient to udpate this list
  11275. * @returns the list of drag gradients
  11276. */
  11277. getDragGradients(): Nullable<Array<FactorGradient>>;
  11278. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11279. limitVelocityDamping: number;
  11280. /**
  11281. * Gets the current list of limit velocity gradients.
  11282. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11283. * @returns the list of limit velocity gradients
  11284. */
  11285. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11286. /**
  11287. * Gets the current list of color gradients.
  11288. * You must use addColorGradient and removeColorGradient to udpate this list
  11289. * @returns the list of color gradients
  11290. */
  11291. getColorGradients(): Nullable<Array<ColorGradient>>;
  11292. /**
  11293. * Gets the current list of size gradients.
  11294. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11295. * @returns the list of size gradients
  11296. */
  11297. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11298. /**
  11299. * Gets the current list of color remap gradients.
  11300. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11301. * @returns the list of color remap gradients
  11302. */
  11303. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11304. /**
  11305. * Gets the current list of alpha remap gradients.
  11306. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11307. * @returns the list of alpha remap gradients
  11308. */
  11309. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11310. /**
  11311. * Gets the current list of life time gradients.
  11312. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11313. * @returns the list of life time gradients
  11314. */
  11315. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11316. /**
  11317. * Gets the current list of angular speed gradients.
  11318. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11319. * @returns the list of angular speed gradients
  11320. */
  11321. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11322. /**
  11323. * Gets the current list of velocity gradients.
  11324. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11325. * @returns the list of velocity gradients
  11326. */
  11327. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11328. /**
  11329. * Gets the current list of start size gradients.
  11330. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11331. * @returns the list of start size gradients
  11332. */
  11333. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11334. /**
  11335. * Gets the current list of emit rate gradients.
  11336. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11337. * @returns the list of emit rate gradients
  11338. */
  11339. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11340. /**
  11341. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11342. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11343. */
  11344. get direction1(): Vector3;
  11345. set direction1(value: Vector3);
  11346. /**
  11347. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11348. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11349. */
  11350. get direction2(): Vector3;
  11351. set direction2(value: Vector3);
  11352. /**
  11353. * 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.
  11354. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11355. */
  11356. get minEmitBox(): Vector3;
  11357. set minEmitBox(value: Vector3);
  11358. /**
  11359. * 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.
  11360. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11361. */
  11362. get maxEmitBox(): Vector3;
  11363. set maxEmitBox(value: Vector3);
  11364. /**
  11365. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11366. */
  11367. color1: Color4;
  11368. /**
  11369. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11370. */
  11371. color2: Color4;
  11372. /**
  11373. * Color the particle will have at the end of its lifetime
  11374. */
  11375. colorDead: Color4;
  11376. /**
  11377. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11378. */
  11379. textureMask: Color4;
  11380. /**
  11381. * The particle emitter type defines the emitter used by the particle system.
  11382. * It can be for example box, sphere, or cone...
  11383. */
  11384. particleEmitterType: IParticleEmitterType;
  11385. /** @hidden */
  11386. _isSubEmitter: boolean;
  11387. /**
  11388. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11389. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11390. */
  11391. billboardMode: number;
  11392. protected _isBillboardBased: boolean;
  11393. /**
  11394. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11395. */
  11396. get isBillboardBased(): boolean;
  11397. set isBillboardBased(value: boolean);
  11398. /**
  11399. * The scene the particle system belongs to.
  11400. */
  11401. protected _scene: Scene;
  11402. /**
  11403. * Local cache of defines for image processing.
  11404. */
  11405. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11406. /**
  11407. * Default configuration related to image processing available in the standard Material.
  11408. */
  11409. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11410. /**
  11411. * Gets the image processing configuration used either in this material.
  11412. */
  11413. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11414. /**
  11415. * Sets the Default image processing configuration used either in the this material.
  11416. *
  11417. * If sets to null, the scene one is in use.
  11418. */
  11419. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11420. /**
  11421. * Attaches a new image processing configuration to the Standard Material.
  11422. * @param configuration
  11423. */
  11424. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11425. /** @hidden */
  11426. protected _reset(): void;
  11427. /** @hidden */
  11428. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11429. /**
  11430. * Instantiates a particle system.
  11431. * 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.
  11432. * @param name The name of the particle system
  11433. */
  11434. constructor(name: string);
  11435. /**
  11436. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11437. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11438. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11439. * @returns the emitter
  11440. */
  11441. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11442. /**
  11443. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11444. * @param radius The radius of the hemisphere to emit from
  11445. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11446. * @returns the emitter
  11447. */
  11448. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11449. /**
  11450. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11451. * @param radius The radius of the sphere to emit from
  11452. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11453. * @returns the emitter
  11454. */
  11455. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11456. /**
  11457. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11458. * @param radius The radius of the sphere to emit from
  11459. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11460. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11461. * @returns the emitter
  11462. */
  11463. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11464. /**
  11465. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11466. * @param radius The radius of the emission cylinder
  11467. * @param height The height of the emission cylinder
  11468. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11469. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11470. * @returns the emitter
  11471. */
  11472. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11473. /**
  11474. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11475. * @param radius The radius of the cylinder to emit from
  11476. * @param height The height of the emission cylinder
  11477. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11478. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11479. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11480. * @returns the emitter
  11481. */
  11482. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11483. /**
  11484. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11485. * @param radius The radius of the cone to emit from
  11486. * @param angle The base angle of the cone
  11487. * @returns the emitter
  11488. */
  11489. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11490. /**
  11491. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11492. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11493. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11494. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11495. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11496. * @returns the emitter
  11497. */
  11498. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11499. }
  11500. }
  11501. declare module BABYLON {
  11502. /**
  11503. * Type of sub emitter
  11504. */
  11505. export enum SubEmitterType {
  11506. /**
  11507. * Attached to the particle over it's lifetime
  11508. */
  11509. ATTACHED = 0,
  11510. /**
  11511. * Created when the particle dies
  11512. */
  11513. END = 1
  11514. }
  11515. /**
  11516. * Sub emitter class used to emit particles from an existing particle
  11517. */
  11518. export class SubEmitter {
  11519. /**
  11520. * the particle system to be used by the sub emitter
  11521. */
  11522. particleSystem: ParticleSystem;
  11523. /**
  11524. * Type of the submitter (Default: END)
  11525. */
  11526. type: SubEmitterType;
  11527. /**
  11528. * 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)
  11529. * Note: This only is supported when using an emitter of type Mesh
  11530. */
  11531. inheritDirection: boolean;
  11532. /**
  11533. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11534. */
  11535. inheritedVelocityAmount: number;
  11536. /**
  11537. * Creates a sub emitter
  11538. * @param particleSystem the particle system to be used by the sub emitter
  11539. */
  11540. constructor(
  11541. /**
  11542. * the particle system to be used by the sub emitter
  11543. */
  11544. particleSystem: ParticleSystem);
  11545. /**
  11546. * Clones the sub emitter
  11547. * @returns the cloned sub emitter
  11548. */
  11549. clone(): SubEmitter;
  11550. /**
  11551. * Serialize current object to a JSON object
  11552. * @returns the serialized object
  11553. */
  11554. serialize(): any;
  11555. /** @hidden */
  11556. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11557. /**
  11558. * Creates a new SubEmitter from a serialized JSON version
  11559. * @param serializationObject defines the JSON object to read from
  11560. * @param scene defines the hosting scene
  11561. * @param rootUrl defines the rootUrl for data loading
  11562. * @returns a new SubEmitter
  11563. */
  11564. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11565. /** Release associated resources */
  11566. dispose(): void;
  11567. }
  11568. }
  11569. declare module BABYLON {
  11570. /** @hidden */
  11571. export var imageProcessingDeclaration: {
  11572. name: string;
  11573. shader: string;
  11574. };
  11575. }
  11576. declare module BABYLON {
  11577. /** @hidden */
  11578. export var imageProcessingFunctions: {
  11579. name: string;
  11580. shader: string;
  11581. };
  11582. }
  11583. declare module BABYLON {
  11584. /** @hidden */
  11585. export var particlesPixelShader: {
  11586. name: string;
  11587. shader: string;
  11588. };
  11589. }
  11590. declare module BABYLON {
  11591. /** @hidden */
  11592. export var particlesVertexShader: {
  11593. name: string;
  11594. shader: string;
  11595. };
  11596. }
  11597. declare module BABYLON {
  11598. /**
  11599. * This represents a particle system in Babylon.
  11600. * 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.
  11601. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11602. * @example https://doc.babylonjs.com/babylon101/particles
  11603. */
  11604. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11605. /**
  11606. * Billboard mode will only apply to Y axis
  11607. */
  11608. static readonly BILLBOARDMODE_Y: number;
  11609. /**
  11610. * Billboard mode will apply to all axes
  11611. */
  11612. static readonly BILLBOARDMODE_ALL: number;
  11613. /**
  11614. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11615. */
  11616. static readonly BILLBOARDMODE_STRETCHED: number;
  11617. /**
  11618. * This function can be defined to provide custom update for active particles.
  11619. * This function will be called instead of regular update (age, position, color, etc.).
  11620. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11621. */
  11622. updateFunction: (particles: Particle[]) => void;
  11623. private _emitterWorldMatrix;
  11624. /**
  11625. * This function can be defined to specify initial direction for every new particle.
  11626. * It by default use the emitterType defined function
  11627. */
  11628. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11629. /**
  11630. * This function can be defined to specify initial position for every new particle.
  11631. * It by default use the emitterType defined function
  11632. */
  11633. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11634. /**
  11635. * @hidden
  11636. */
  11637. _inheritedVelocityOffset: Vector3;
  11638. /**
  11639. * An event triggered when the system is disposed
  11640. */
  11641. onDisposeObservable: Observable<ParticleSystem>;
  11642. private _onDisposeObserver;
  11643. /**
  11644. * Sets a callback that will be triggered when the system is disposed
  11645. */
  11646. set onDispose(callback: () => void);
  11647. private _particles;
  11648. private _epsilon;
  11649. private _capacity;
  11650. private _stockParticles;
  11651. private _newPartsExcess;
  11652. private _vertexData;
  11653. private _vertexBuffer;
  11654. private _vertexBuffers;
  11655. private _spriteBuffer;
  11656. private _indexBuffer;
  11657. private _effect;
  11658. private _customEffect;
  11659. private _cachedDefines;
  11660. private _scaledColorStep;
  11661. private _colorDiff;
  11662. private _scaledDirection;
  11663. private _scaledGravity;
  11664. private _currentRenderId;
  11665. private _alive;
  11666. private _useInstancing;
  11667. private _started;
  11668. private _stopped;
  11669. private _actualFrame;
  11670. private _scaledUpdateSpeed;
  11671. private _vertexBufferSize;
  11672. /** @hidden */
  11673. _currentEmitRateGradient: Nullable<FactorGradient>;
  11674. /** @hidden */
  11675. _currentEmitRate1: number;
  11676. /** @hidden */
  11677. _currentEmitRate2: number;
  11678. /** @hidden */
  11679. _currentStartSizeGradient: Nullable<FactorGradient>;
  11680. /** @hidden */
  11681. _currentStartSize1: number;
  11682. /** @hidden */
  11683. _currentStartSize2: number;
  11684. private readonly _rawTextureWidth;
  11685. private _rampGradientsTexture;
  11686. private _useRampGradients;
  11687. /** Gets or sets a boolean indicating that ramp gradients must be used
  11688. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11689. */
  11690. get useRampGradients(): boolean;
  11691. set useRampGradients(value: boolean);
  11692. /**
  11693. * 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.
  11694. * 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: [])
  11695. */
  11696. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11697. private _subEmitters;
  11698. /**
  11699. * @hidden
  11700. * If the particle systems emitter should be disposed when the particle system is disposed
  11701. */
  11702. _disposeEmitterOnDispose: boolean;
  11703. /**
  11704. * The current active Sub-systems, this property is used by the root particle system only.
  11705. */
  11706. activeSubSystems: Array<ParticleSystem>;
  11707. /**
  11708. * Specifies if the particles are updated in emitter local space or world space
  11709. */
  11710. isLocal: boolean;
  11711. private _rootParticleSystem;
  11712. /**
  11713. * Gets the current list of active particles
  11714. */
  11715. get particles(): Particle[];
  11716. /**
  11717. * Gets the number of particles active at the same time.
  11718. * @returns The number of active particles.
  11719. */
  11720. getActiveCount(): number;
  11721. /**
  11722. * Returns the string "ParticleSystem"
  11723. * @returns a string containing the class name
  11724. */
  11725. getClassName(): string;
  11726. /**
  11727. * Gets a boolean indicating that the system is stopping
  11728. * @returns true if the system is currently stopping
  11729. */
  11730. isStopping(): boolean;
  11731. /**
  11732. * Instantiates a particle system.
  11733. * 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.
  11734. * @param name The name of the particle system
  11735. * @param capacity The max number of particles alive at the same time
  11736. * @param scene The scene the particle system belongs to
  11737. * @param customEffect a custom effect used to change the way particles are rendered by default
  11738. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11739. * @param epsilon Offset used to render the particles
  11740. */
  11741. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11742. private _addFactorGradient;
  11743. private _removeFactorGradient;
  11744. /**
  11745. * Adds a new life time gradient
  11746. * @param gradient defines the gradient to use (between 0 and 1)
  11747. * @param factor defines the life time factor to affect to the specified gradient
  11748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11749. * @returns the current particle system
  11750. */
  11751. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11752. /**
  11753. * Remove a specific life time gradient
  11754. * @param gradient defines the gradient to remove
  11755. * @returns the current particle system
  11756. */
  11757. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11758. /**
  11759. * Adds a new size gradient
  11760. * @param gradient defines the gradient to use (between 0 and 1)
  11761. * @param factor defines the size factor to affect to the specified gradient
  11762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11763. * @returns the current particle system
  11764. */
  11765. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11766. /**
  11767. * Remove a specific size gradient
  11768. * @param gradient defines the gradient to remove
  11769. * @returns the current particle system
  11770. */
  11771. removeSizeGradient(gradient: number): IParticleSystem;
  11772. /**
  11773. * Adds a new color remap gradient
  11774. * @param gradient defines the gradient to use (between 0 and 1)
  11775. * @param min defines the color remap minimal range
  11776. * @param max defines the color remap maximal range
  11777. * @returns the current particle system
  11778. */
  11779. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11780. /**
  11781. * Remove a specific color remap gradient
  11782. * @param gradient defines the gradient to remove
  11783. * @returns the current particle system
  11784. */
  11785. removeColorRemapGradient(gradient: number): IParticleSystem;
  11786. /**
  11787. * Adds a new alpha remap gradient
  11788. * @param gradient defines the gradient to use (between 0 and 1)
  11789. * @param min defines the alpha remap minimal range
  11790. * @param max defines the alpha remap maximal range
  11791. * @returns the current particle system
  11792. */
  11793. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11794. /**
  11795. * Remove a specific alpha remap gradient
  11796. * @param gradient defines the gradient to remove
  11797. * @returns the current particle system
  11798. */
  11799. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11800. /**
  11801. * Adds a new angular speed gradient
  11802. * @param gradient defines the gradient to use (between 0 and 1)
  11803. * @param factor defines the angular speed to affect to the specified gradient
  11804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11805. * @returns the current particle system
  11806. */
  11807. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11808. /**
  11809. * Remove a specific angular speed gradient
  11810. * @param gradient defines the gradient to remove
  11811. * @returns the current particle system
  11812. */
  11813. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11814. /**
  11815. * Adds a new velocity gradient
  11816. * @param gradient defines the gradient to use (between 0 and 1)
  11817. * @param factor defines the velocity to affect to the specified gradient
  11818. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11819. * @returns the current particle system
  11820. */
  11821. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11822. /**
  11823. * Remove a specific velocity gradient
  11824. * @param gradient defines the gradient to remove
  11825. * @returns the current particle system
  11826. */
  11827. removeVelocityGradient(gradient: number): IParticleSystem;
  11828. /**
  11829. * Adds a new limit velocity gradient
  11830. * @param gradient defines the gradient to use (between 0 and 1)
  11831. * @param factor defines the limit velocity value to affect to the specified gradient
  11832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11833. * @returns the current particle system
  11834. */
  11835. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11836. /**
  11837. * Remove a specific limit velocity gradient
  11838. * @param gradient defines the gradient to remove
  11839. * @returns the current particle system
  11840. */
  11841. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11842. /**
  11843. * Adds a new drag gradient
  11844. * @param gradient defines the gradient to use (between 0 and 1)
  11845. * @param factor defines the drag value to affect to the specified gradient
  11846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11847. * @returns the current particle system
  11848. */
  11849. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11850. /**
  11851. * Remove a specific drag gradient
  11852. * @param gradient defines the gradient to remove
  11853. * @returns the current particle system
  11854. */
  11855. removeDragGradient(gradient: number): IParticleSystem;
  11856. /**
  11857. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11858. * @param gradient defines the gradient to use (between 0 and 1)
  11859. * @param factor defines the emit rate value to affect to the specified gradient
  11860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11861. * @returns the current particle system
  11862. */
  11863. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11864. /**
  11865. * Remove a specific emit rate gradient
  11866. * @param gradient defines the gradient to remove
  11867. * @returns the current particle system
  11868. */
  11869. removeEmitRateGradient(gradient: number): IParticleSystem;
  11870. /**
  11871. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11872. * @param gradient defines the gradient to use (between 0 and 1)
  11873. * @param factor defines the start size value to affect to the specified gradient
  11874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11875. * @returns the current particle system
  11876. */
  11877. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11878. /**
  11879. * Remove a specific start size gradient
  11880. * @param gradient defines the gradient to remove
  11881. * @returns the current particle system
  11882. */
  11883. removeStartSizeGradient(gradient: number): IParticleSystem;
  11884. private _createRampGradientTexture;
  11885. /**
  11886. * Gets the current list of ramp gradients.
  11887. * You must use addRampGradient and removeRampGradient to udpate this list
  11888. * @returns the list of ramp gradients
  11889. */
  11890. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11891. /** Force the system to rebuild all gradients that need to be resync */
  11892. forceRefreshGradients(): void;
  11893. private _syncRampGradientTexture;
  11894. /**
  11895. * Adds a new ramp gradient used to remap particle colors
  11896. * @param gradient defines the gradient to use (between 0 and 1)
  11897. * @param color defines the color to affect to the specified gradient
  11898. * @returns the current particle system
  11899. */
  11900. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11901. /**
  11902. * Remove a specific ramp gradient
  11903. * @param gradient defines the gradient to remove
  11904. * @returns the current particle system
  11905. */
  11906. removeRampGradient(gradient: number): ParticleSystem;
  11907. /**
  11908. * Adds a new color gradient
  11909. * @param gradient defines the gradient to use (between 0 and 1)
  11910. * @param color1 defines the color to affect to the specified gradient
  11911. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11912. * @returns this particle system
  11913. */
  11914. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11915. /**
  11916. * Remove a specific color gradient
  11917. * @param gradient defines the gradient to remove
  11918. * @returns this particle system
  11919. */
  11920. removeColorGradient(gradient: number): IParticleSystem;
  11921. private _fetchR;
  11922. protected _reset(): void;
  11923. private _resetEffect;
  11924. private _createVertexBuffers;
  11925. private _createIndexBuffer;
  11926. /**
  11927. * Gets the maximum number of particles active at the same time.
  11928. * @returns The max number of active particles.
  11929. */
  11930. getCapacity(): number;
  11931. /**
  11932. * Gets whether there are still active particles in the system.
  11933. * @returns True if it is alive, otherwise false.
  11934. */
  11935. isAlive(): boolean;
  11936. /**
  11937. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11938. * @returns True if it has been started, otherwise false.
  11939. */
  11940. isStarted(): boolean;
  11941. private _prepareSubEmitterInternalArray;
  11942. /**
  11943. * Starts the particle system and begins to emit
  11944. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11945. */
  11946. start(delay?: number): void;
  11947. /**
  11948. * Stops the particle system.
  11949. * @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.
  11950. */
  11951. stop(stopSubEmitters?: boolean): void;
  11952. /**
  11953. * Remove all active particles
  11954. */
  11955. reset(): void;
  11956. /**
  11957. * @hidden (for internal use only)
  11958. */
  11959. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11960. /**
  11961. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11962. * Its lifetime will start back at 0.
  11963. */
  11964. recycleParticle: (particle: Particle) => void;
  11965. private _stopSubEmitters;
  11966. private _createParticle;
  11967. private _removeFromRoot;
  11968. private _emitFromParticle;
  11969. private _update;
  11970. /** @hidden */
  11971. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11972. /** @hidden */
  11973. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11974. /** @hidden */
  11975. private _getEffect;
  11976. /**
  11977. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11978. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11979. */
  11980. animate(preWarmOnly?: boolean): void;
  11981. private _appendParticleVertices;
  11982. /**
  11983. * Rebuilds the particle system.
  11984. */
  11985. rebuild(): void;
  11986. /**
  11987. * Is this system ready to be used/rendered
  11988. * @return true if the system is ready
  11989. */
  11990. isReady(): boolean;
  11991. private _render;
  11992. /**
  11993. * Renders the particle system in its current state.
  11994. * @returns the current number of particles
  11995. */
  11996. render(): number;
  11997. /**
  11998. * Disposes the particle system and free the associated resources
  11999. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12000. */
  12001. dispose(disposeTexture?: boolean): void;
  12002. /**
  12003. * Clones the particle system.
  12004. * @param name The name of the cloned object
  12005. * @param newEmitter The new emitter to use
  12006. * @returns the cloned particle system
  12007. */
  12008. clone(name: string, newEmitter: any): ParticleSystem;
  12009. /**
  12010. * Serializes the particle system to a JSON object
  12011. * @param serializeTexture defines if the texture must be serialized as well
  12012. * @returns the JSON object
  12013. */
  12014. serialize(serializeTexture?: boolean): any;
  12015. /** @hidden */
  12016. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12017. /** @hidden */
  12018. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12019. /**
  12020. * Parses a JSON object to create a particle system.
  12021. * @param parsedParticleSystem The JSON object to parse
  12022. * @param scene The scene to create the particle system in
  12023. * @param rootUrl The root url to use to load external dependencies like texture
  12024. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12025. * @returns the Parsed particle system
  12026. */
  12027. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12028. }
  12029. }
  12030. declare module BABYLON {
  12031. /**
  12032. * A particle represents one of the element emitted by a particle system.
  12033. * This is mainly define by its coordinates, direction, velocity and age.
  12034. */
  12035. export class Particle {
  12036. /**
  12037. * The particle system the particle belongs to.
  12038. */
  12039. particleSystem: ParticleSystem;
  12040. private static _Count;
  12041. /**
  12042. * Unique ID of the particle
  12043. */
  12044. id: number;
  12045. /**
  12046. * The world position of the particle in the scene.
  12047. */
  12048. position: Vector3;
  12049. /**
  12050. * The world direction of the particle in the scene.
  12051. */
  12052. direction: Vector3;
  12053. /**
  12054. * The color of the particle.
  12055. */
  12056. color: Color4;
  12057. /**
  12058. * The color change of the particle per step.
  12059. */
  12060. colorStep: Color4;
  12061. /**
  12062. * Defines how long will the life of the particle be.
  12063. */
  12064. lifeTime: number;
  12065. /**
  12066. * The current age of the particle.
  12067. */
  12068. age: number;
  12069. /**
  12070. * The current size of the particle.
  12071. */
  12072. size: number;
  12073. /**
  12074. * The current scale of the particle.
  12075. */
  12076. scale: Vector2;
  12077. /**
  12078. * The current angle of the particle.
  12079. */
  12080. angle: number;
  12081. /**
  12082. * Defines how fast is the angle changing.
  12083. */
  12084. angularSpeed: number;
  12085. /**
  12086. * Defines the cell index used by the particle to be rendered from a sprite.
  12087. */
  12088. cellIndex: number;
  12089. /**
  12090. * The information required to support color remapping
  12091. */
  12092. remapData: Vector4;
  12093. /** @hidden */
  12094. _randomCellOffset?: number;
  12095. /** @hidden */
  12096. _initialDirection: Nullable<Vector3>;
  12097. /** @hidden */
  12098. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12099. /** @hidden */
  12100. _initialStartSpriteCellID: number;
  12101. /** @hidden */
  12102. _initialEndSpriteCellID: number;
  12103. /** @hidden */
  12104. _currentColorGradient: Nullable<ColorGradient>;
  12105. /** @hidden */
  12106. _currentColor1: Color4;
  12107. /** @hidden */
  12108. _currentColor2: Color4;
  12109. /** @hidden */
  12110. _currentSizeGradient: Nullable<FactorGradient>;
  12111. /** @hidden */
  12112. _currentSize1: number;
  12113. /** @hidden */
  12114. _currentSize2: number;
  12115. /** @hidden */
  12116. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12117. /** @hidden */
  12118. _currentAngularSpeed1: number;
  12119. /** @hidden */
  12120. _currentAngularSpeed2: number;
  12121. /** @hidden */
  12122. _currentVelocityGradient: Nullable<FactorGradient>;
  12123. /** @hidden */
  12124. _currentVelocity1: number;
  12125. /** @hidden */
  12126. _currentVelocity2: number;
  12127. /** @hidden */
  12128. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12129. /** @hidden */
  12130. _currentLimitVelocity1: number;
  12131. /** @hidden */
  12132. _currentLimitVelocity2: number;
  12133. /** @hidden */
  12134. _currentDragGradient: Nullable<FactorGradient>;
  12135. /** @hidden */
  12136. _currentDrag1: number;
  12137. /** @hidden */
  12138. _currentDrag2: number;
  12139. /** @hidden */
  12140. _randomNoiseCoordinates1: Vector3;
  12141. /** @hidden */
  12142. _randomNoiseCoordinates2: Vector3;
  12143. /** @hidden */
  12144. _localPosition?: Vector3;
  12145. /**
  12146. * Creates a new instance Particle
  12147. * @param particleSystem the particle system the particle belongs to
  12148. */
  12149. constructor(
  12150. /**
  12151. * The particle system the particle belongs to.
  12152. */
  12153. particleSystem: ParticleSystem);
  12154. private updateCellInfoFromSystem;
  12155. /**
  12156. * Defines how the sprite cell index is updated for the particle
  12157. */
  12158. updateCellIndex(): void;
  12159. /** @hidden */
  12160. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12161. /** @hidden */
  12162. _inheritParticleInfoToSubEmitters(): void;
  12163. /** @hidden */
  12164. _reset(): void;
  12165. /**
  12166. * Copy the properties of particle to another one.
  12167. * @param other the particle to copy the information to.
  12168. */
  12169. copyTo(other: Particle): void;
  12170. }
  12171. }
  12172. declare module BABYLON {
  12173. /**
  12174. * Particle emitter represents a volume emitting particles.
  12175. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12176. */
  12177. export interface IParticleEmitterType {
  12178. /**
  12179. * Called by the particle System when the direction is computed for the created particle.
  12180. * @param worldMatrix is the world matrix of the particle system
  12181. * @param directionToUpdate is the direction vector to update with the result
  12182. * @param particle is the particle we are computed the direction for
  12183. * @param isLocal defines if the direction should be set in local space
  12184. */
  12185. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12186. /**
  12187. * Called by the particle System when the position is computed for the created particle.
  12188. * @param worldMatrix is the world matrix of the particle system
  12189. * @param positionToUpdate is the position vector to update with the result
  12190. * @param particle is the particle we are computed the position for
  12191. * @param isLocal defines if the position should be set in local space
  12192. */
  12193. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12194. /**
  12195. * Clones the current emitter and returns a copy of it
  12196. * @returns the new emitter
  12197. */
  12198. clone(): IParticleEmitterType;
  12199. /**
  12200. * Called by the GPUParticleSystem to setup the update shader
  12201. * @param effect defines the update shader
  12202. */
  12203. applyToShader(effect: Effect): void;
  12204. /**
  12205. * Returns a string to use to update the GPU particles update shader
  12206. * @returns the effect defines string
  12207. */
  12208. getEffectDefines(): string;
  12209. /**
  12210. * Returns a string representing the class name
  12211. * @returns a string containing the class name
  12212. */
  12213. getClassName(): string;
  12214. /**
  12215. * Serializes the particle system to a JSON object.
  12216. * @returns the JSON object
  12217. */
  12218. serialize(): any;
  12219. /**
  12220. * Parse properties from a JSON object
  12221. * @param serializationObject defines the JSON object
  12222. * @param scene defines the hosting scene
  12223. */
  12224. parse(serializationObject: any, scene: Scene): void;
  12225. }
  12226. }
  12227. declare module BABYLON {
  12228. /**
  12229. * Particle emitter emitting particles from the inside of a box.
  12230. * It emits the particles randomly between 2 given directions.
  12231. */
  12232. export class BoxParticleEmitter implements IParticleEmitterType {
  12233. /**
  12234. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12235. */
  12236. direction1: Vector3;
  12237. /**
  12238. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12239. */
  12240. direction2: Vector3;
  12241. /**
  12242. * 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.
  12243. */
  12244. minEmitBox: Vector3;
  12245. /**
  12246. * 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.
  12247. */
  12248. maxEmitBox: Vector3;
  12249. /**
  12250. * Creates a new instance BoxParticleEmitter
  12251. */
  12252. constructor();
  12253. /**
  12254. * Called by the particle System when the direction is computed for the created particle.
  12255. * @param worldMatrix is the world matrix of the particle system
  12256. * @param directionToUpdate is the direction vector to update with the result
  12257. * @param particle is the particle we are computed the direction for
  12258. * @param isLocal defines if the direction should be set in local space
  12259. */
  12260. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12261. /**
  12262. * Called by the particle System when the position is computed for the created particle.
  12263. * @param worldMatrix is the world matrix of the particle system
  12264. * @param positionToUpdate is the position vector to update with the result
  12265. * @param particle is the particle we are computed the position for
  12266. * @param isLocal defines if the position should be set in local space
  12267. */
  12268. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12269. /**
  12270. * Clones the current emitter and returns a copy of it
  12271. * @returns the new emitter
  12272. */
  12273. clone(): BoxParticleEmitter;
  12274. /**
  12275. * Called by the GPUParticleSystem to setup the update shader
  12276. * @param effect defines the update shader
  12277. */
  12278. applyToShader(effect: Effect): void;
  12279. /**
  12280. * Returns a string to use to update the GPU particles update shader
  12281. * @returns a string containng the defines string
  12282. */
  12283. getEffectDefines(): string;
  12284. /**
  12285. * Returns the string "BoxParticleEmitter"
  12286. * @returns a string containing the class name
  12287. */
  12288. getClassName(): string;
  12289. /**
  12290. * Serializes the particle system to a JSON object.
  12291. * @returns the JSON object
  12292. */
  12293. serialize(): any;
  12294. /**
  12295. * Parse properties from a JSON object
  12296. * @param serializationObject defines the JSON object
  12297. */
  12298. parse(serializationObject: any): void;
  12299. }
  12300. }
  12301. declare module BABYLON {
  12302. /**
  12303. * Particle emitter emitting particles from the inside of a cone.
  12304. * It emits the particles alongside the cone volume from the base to the particle.
  12305. * The emission direction might be randomized.
  12306. */
  12307. export class ConeParticleEmitter implements IParticleEmitterType {
  12308. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12309. directionRandomizer: number;
  12310. private _radius;
  12311. private _angle;
  12312. private _height;
  12313. /**
  12314. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12315. */
  12316. radiusRange: number;
  12317. /**
  12318. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12319. */
  12320. heightRange: number;
  12321. /**
  12322. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12323. */
  12324. emitFromSpawnPointOnly: boolean;
  12325. /**
  12326. * Gets or sets the radius of the emission cone
  12327. */
  12328. get radius(): number;
  12329. set radius(value: number);
  12330. /**
  12331. * Gets or sets the angle of the emission cone
  12332. */
  12333. get angle(): number;
  12334. set angle(value: number);
  12335. private _buildHeight;
  12336. /**
  12337. * Creates a new instance ConeParticleEmitter
  12338. * @param radius the radius of the emission cone (1 by default)
  12339. * @param angle the cone base angle (PI by default)
  12340. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12341. */
  12342. constructor(radius?: number, angle?: number,
  12343. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12344. directionRandomizer?: number);
  12345. /**
  12346. * Called by the particle System when the direction is computed for the created particle.
  12347. * @param worldMatrix is the world matrix of the particle system
  12348. * @param directionToUpdate is the direction vector to update with the result
  12349. * @param particle is the particle we are computed the direction for
  12350. * @param isLocal defines if the direction should be set in local space
  12351. */
  12352. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12353. /**
  12354. * Called by the particle System when the position is computed for the created particle.
  12355. * @param worldMatrix is the world matrix of the particle system
  12356. * @param positionToUpdate is the position vector to update with the result
  12357. * @param particle is the particle we are computed the position for
  12358. * @param isLocal defines if the position should be set in local space
  12359. */
  12360. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12361. /**
  12362. * Clones the current emitter and returns a copy of it
  12363. * @returns the new emitter
  12364. */
  12365. clone(): ConeParticleEmitter;
  12366. /**
  12367. * Called by the GPUParticleSystem to setup the update shader
  12368. * @param effect defines the update shader
  12369. */
  12370. applyToShader(effect: Effect): void;
  12371. /**
  12372. * Returns a string to use to update the GPU particles update shader
  12373. * @returns a string containng the defines string
  12374. */
  12375. getEffectDefines(): string;
  12376. /**
  12377. * Returns the string "ConeParticleEmitter"
  12378. * @returns a string containing the class name
  12379. */
  12380. getClassName(): string;
  12381. /**
  12382. * Serializes the particle system to a JSON object.
  12383. * @returns the JSON object
  12384. */
  12385. serialize(): any;
  12386. /**
  12387. * Parse properties from a JSON object
  12388. * @param serializationObject defines the JSON object
  12389. */
  12390. parse(serializationObject: any): void;
  12391. }
  12392. }
  12393. declare module BABYLON {
  12394. /**
  12395. * Particle emitter emitting particles from the inside of a cylinder.
  12396. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12397. */
  12398. export class CylinderParticleEmitter implements IParticleEmitterType {
  12399. /**
  12400. * The radius of the emission cylinder.
  12401. */
  12402. radius: number;
  12403. /**
  12404. * The height of the emission cylinder.
  12405. */
  12406. height: number;
  12407. /**
  12408. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12409. */
  12410. radiusRange: number;
  12411. /**
  12412. * How much to randomize the particle direction [0-1].
  12413. */
  12414. directionRandomizer: number;
  12415. /**
  12416. * Creates a new instance CylinderParticleEmitter
  12417. * @param radius the radius of the emission cylinder (1 by default)
  12418. * @param height the height of the emission cylinder (1 by default)
  12419. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12420. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12421. */
  12422. constructor(
  12423. /**
  12424. * The radius of the emission cylinder.
  12425. */
  12426. radius?: number,
  12427. /**
  12428. * The height of the emission cylinder.
  12429. */
  12430. height?: number,
  12431. /**
  12432. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12433. */
  12434. radiusRange?: number,
  12435. /**
  12436. * How much to randomize the particle direction [0-1].
  12437. */
  12438. directionRandomizer?: number);
  12439. /**
  12440. * Called by the particle System when the direction is computed for the created particle.
  12441. * @param worldMatrix is the world matrix of the particle system
  12442. * @param directionToUpdate is the direction vector to update with the result
  12443. * @param particle is the particle we are computed the direction for
  12444. * @param isLocal defines if the direction should be set in local space
  12445. */
  12446. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12447. /**
  12448. * Called by the particle System when the position is computed for the created particle.
  12449. * @param worldMatrix is the world matrix of the particle system
  12450. * @param positionToUpdate is the position vector to update with the result
  12451. * @param particle is the particle we are computed the position for
  12452. * @param isLocal defines if the position should be set in local space
  12453. */
  12454. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12455. /**
  12456. * Clones the current emitter and returns a copy of it
  12457. * @returns the new emitter
  12458. */
  12459. clone(): CylinderParticleEmitter;
  12460. /**
  12461. * Called by the GPUParticleSystem to setup the update shader
  12462. * @param effect defines the update shader
  12463. */
  12464. applyToShader(effect: Effect): void;
  12465. /**
  12466. * Returns a string to use to update the GPU particles update shader
  12467. * @returns a string containng the defines string
  12468. */
  12469. getEffectDefines(): string;
  12470. /**
  12471. * Returns the string "CylinderParticleEmitter"
  12472. * @returns a string containing the class name
  12473. */
  12474. getClassName(): string;
  12475. /**
  12476. * Serializes the particle system to a JSON object.
  12477. * @returns the JSON object
  12478. */
  12479. serialize(): any;
  12480. /**
  12481. * Parse properties from a JSON object
  12482. * @param serializationObject defines the JSON object
  12483. */
  12484. parse(serializationObject: any): void;
  12485. }
  12486. /**
  12487. * Particle emitter emitting particles from the inside of a cylinder.
  12488. * It emits the particles randomly between two vectors.
  12489. */
  12490. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12491. /**
  12492. * The min limit of the emission direction.
  12493. */
  12494. direction1: Vector3;
  12495. /**
  12496. * The max limit of the emission direction.
  12497. */
  12498. direction2: Vector3;
  12499. /**
  12500. * Creates a new instance CylinderDirectedParticleEmitter
  12501. * @param radius the radius of the emission cylinder (1 by default)
  12502. * @param height the height of the emission cylinder (1 by default)
  12503. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12504. * @param direction1 the min limit of the emission direction (up vector by default)
  12505. * @param direction2 the max limit of the emission direction (up vector by default)
  12506. */
  12507. constructor(radius?: number, height?: number, radiusRange?: number,
  12508. /**
  12509. * The min limit of the emission direction.
  12510. */
  12511. direction1?: Vector3,
  12512. /**
  12513. * The max limit of the emission direction.
  12514. */
  12515. direction2?: Vector3);
  12516. /**
  12517. * Called by the particle System when the direction is computed for the created particle.
  12518. * @param worldMatrix is the world matrix of the particle system
  12519. * @param directionToUpdate is the direction vector to update with the result
  12520. * @param particle is the particle we are computed the direction for
  12521. */
  12522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12523. /**
  12524. * Clones the current emitter and returns a copy of it
  12525. * @returns the new emitter
  12526. */
  12527. clone(): CylinderDirectedParticleEmitter;
  12528. /**
  12529. * Called by the GPUParticleSystem to setup the update shader
  12530. * @param effect defines the update shader
  12531. */
  12532. applyToShader(effect: Effect): void;
  12533. /**
  12534. * Returns a string to use to update the GPU particles update shader
  12535. * @returns a string containng the defines string
  12536. */
  12537. getEffectDefines(): string;
  12538. /**
  12539. * Returns the string "CylinderDirectedParticleEmitter"
  12540. * @returns a string containing the class name
  12541. */
  12542. getClassName(): string;
  12543. /**
  12544. * Serializes the particle system to a JSON object.
  12545. * @returns the JSON object
  12546. */
  12547. serialize(): any;
  12548. /**
  12549. * Parse properties from a JSON object
  12550. * @param serializationObject defines the JSON object
  12551. */
  12552. parse(serializationObject: any): void;
  12553. }
  12554. }
  12555. declare module BABYLON {
  12556. /**
  12557. * Particle emitter emitting particles from the inside of a hemisphere.
  12558. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12559. */
  12560. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12561. /**
  12562. * The radius of the emission hemisphere.
  12563. */
  12564. radius: number;
  12565. /**
  12566. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12567. */
  12568. radiusRange: number;
  12569. /**
  12570. * How much to randomize the particle direction [0-1].
  12571. */
  12572. directionRandomizer: number;
  12573. /**
  12574. * Creates a new instance HemisphericParticleEmitter
  12575. * @param radius the radius of the emission hemisphere (1 by default)
  12576. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12577. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12578. */
  12579. constructor(
  12580. /**
  12581. * The radius of the emission hemisphere.
  12582. */
  12583. radius?: number,
  12584. /**
  12585. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12586. */
  12587. radiusRange?: number,
  12588. /**
  12589. * How much to randomize the particle direction [0-1].
  12590. */
  12591. directionRandomizer?: number);
  12592. /**
  12593. * Called by the particle System when the direction is computed for the created particle.
  12594. * @param worldMatrix is the world matrix of the particle system
  12595. * @param directionToUpdate is the direction vector to update with the result
  12596. * @param particle is the particle we are computed the direction for
  12597. * @param isLocal defines if the direction should be set in local space
  12598. */
  12599. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12600. /**
  12601. * Called by the particle System when the position is computed for the created particle.
  12602. * @param worldMatrix is the world matrix of the particle system
  12603. * @param positionToUpdate is the position vector to update with the result
  12604. * @param particle is the particle we are computed the position for
  12605. * @param isLocal defines if the position should be set in local space
  12606. */
  12607. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12608. /**
  12609. * Clones the current emitter and returns a copy of it
  12610. * @returns the new emitter
  12611. */
  12612. clone(): HemisphericParticleEmitter;
  12613. /**
  12614. * Called by the GPUParticleSystem to setup the update shader
  12615. * @param effect defines the update shader
  12616. */
  12617. applyToShader(effect: Effect): void;
  12618. /**
  12619. * Returns a string to use to update the GPU particles update shader
  12620. * @returns a string containng the defines string
  12621. */
  12622. getEffectDefines(): string;
  12623. /**
  12624. * Returns the string "HemisphericParticleEmitter"
  12625. * @returns a string containing the class name
  12626. */
  12627. getClassName(): string;
  12628. /**
  12629. * Serializes the particle system to a JSON object.
  12630. * @returns the JSON object
  12631. */
  12632. serialize(): any;
  12633. /**
  12634. * Parse properties from a JSON object
  12635. * @param serializationObject defines the JSON object
  12636. */
  12637. parse(serializationObject: any): void;
  12638. }
  12639. }
  12640. declare module BABYLON {
  12641. /**
  12642. * Particle emitter emitting particles from a point.
  12643. * It emits the particles randomly between 2 given directions.
  12644. */
  12645. export class PointParticleEmitter implements IParticleEmitterType {
  12646. /**
  12647. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12648. */
  12649. direction1: Vector3;
  12650. /**
  12651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12652. */
  12653. direction2: Vector3;
  12654. /**
  12655. * Creates a new instance PointParticleEmitter
  12656. */
  12657. constructor();
  12658. /**
  12659. * Called by the particle System when the direction is computed for the created particle.
  12660. * @param worldMatrix is the world matrix of the particle system
  12661. * @param directionToUpdate is the direction vector to update with the result
  12662. * @param particle is the particle we are computed the direction for
  12663. * @param isLocal defines if the direction should be set in local space
  12664. */
  12665. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12666. /**
  12667. * Called by the particle System when the position is computed for the created particle.
  12668. * @param worldMatrix is the world matrix of the particle system
  12669. * @param positionToUpdate is the position vector to update with the result
  12670. * @param particle is the particle we are computed the position for
  12671. * @param isLocal defines if the position should be set in local space
  12672. */
  12673. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12674. /**
  12675. * Clones the current emitter and returns a copy of it
  12676. * @returns the new emitter
  12677. */
  12678. clone(): PointParticleEmitter;
  12679. /**
  12680. * Called by the GPUParticleSystem to setup the update shader
  12681. * @param effect defines the update shader
  12682. */
  12683. applyToShader(effect: Effect): void;
  12684. /**
  12685. * Returns a string to use to update the GPU particles update shader
  12686. * @returns a string containng the defines string
  12687. */
  12688. getEffectDefines(): string;
  12689. /**
  12690. * Returns the string "PointParticleEmitter"
  12691. * @returns a string containing the class name
  12692. */
  12693. getClassName(): string;
  12694. /**
  12695. * Serializes the particle system to a JSON object.
  12696. * @returns the JSON object
  12697. */
  12698. serialize(): any;
  12699. /**
  12700. * Parse properties from a JSON object
  12701. * @param serializationObject defines the JSON object
  12702. */
  12703. parse(serializationObject: any): void;
  12704. }
  12705. }
  12706. declare module BABYLON {
  12707. /**
  12708. * Particle emitter emitting particles from the inside of a sphere.
  12709. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12710. */
  12711. export class SphereParticleEmitter implements IParticleEmitterType {
  12712. /**
  12713. * The radius of the emission sphere.
  12714. */
  12715. radius: number;
  12716. /**
  12717. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12718. */
  12719. radiusRange: number;
  12720. /**
  12721. * How much to randomize the particle direction [0-1].
  12722. */
  12723. directionRandomizer: number;
  12724. /**
  12725. * Creates a new instance SphereParticleEmitter
  12726. * @param radius the radius of the emission sphere (1 by default)
  12727. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12728. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12729. */
  12730. constructor(
  12731. /**
  12732. * The radius of the emission sphere.
  12733. */
  12734. radius?: number,
  12735. /**
  12736. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12737. */
  12738. radiusRange?: number,
  12739. /**
  12740. * How much to randomize the particle direction [0-1].
  12741. */
  12742. directionRandomizer?: number);
  12743. /**
  12744. * Called by the particle System when the direction is computed for the created particle.
  12745. * @param worldMatrix is the world matrix of the particle system
  12746. * @param directionToUpdate is the direction vector to update with the result
  12747. * @param particle is the particle we are computed the direction for
  12748. * @param isLocal defines if the direction should be set in local space
  12749. */
  12750. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12751. /**
  12752. * Called by the particle System when the position is computed for the created particle.
  12753. * @param worldMatrix is the world matrix of the particle system
  12754. * @param positionToUpdate is the position vector to update with the result
  12755. * @param particle is the particle we are computed the position for
  12756. * @param isLocal defines if the position should be set in local space
  12757. */
  12758. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12759. /**
  12760. * Clones the current emitter and returns a copy of it
  12761. * @returns the new emitter
  12762. */
  12763. clone(): SphereParticleEmitter;
  12764. /**
  12765. * Called by the GPUParticleSystem to setup the update shader
  12766. * @param effect defines the update shader
  12767. */
  12768. applyToShader(effect: Effect): void;
  12769. /**
  12770. * Returns a string to use to update the GPU particles update shader
  12771. * @returns a string containng the defines string
  12772. */
  12773. getEffectDefines(): string;
  12774. /**
  12775. * Returns the string "SphereParticleEmitter"
  12776. * @returns a string containing the class name
  12777. */
  12778. getClassName(): string;
  12779. /**
  12780. * Serializes the particle system to a JSON object.
  12781. * @returns the JSON object
  12782. */
  12783. serialize(): any;
  12784. /**
  12785. * Parse properties from a JSON object
  12786. * @param serializationObject defines the JSON object
  12787. */
  12788. parse(serializationObject: any): void;
  12789. }
  12790. /**
  12791. * Particle emitter emitting particles from the inside of a sphere.
  12792. * It emits the particles randomly between two vectors.
  12793. */
  12794. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12795. /**
  12796. * The min limit of the emission direction.
  12797. */
  12798. direction1: Vector3;
  12799. /**
  12800. * The max limit of the emission direction.
  12801. */
  12802. direction2: Vector3;
  12803. /**
  12804. * Creates a new instance SphereDirectedParticleEmitter
  12805. * @param radius the radius of the emission sphere (1 by default)
  12806. * @param direction1 the min limit of the emission direction (up vector by default)
  12807. * @param direction2 the max limit of the emission direction (up vector by default)
  12808. */
  12809. constructor(radius?: number,
  12810. /**
  12811. * The min limit of the emission direction.
  12812. */
  12813. direction1?: Vector3,
  12814. /**
  12815. * The max limit of the emission direction.
  12816. */
  12817. direction2?: Vector3);
  12818. /**
  12819. * Called by the particle System when the direction is computed for the created particle.
  12820. * @param worldMatrix is the world matrix of the particle system
  12821. * @param directionToUpdate is the direction vector to update with the result
  12822. * @param particle is the particle we are computed the direction for
  12823. */
  12824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12825. /**
  12826. * Clones the current emitter and returns a copy of it
  12827. * @returns the new emitter
  12828. */
  12829. clone(): SphereDirectedParticleEmitter;
  12830. /**
  12831. * Called by the GPUParticleSystem to setup the update shader
  12832. * @param effect defines the update shader
  12833. */
  12834. applyToShader(effect: Effect): void;
  12835. /**
  12836. * Returns a string to use to update the GPU particles update shader
  12837. * @returns a string containng the defines string
  12838. */
  12839. getEffectDefines(): string;
  12840. /**
  12841. * Returns the string "SphereDirectedParticleEmitter"
  12842. * @returns a string containing the class name
  12843. */
  12844. getClassName(): string;
  12845. /**
  12846. * Serializes the particle system to a JSON object.
  12847. * @returns the JSON object
  12848. */
  12849. serialize(): any;
  12850. /**
  12851. * Parse properties from a JSON object
  12852. * @param serializationObject defines the JSON object
  12853. */
  12854. parse(serializationObject: any): void;
  12855. }
  12856. }
  12857. declare module BABYLON {
  12858. /**
  12859. * Particle emitter emitting particles from a custom list of positions.
  12860. */
  12861. export class CustomParticleEmitter implements IParticleEmitterType {
  12862. /**
  12863. * Gets or sets the position generator that will create the inital position of each particle.
  12864. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12865. */
  12866. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12867. /**
  12868. * Gets or sets the destination generator that will create the final destination of each particle.
  12869. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12870. */
  12871. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12872. /**
  12873. * Creates a new instance CustomParticleEmitter
  12874. */
  12875. constructor();
  12876. /**
  12877. * Called by the particle System when the direction is computed for the created particle.
  12878. * @param worldMatrix is the world matrix of the particle system
  12879. * @param directionToUpdate is the direction vector to update with the result
  12880. * @param particle is the particle we are computed the direction for
  12881. * @param isLocal defines if the direction should be set in local space
  12882. */
  12883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12884. /**
  12885. * Called by the particle System when the position is computed for the created particle.
  12886. * @param worldMatrix is the world matrix of the particle system
  12887. * @param positionToUpdate is the position vector to update with the result
  12888. * @param particle is the particle we are computed the position for
  12889. * @param isLocal defines if the position should be set in local space
  12890. */
  12891. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12892. /**
  12893. * Clones the current emitter and returns a copy of it
  12894. * @returns the new emitter
  12895. */
  12896. clone(): CustomParticleEmitter;
  12897. /**
  12898. * Called by the GPUParticleSystem to setup the update shader
  12899. * @param effect defines the update shader
  12900. */
  12901. applyToShader(effect: Effect): void;
  12902. /**
  12903. * Returns a string to use to update the GPU particles update shader
  12904. * @returns a string containng the defines string
  12905. */
  12906. getEffectDefines(): string;
  12907. /**
  12908. * Returns the string "PointParticleEmitter"
  12909. * @returns a string containing the class name
  12910. */
  12911. getClassName(): string;
  12912. /**
  12913. * Serializes the particle system to a JSON object.
  12914. * @returns the JSON object
  12915. */
  12916. serialize(): any;
  12917. /**
  12918. * Parse properties from a JSON object
  12919. * @param serializationObject defines the JSON object
  12920. */
  12921. parse(serializationObject: any): void;
  12922. }
  12923. }
  12924. declare module BABYLON {
  12925. /**
  12926. * Particle emitter emitting particles from the inside of a box.
  12927. * It emits the particles randomly between 2 given directions.
  12928. */
  12929. export class MeshParticleEmitter implements IParticleEmitterType {
  12930. private _indices;
  12931. private _positions;
  12932. private _normals;
  12933. private _storedNormal;
  12934. private _mesh;
  12935. /**
  12936. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12937. */
  12938. direction1: Vector3;
  12939. /**
  12940. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12941. */
  12942. direction2: Vector3;
  12943. /**
  12944. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12945. */
  12946. useMeshNormalsForDirection: boolean;
  12947. /** Defines the mesh to use as source */
  12948. get mesh(): Nullable<AbstractMesh>;
  12949. set mesh(value: Nullable<AbstractMesh>);
  12950. /**
  12951. * Creates a new instance MeshParticleEmitter
  12952. * @param mesh defines the mesh to use as source
  12953. */
  12954. constructor(mesh?: Nullable<AbstractMesh>);
  12955. /**
  12956. * Called by the particle System when the direction is computed for the created particle.
  12957. * @param worldMatrix is the world matrix of the particle system
  12958. * @param directionToUpdate is the direction vector to update with the result
  12959. * @param particle is the particle we are computed the direction for
  12960. * @param isLocal defines if the direction should be set in local space
  12961. */
  12962. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12963. /**
  12964. * Called by the particle System when the position is computed for the created particle.
  12965. * @param worldMatrix is the world matrix of the particle system
  12966. * @param positionToUpdate is the position vector to update with the result
  12967. * @param particle is the particle we are computed the position for
  12968. * @param isLocal defines if the position should be set in local space
  12969. */
  12970. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12971. /**
  12972. * Clones the current emitter and returns a copy of it
  12973. * @returns the new emitter
  12974. */
  12975. clone(): MeshParticleEmitter;
  12976. /**
  12977. * Called by the GPUParticleSystem to setup the update shader
  12978. * @param effect defines the update shader
  12979. */
  12980. applyToShader(effect: Effect): void;
  12981. /**
  12982. * Returns a string to use to update the GPU particles update shader
  12983. * @returns a string containng the defines string
  12984. */
  12985. getEffectDefines(): string;
  12986. /**
  12987. * Returns the string "BoxParticleEmitter"
  12988. * @returns a string containing the class name
  12989. */
  12990. getClassName(): string;
  12991. /**
  12992. * Serializes the particle system to a JSON object.
  12993. * @returns the JSON object
  12994. */
  12995. serialize(): any;
  12996. /**
  12997. * Parse properties from a JSON object
  12998. * @param serializationObject defines the JSON object
  12999. * @param scene defines the hosting scene
  13000. */
  13001. parse(serializationObject: any, scene: Scene): void;
  13002. }
  13003. }
  13004. declare module BABYLON {
  13005. /**
  13006. * Interface representing a particle system in Babylon.js.
  13007. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13008. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13009. */
  13010. export interface IParticleSystem {
  13011. /**
  13012. * List of animations used by the particle system.
  13013. */
  13014. animations: Animation[];
  13015. /**
  13016. * The id of the Particle system.
  13017. */
  13018. id: string;
  13019. /**
  13020. * The name of the Particle system.
  13021. */
  13022. name: string;
  13023. /**
  13024. * The emitter represents the Mesh or position we are attaching the particle system to.
  13025. */
  13026. emitter: Nullable<AbstractMesh | Vector3>;
  13027. /**
  13028. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13029. */
  13030. isBillboardBased: boolean;
  13031. /**
  13032. * The rendering group used by the Particle system to chose when to render.
  13033. */
  13034. renderingGroupId: number;
  13035. /**
  13036. * The layer mask we are rendering the particles through.
  13037. */
  13038. layerMask: number;
  13039. /**
  13040. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13041. */
  13042. updateSpeed: number;
  13043. /**
  13044. * The amount of time the particle system is running (depends of the overall update speed).
  13045. */
  13046. targetStopDuration: number;
  13047. /**
  13048. * The texture used to render each particle. (this can be a spritesheet)
  13049. */
  13050. particleTexture: Nullable<Texture>;
  13051. /**
  13052. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13053. */
  13054. blendMode: number;
  13055. /**
  13056. * Minimum life time of emitting particles.
  13057. */
  13058. minLifeTime: number;
  13059. /**
  13060. * Maximum life time of emitting particles.
  13061. */
  13062. maxLifeTime: number;
  13063. /**
  13064. * Minimum Size of emitting particles.
  13065. */
  13066. minSize: number;
  13067. /**
  13068. * Maximum Size of emitting particles.
  13069. */
  13070. maxSize: number;
  13071. /**
  13072. * Minimum scale of emitting particles on X axis.
  13073. */
  13074. minScaleX: number;
  13075. /**
  13076. * Maximum scale of emitting particles on X axis.
  13077. */
  13078. maxScaleX: number;
  13079. /**
  13080. * Minimum scale of emitting particles on Y axis.
  13081. */
  13082. minScaleY: number;
  13083. /**
  13084. * Maximum scale of emitting particles on Y axis.
  13085. */
  13086. maxScaleY: number;
  13087. /**
  13088. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13089. */
  13090. color1: Color4;
  13091. /**
  13092. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13093. */
  13094. color2: Color4;
  13095. /**
  13096. * Color the particle will have at the end of its lifetime.
  13097. */
  13098. colorDead: Color4;
  13099. /**
  13100. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13101. */
  13102. emitRate: number;
  13103. /**
  13104. * You can use gravity if you want to give an orientation to your particles.
  13105. */
  13106. gravity: Vector3;
  13107. /**
  13108. * Minimum power of emitting particles.
  13109. */
  13110. minEmitPower: number;
  13111. /**
  13112. * Maximum power of emitting particles.
  13113. */
  13114. maxEmitPower: number;
  13115. /**
  13116. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13117. */
  13118. minAngularSpeed: number;
  13119. /**
  13120. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13121. */
  13122. maxAngularSpeed: number;
  13123. /**
  13124. * Gets or sets the minimal initial rotation in radians.
  13125. */
  13126. minInitialRotation: number;
  13127. /**
  13128. * Gets or sets the maximal initial rotation in radians.
  13129. */
  13130. maxInitialRotation: number;
  13131. /**
  13132. * The particle emitter type defines the emitter used by the particle system.
  13133. * It can be for example box, sphere, or cone...
  13134. */
  13135. particleEmitterType: Nullable<IParticleEmitterType>;
  13136. /**
  13137. * Defines the delay in milliseconds before starting the system (0 by default)
  13138. */
  13139. startDelay: number;
  13140. /**
  13141. * 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
  13142. */
  13143. preWarmCycles: number;
  13144. /**
  13145. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13146. */
  13147. preWarmStepOffset: number;
  13148. /**
  13149. * 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)
  13150. */
  13151. spriteCellChangeSpeed: number;
  13152. /**
  13153. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13154. */
  13155. startSpriteCellID: number;
  13156. /**
  13157. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13158. */
  13159. endSpriteCellID: number;
  13160. /**
  13161. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13162. */
  13163. spriteCellWidth: number;
  13164. /**
  13165. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13166. */
  13167. spriteCellHeight: number;
  13168. /**
  13169. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13170. */
  13171. spriteRandomStartCell: boolean;
  13172. /**
  13173. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13174. */
  13175. isAnimationSheetEnabled: boolean;
  13176. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13177. translationPivot: Vector2;
  13178. /**
  13179. * Gets or sets a texture used to add random noise to particle positions
  13180. */
  13181. noiseTexture: Nullable<BaseTexture>;
  13182. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13183. noiseStrength: Vector3;
  13184. /**
  13185. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13186. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13187. */
  13188. billboardMode: number;
  13189. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13190. limitVelocityDamping: number;
  13191. /**
  13192. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13193. */
  13194. beginAnimationOnStart: boolean;
  13195. /**
  13196. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13197. */
  13198. beginAnimationFrom: number;
  13199. /**
  13200. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13201. */
  13202. beginAnimationTo: number;
  13203. /**
  13204. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13205. */
  13206. beginAnimationLoop: boolean;
  13207. /**
  13208. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13209. */
  13210. disposeOnStop: boolean;
  13211. /**
  13212. * Specifies if the particles are updated in emitter local space or world space
  13213. */
  13214. isLocal: boolean;
  13215. /** Snippet ID if the particle system was created from the snippet server */
  13216. snippetId: string;
  13217. /**
  13218. * Gets the maximum number of particles active at the same time.
  13219. * @returns The max number of active particles.
  13220. */
  13221. getCapacity(): number;
  13222. /**
  13223. * Gets the number of particles active at the same time.
  13224. * @returns The number of active particles.
  13225. */
  13226. getActiveCount(): number;
  13227. /**
  13228. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13229. * @returns True if it has been started, otherwise false.
  13230. */
  13231. isStarted(): boolean;
  13232. /**
  13233. * Animates the particle system for this frame.
  13234. */
  13235. animate(): void;
  13236. /**
  13237. * Renders the particle system in its current state.
  13238. * @returns the current number of particles
  13239. */
  13240. render(): number;
  13241. /**
  13242. * Dispose the particle system and frees its associated resources.
  13243. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13244. */
  13245. dispose(disposeTexture?: boolean): void;
  13246. /**
  13247. * Clones the particle system.
  13248. * @param name The name of the cloned object
  13249. * @param newEmitter The new emitter to use
  13250. * @returns the cloned particle system
  13251. */
  13252. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13253. /**
  13254. * Serializes the particle system to a JSON object
  13255. * @param serializeTexture defines if the texture must be serialized as well
  13256. * @returns the JSON object
  13257. */
  13258. serialize(serializeTexture: boolean): any;
  13259. /**
  13260. * Rebuild the particle system
  13261. */
  13262. rebuild(): void;
  13263. /** Force the system to rebuild all gradients that need to be resync */
  13264. forceRefreshGradients(): void;
  13265. /**
  13266. * Starts the particle system and begins to emit
  13267. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13268. */
  13269. start(delay?: number): void;
  13270. /**
  13271. * Stops the particle system.
  13272. */
  13273. stop(): void;
  13274. /**
  13275. * Remove all active particles
  13276. */
  13277. reset(): void;
  13278. /**
  13279. * Gets a boolean indicating that the system is stopping
  13280. * @returns true if the system is currently stopping
  13281. */
  13282. isStopping(): boolean;
  13283. /**
  13284. * Is this system ready to be used/rendered
  13285. * @return true if the system is ready
  13286. */
  13287. isReady(): boolean;
  13288. /**
  13289. * Returns the string "ParticleSystem"
  13290. * @returns a string containing the class name
  13291. */
  13292. getClassName(): string;
  13293. /**
  13294. * Adds a new color gradient
  13295. * @param gradient defines the gradient to use (between 0 and 1)
  13296. * @param color1 defines the color to affect to the specified gradient
  13297. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13298. * @returns the current particle system
  13299. */
  13300. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13301. /**
  13302. * Remove a specific color gradient
  13303. * @param gradient defines the gradient to remove
  13304. * @returns the current particle system
  13305. */
  13306. removeColorGradient(gradient: number): IParticleSystem;
  13307. /**
  13308. * Adds a new size gradient
  13309. * @param gradient defines the gradient to use (between 0 and 1)
  13310. * @param factor defines the size factor to affect to the specified gradient
  13311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13312. * @returns the current particle system
  13313. */
  13314. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13315. /**
  13316. * Remove a specific size gradient
  13317. * @param gradient defines the gradient to remove
  13318. * @returns the current particle system
  13319. */
  13320. removeSizeGradient(gradient: number): IParticleSystem;
  13321. /**
  13322. * Gets the current list of color gradients.
  13323. * You must use addColorGradient and removeColorGradient to udpate this list
  13324. * @returns the list of color gradients
  13325. */
  13326. getColorGradients(): Nullable<Array<ColorGradient>>;
  13327. /**
  13328. * Gets the current list of size gradients.
  13329. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13330. * @returns the list of size gradients
  13331. */
  13332. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13333. /**
  13334. * Gets the current list of angular speed gradients.
  13335. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13336. * @returns the list of angular speed gradients
  13337. */
  13338. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13339. /**
  13340. * Adds a new angular speed gradient
  13341. * @param gradient defines the gradient to use (between 0 and 1)
  13342. * @param factor defines the angular speed to affect to the specified gradient
  13343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13344. * @returns the current particle system
  13345. */
  13346. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13347. /**
  13348. * Remove a specific angular speed gradient
  13349. * @param gradient defines the gradient to remove
  13350. * @returns the current particle system
  13351. */
  13352. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13353. /**
  13354. * Gets the current list of velocity gradients.
  13355. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13356. * @returns the list of velocity gradients
  13357. */
  13358. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13359. /**
  13360. * Adds a new velocity gradient
  13361. * @param gradient defines the gradient to use (between 0 and 1)
  13362. * @param factor defines the velocity to affect to the specified gradient
  13363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13364. * @returns the current particle system
  13365. */
  13366. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13367. /**
  13368. * Remove a specific velocity gradient
  13369. * @param gradient defines the gradient to remove
  13370. * @returns the current particle system
  13371. */
  13372. removeVelocityGradient(gradient: number): IParticleSystem;
  13373. /**
  13374. * Gets the current list of limit velocity gradients.
  13375. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13376. * @returns the list of limit velocity gradients
  13377. */
  13378. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13379. /**
  13380. * Adds a new limit velocity gradient
  13381. * @param gradient defines the gradient to use (between 0 and 1)
  13382. * @param factor defines the limit velocity to affect to the specified gradient
  13383. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13384. * @returns the current particle system
  13385. */
  13386. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13387. /**
  13388. * Remove a specific limit velocity gradient
  13389. * @param gradient defines the gradient to remove
  13390. * @returns the current particle system
  13391. */
  13392. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13393. /**
  13394. * Adds a new drag gradient
  13395. * @param gradient defines the gradient to use (between 0 and 1)
  13396. * @param factor defines the drag to affect to the specified gradient
  13397. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13398. * @returns the current particle system
  13399. */
  13400. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13401. /**
  13402. * Remove a specific drag gradient
  13403. * @param gradient defines the gradient to remove
  13404. * @returns the current particle system
  13405. */
  13406. removeDragGradient(gradient: number): IParticleSystem;
  13407. /**
  13408. * Gets the current list of drag gradients.
  13409. * You must use addDragGradient and removeDragGradient to udpate this list
  13410. * @returns the list of drag gradients
  13411. */
  13412. getDragGradients(): Nullable<Array<FactorGradient>>;
  13413. /**
  13414. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13415. * @param gradient defines the gradient to use (between 0 and 1)
  13416. * @param factor defines the emit rate to affect to the specified gradient
  13417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13418. * @returns the current particle system
  13419. */
  13420. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13421. /**
  13422. * Remove a specific emit rate gradient
  13423. * @param gradient defines the gradient to remove
  13424. * @returns the current particle system
  13425. */
  13426. removeEmitRateGradient(gradient: number): IParticleSystem;
  13427. /**
  13428. * Gets the current list of emit rate gradients.
  13429. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13430. * @returns the list of emit rate gradients
  13431. */
  13432. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13433. /**
  13434. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13435. * @param gradient defines the gradient to use (between 0 and 1)
  13436. * @param factor defines the start size to affect to the specified gradient
  13437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13438. * @returns the current particle system
  13439. */
  13440. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13441. /**
  13442. * Remove a specific start size gradient
  13443. * @param gradient defines the gradient to remove
  13444. * @returns the current particle system
  13445. */
  13446. removeStartSizeGradient(gradient: number): IParticleSystem;
  13447. /**
  13448. * Gets the current list of start size gradients.
  13449. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13450. * @returns the list of start size gradients
  13451. */
  13452. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13453. /**
  13454. * Adds a new life time gradient
  13455. * @param gradient defines the gradient to use (between 0 and 1)
  13456. * @param factor defines the life time factor to affect to the specified gradient
  13457. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13458. * @returns the current particle system
  13459. */
  13460. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13461. /**
  13462. * Remove a specific life time gradient
  13463. * @param gradient defines the gradient to remove
  13464. * @returns the current particle system
  13465. */
  13466. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13467. /**
  13468. * Gets the current list of life time gradients.
  13469. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13470. * @returns the list of life time gradients
  13471. */
  13472. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13473. /**
  13474. * Gets the current list of color gradients.
  13475. * You must use addColorGradient and removeColorGradient to udpate this list
  13476. * @returns the list of color gradients
  13477. */
  13478. getColorGradients(): Nullable<Array<ColorGradient>>;
  13479. /**
  13480. * Adds a new ramp gradient used to remap particle colors
  13481. * @param gradient defines the gradient to use (between 0 and 1)
  13482. * @param color defines the color to affect to the specified gradient
  13483. * @returns the current particle system
  13484. */
  13485. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13486. /**
  13487. * Gets the current list of ramp gradients.
  13488. * You must use addRampGradient and removeRampGradient to udpate this list
  13489. * @returns the list of ramp gradients
  13490. */
  13491. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13492. /** Gets or sets a boolean indicating that ramp gradients must be used
  13493. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13494. */
  13495. useRampGradients: boolean;
  13496. /**
  13497. * Adds a new color remap gradient
  13498. * @param gradient defines the gradient to use (between 0 and 1)
  13499. * @param min defines the color remap minimal range
  13500. * @param max defines the color remap maximal range
  13501. * @returns the current particle system
  13502. */
  13503. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13504. /**
  13505. * Gets the current list of color remap gradients.
  13506. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13507. * @returns the list of color remap gradients
  13508. */
  13509. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13510. /**
  13511. * Adds a new alpha remap gradient
  13512. * @param gradient defines the gradient to use (between 0 and 1)
  13513. * @param min defines the alpha remap minimal range
  13514. * @param max defines the alpha remap maximal range
  13515. * @returns the current particle system
  13516. */
  13517. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13518. /**
  13519. * Gets the current list of alpha remap gradients.
  13520. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13521. * @returns the list of alpha remap gradients
  13522. */
  13523. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13524. /**
  13525. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13526. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13527. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13528. * @returns the emitter
  13529. */
  13530. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13531. /**
  13532. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13533. * @param radius The radius of the hemisphere to emit from
  13534. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13535. * @returns the emitter
  13536. */
  13537. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13538. /**
  13539. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13540. * @param radius The radius of the sphere to emit from
  13541. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13542. * @returns the emitter
  13543. */
  13544. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13545. /**
  13546. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13547. * @param radius The radius of the sphere to emit from
  13548. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13549. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13550. * @returns the emitter
  13551. */
  13552. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13553. /**
  13554. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13555. * @param radius The radius of the emission cylinder
  13556. * @param height The height of the emission cylinder
  13557. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13558. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13559. * @returns the emitter
  13560. */
  13561. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13562. /**
  13563. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13564. * @param radius The radius of the cylinder to emit from
  13565. * @param height The height of the emission cylinder
  13566. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13567. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13568. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13569. * @returns the emitter
  13570. */
  13571. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13572. /**
  13573. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13574. * @param radius The radius of the cone to emit from
  13575. * @param angle The base angle of the cone
  13576. * @returns the emitter
  13577. */
  13578. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13579. /**
  13580. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13581. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13582. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13583. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13584. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13585. * @returns the emitter
  13586. */
  13587. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13588. /**
  13589. * Get hosting scene
  13590. * @returns the scene
  13591. */
  13592. getScene(): Scene;
  13593. }
  13594. }
  13595. declare module BABYLON {
  13596. /**
  13597. * 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.
  13598. * @see https://doc.babylonjs.com/how_to/transformnode
  13599. */
  13600. export class TransformNode extends Node {
  13601. /**
  13602. * Object will not rotate to face the camera
  13603. */
  13604. static BILLBOARDMODE_NONE: number;
  13605. /**
  13606. * Object will rotate to face the camera but only on the x axis
  13607. */
  13608. static BILLBOARDMODE_X: number;
  13609. /**
  13610. * Object will rotate to face the camera but only on the y axis
  13611. */
  13612. static BILLBOARDMODE_Y: number;
  13613. /**
  13614. * Object will rotate to face the camera but only on the z axis
  13615. */
  13616. static BILLBOARDMODE_Z: number;
  13617. /**
  13618. * Object will rotate to face the camera
  13619. */
  13620. static BILLBOARDMODE_ALL: number;
  13621. /**
  13622. * Object will rotate to face the camera's position instead of orientation
  13623. */
  13624. static BILLBOARDMODE_USE_POSITION: number;
  13625. private _forward;
  13626. private _forwardInverted;
  13627. private _up;
  13628. private _right;
  13629. private _rightInverted;
  13630. private _position;
  13631. private _rotation;
  13632. private _rotationQuaternion;
  13633. protected _scaling: Vector3;
  13634. protected _isDirty: boolean;
  13635. private _transformToBoneReferal;
  13636. private _isAbsoluteSynced;
  13637. private _billboardMode;
  13638. /**
  13639. * Gets or sets the billboard mode. Default is 0.
  13640. *
  13641. * | Value | Type | Description |
  13642. * | --- | --- | --- |
  13643. * | 0 | BILLBOARDMODE_NONE | |
  13644. * | 1 | BILLBOARDMODE_X | |
  13645. * | 2 | BILLBOARDMODE_Y | |
  13646. * | 4 | BILLBOARDMODE_Z | |
  13647. * | 7 | BILLBOARDMODE_ALL | |
  13648. *
  13649. */
  13650. get billboardMode(): number;
  13651. set billboardMode(value: number);
  13652. private _preserveParentRotationForBillboard;
  13653. /**
  13654. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13655. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13656. */
  13657. get preserveParentRotationForBillboard(): boolean;
  13658. set preserveParentRotationForBillboard(value: boolean);
  13659. /**
  13660. * 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
  13661. */
  13662. scalingDeterminant: number;
  13663. private _infiniteDistance;
  13664. /**
  13665. * Gets or sets the distance of the object to max, often used by skybox
  13666. */
  13667. get infiniteDistance(): boolean;
  13668. set infiniteDistance(value: boolean);
  13669. /**
  13670. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13671. * By default the system will update normals to compensate
  13672. */
  13673. ignoreNonUniformScaling: boolean;
  13674. /**
  13675. * 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
  13676. */
  13677. reIntegrateRotationIntoRotationQuaternion: boolean;
  13678. /** @hidden */
  13679. _poseMatrix: Nullable<Matrix>;
  13680. /** @hidden */
  13681. _localMatrix: Matrix;
  13682. private _usePivotMatrix;
  13683. private _absolutePosition;
  13684. private _absoluteScaling;
  13685. private _absoluteRotationQuaternion;
  13686. private _pivotMatrix;
  13687. private _pivotMatrixInverse;
  13688. protected _postMultiplyPivotMatrix: boolean;
  13689. protected _isWorldMatrixFrozen: boolean;
  13690. /** @hidden */
  13691. _indexInSceneTransformNodesArray: number;
  13692. /**
  13693. * An event triggered after the world matrix is updated
  13694. */
  13695. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13696. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13697. /**
  13698. * Gets a string identifying the name of the class
  13699. * @returns "TransformNode" string
  13700. */
  13701. getClassName(): string;
  13702. /**
  13703. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13704. */
  13705. get position(): Vector3;
  13706. set position(newPosition: Vector3);
  13707. /**
  13708. * 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)).
  13709. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13710. */
  13711. get rotation(): Vector3;
  13712. set rotation(newRotation: Vector3);
  13713. /**
  13714. * 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)).
  13715. */
  13716. get scaling(): Vector3;
  13717. set scaling(newScaling: Vector3);
  13718. /**
  13719. * 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).
  13720. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13721. */
  13722. get rotationQuaternion(): Nullable<Quaternion>;
  13723. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13724. /**
  13725. * The forward direction of that transform in world space.
  13726. */
  13727. get forward(): Vector3;
  13728. /**
  13729. * The up direction of that transform in world space.
  13730. */
  13731. get up(): Vector3;
  13732. /**
  13733. * The right direction of that transform in world space.
  13734. */
  13735. get right(): Vector3;
  13736. /**
  13737. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13738. * @param matrix the matrix to copy the pose from
  13739. * @returns this TransformNode.
  13740. */
  13741. updatePoseMatrix(matrix: Matrix): TransformNode;
  13742. /**
  13743. * Returns the mesh Pose matrix.
  13744. * @returns the pose matrix
  13745. */
  13746. getPoseMatrix(): Matrix;
  13747. /** @hidden */
  13748. _isSynchronized(): boolean;
  13749. /** @hidden */
  13750. _initCache(): void;
  13751. /**
  13752. * Flag the transform node as dirty (Forcing it to update everything)
  13753. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13754. * @returns this transform node
  13755. */
  13756. markAsDirty(property: string): TransformNode;
  13757. /**
  13758. * Returns the current mesh absolute position.
  13759. * Returns a Vector3.
  13760. */
  13761. get absolutePosition(): Vector3;
  13762. /**
  13763. * Returns the current mesh absolute scaling.
  13764. * Returns a Vector3.
  13765. */
  13766. get absoluteScaling(): Vector3;
  13767. /**
  13768. * Returns the current mesh absolute rotation.
  13769. * Returns a Quaternion.
  13770. */
  13771. get absoluteRotationQuaternion(): Quaternion;
  13772. /**
  13773. * Sets a new matrix to apply before all other transformation
  13774. * @param matrix defines the transform matrix
  13775. * @returns the current TransformNode
  13776. */
  13777. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13778. /**
  13779. * Sets a new pivot matrix to the current node
  13780. * @param matrix defines the new pivot matrix to use
  13781. * @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
  13782. * @returns the current TransformNode
  13783. */
  13784. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13785. /**
  13786. * Returns the mesh pivot matrix.
  13787. * Default : Identity.
  13788. * @returns the matrix
  13789. */
  13790. getPivotMatrix(): Matrix;
  13791. /**
  13792. * Instantiate (when possible) or clone that node with its hierarchy
  13793. * @param newParent defines the new parent to use for the instance (or clone)
  13794. * @param options defines options to configure how copy is done
  13795. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13796. * @returns an instance (or a clone) of the current node with its hiearchy
  13797. */
  13798. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13799. doNotInstantiate: boolean;
  13800. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13801. /**
  13802. * Prevents the World matrix to be computed any longer
  13803. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13804. * @returns the TransformNode.
  13805. */
  13806. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13807. /**
  13808. * Allows back the World matrix computation.
  13809. * @returns the TransformNode.
  13810. */
  13811. unfreezeWorldMatrix(): this;
  13812. /**
  13813. * True if the World matrix has been frozen.
  13814. */
  13815. get isWorldMatrixFrozen(): boolean;
  13816. /**
  13817. * Retuns the mesh absolute position in the World.
  13818. * @returns a Vector3.
  13819. */
  13820. getAbsolutePosition(): Vector3;
  13821. /**
  13822. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13823. * @param absolutePosition the absolute position to set
  13824. * @returns the TransformNode.
  13825. */
  13826. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13827. /**
  13828. * Sets the mesh position in its local space.
  13829. * @param vector3 the position to set in localspace
  13830. * @returns the TransformNode.
  13831. */
  13832. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13833. /**
  13834. * Returns the mesh position in the local space from the current World matrix values.
  13835. * @returns a new Vector3.
  13836. */
  13837. getPositionExpressedInLocalSpace(): Vector3;
  13838. /**
  13839. * Translates the mesh along the passed Vector3 in its local space.
  13840. * @param vector3 the distance to translate in localspace
  13841. * @returns the TransformNode.
  13842. */
  13843. locallyTranslate(vector3: Vector3): TransformNode;
  13844. private static _lookAtVectorCache;
  13845. /**
  13846. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13847. * @param targetPoint the position (must be in same space as current mesh) to look at
  13848. * @param yawCor optional yaw (y-axis) correction in radians
  13849. * @param pitchCor optional pitch (x-axis) correction in radians
  13850. * @param rollCor optional roll (z-axis) correction in radians
  13851. * @param space the choosen space of the target
  13852. * @returns the TransformNode.
  13853. */
  13854. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13855. /**
  13856. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13857. * This Vector3 is expressed in the World space.
  13858. * @param localAxis axis to rotate
  13859. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13860. */
  13861. getDirection(localAxis: Vector3): Vector3;
  13862. /**
  13863. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13864. * localAxis is expressed in the mesh local space.
  13865. * result is computed in the Wordl space from the mesh World matrix.
  13866. * @param localAxis axis to rotate
  13867. * @param result the resulting transformnode
  13868. * @returns this TransformNode.
  13869. */
  13870. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13871. /**
  13872. * Sets this transform node rotation to the given local axis.
  13873. * @param localAxis the axis in local space
  13874. * @param yawCor optional yaw (y-axis) correction in radians
  13875. * @param pitchCor optional pitch (x-axis) correction in radians
  13876. * @param rollCor optional roll (z-axis) correction in radians
  13877. * @returns this TransformNode
  13878. */
  13879. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13880. /**
  13881. * Sets a new pivot point to the current node
  13882. * @param point defines the new pivot point to use
  13883. * @param space defines if the point is in world or local space (local by default)
  13884. * @returns the current TransformNode
  13885. */
  13886. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13887. /**
  13888. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13889. * @returns the pivot point
  13890. */
  13891. getPivotPoint(): Vector3;
  13892. /**
  13893. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13894. * @param result the vector3 to store the result
  13895. * @returns this TransformNode.
  13896. */
  13897. getPivotPointToRef(result: Vector3): TransformNode;
  13898. /**
  13899. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13900. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13901. */
  13902. getAbsolutePivotPoint(): Vector3;
  13903. /**
  13904. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13905. * @param result vector3 to store the result
  13906. * @returns this TransformNode.
  13907. */
  13908. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13909. /**
  13910. * Defines the passed node as the parent of the current node.
  13911. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13912. * @see https://doc.babylonjs.com/how_to/parenting
  13913. * @param node the node ot set as the parent
  13914. * @returns this TransformNode.
  13915. */
  13916. setParent(node: Nullable<Node>): TransformNode;
  13917. private _nonUniformScaling;
  13918. /**
  13919. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13920. */
  13921. get nonUniformScaling(): boolean;
  13922. /** @hidden */
  13923. _updateNonUniformScalingState(value: boolean): boolean;
  13924. /**
  13925. * Attach the current TransformNode to another TransformNode associated with a bone
  13926. * @param bone Bone affecting the TransformNode
  13927. * @param affectedTransformNode TransformNode associated with the bone
  13928. * @returns this object
  13929. */
  13930. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13931. /**
  13932. * Detach the transform node if its associated with a bone
  13933. * @returns this object
  13934. */
  13935. detachFromBone(): TransformNode;
  13936. private static _rotationAxisCache;
  13937. /**
  13938. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13939. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13940. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13941. * The passed axis is also normalized.
  13942. * @param axis the axis to rotate around
  13943. * @param amount the amount to rotate in radians
  13944. * @param space Space to rotate in (Default: local)
  13945. * @returns the TransformNode.
  13946. */
  13947. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13948. /**
  13949. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13950. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13951. * The passed axis is also normalized. .
  13952. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13953. * @param point the point to rotate around
  13954. * @param axis the axis to rotate around
  13955. * @param amount the amount to rotate in radians
  13956. * @returns the TransformNode
  13957. */
  13958. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13959. /**
  13960. * Translates the mesh along the axis vector for the passed distance in the given space.
  13961. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13962. * @param axis the axis to translate in
  13963. * @param distance the distance to translate
  13964. * @param space Space to rotate in (Default: local)
  13965. * @returns the TransformNode.
  13966. */
  13967. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13968. /**
  13969. * Adds a rotation step to the mesh current rotation.
  13970. * x, y, z are Euler angles expressed in radians.
  13971. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13972. * This means this rotation is made in the mesh local space only.
  13973. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13974. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13975. * ```javascript
  13976. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13977. * ```
  13978. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13979. * 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.
  13980. * @param x Rotation to add
  13981. * @param y Rotation to add
  13982. * @param z Rotation to add
  13983. * @returns the TransformNode.
  13984. */
  13985. addRotation(x: number, y: number, z: number): TransformNode;
  13986. /**
  13987. * @hidden
  13988. */
  13989. protected _getEffectiveParent(): Nullable<Node>;
  13990. /**
  13991. * Computes the world matrix of the node
  13992. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13993. * @returns the world matrix
  13994. */
  13995. computeWorldMatrix(force?: boolean): Matrix;
  13996. /**
  13997. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13998. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13999. */
  14000. resetLocalMatrix(independentOfChildren?: boolean): void;
  14001. protected _afterComputeWorldMatrix(): void;
  14002. /**
  14003. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14004. * @param func callback function to add
  14005. *
  14006. * @returns the TransformNode.
  14007. */
  14008. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14009. /**
  14010. * Removes a registered callback function.
  14011. * @param func callback function to remove
  14012. * @returns the TransformNode.
  14013. */
  14014. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14015. /**
  14016. * Gets the position of the current mesh in camera space
  14017. * @param camera defines the camera to use
  14018. * @returns a position
  14019. */
  14020. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14021. /**
  14022. * Returns the distance from the mesh to the active camera
  14023. * @param camera defines the camera to use
  14024. * @returns the distance
  14025. */
  14026. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14027. /**
  14028. * Clone the current transform node
  14029. * @param name Name of the new clone
  14030. * @param newParent New parent for the clone
  14031. * @param doNotCloneChildren Do not clone children hierarchy
  14032. * @returns the new transform node
  14033. */
  14034. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14035. /**
  14036. * Serializes the objects information.
  14037. * @param currentSerializationObject defines the object to serialize in
  14038. * @returns the serialized object
  14039. */
  14040. serialize(currentSerializationObject?: any): any;
  14041. /**
  14042. * Returns a new TransformNode object parsed from the source provided.
  14043. * @param parsedTransformNode is the source.
  14044. * @param scene the scne the object belongs to
  14045. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14046. * @returns a new TransformNode object parsed from the source provided.
  14047. */
  14048. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14049. /**
  14050. * Get all child-transformNodes of this node
  14051. * @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
  14052. * @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
  14053. * @returns an array of TransformNode
  14054. */
  14055. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14056. /**
  14057. * Releases resources associated with this transform node.
  14058. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14059. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14060. */
  14061. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14062. /**
  14063. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14064. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14065. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14066. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14067. * @returns the current mesh
  14068. */
  14069. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14070. private _syncAbsoluteScalingAndRotation;
  14071. }
  14072. }
  14073. declare module BABYLON {
  14074. /**
  14075. * Class used to override all child animations of a given target
  14076. */
  14077. export class AnimationPropertiesOverride {
  14078. /**
  14079. * Gets or sets a value indicating if animation blending must be used
  14080. */
  14081. enableBlending: boolean;
  14082. /**
  14083. * Gets or sets the blending speed to use when enableBlending is true
  14084. */
  14085. blendingSpeed: number;
  14086. /**
  14087. * Gets or sets the default loop mode to use
  14088. */
  14089. loopMode: number;
  14090. }
  14091. }
  14092. declare module BABYLON {
  14093. /**
  14094. * Class used to store bone information
  14095. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14096. */
  14097. export class Bone extends Node {
  14098. /**
  14099. * defines the bone name
  14100. */
  14101. name: string;
  14102. private static _tmpVecs;
  14103. private static _tmpQuat;
  14104. private static _tmpMats;
  14105. /**
  14106. * Gets the list of child bones
  14107. */
  14108. children: Bone[];
  14109. /** Gets the animations associated with this bone */
  14110. animations: Animation[];
  14111. /**
  14112. * Gets or sets bone length
  14113. */
  14114. length: number;
  14115. /**
  14116. * @hidden Internal only
  14117. * Set this value to map this bone to a different index in the transform matrices
  14118. * Set this value to -1 to exclude the bone from the transform matrices
  14119. */
  14120. _index: Nullable<number>;
  14121. private _skeleton;
  14122. private _localMatrix;
  14123. private _restPose;
  14124. private _baseMatrix;
  14125. private _absoluteTransform;
  14126. private _invertedAbsoluteTransform;
  14127. private _parent;
  14128. private _scalingDeterminant;
  14129. private _worldTransform;
  14130. private _localScaling;
  14131. private _localRotation;
  14132. private _localPosition;
  14133. private _needToDecompose;
  14134. private _needToCompose;
  14135. /** @hidden */
  14136. _linkedTransformNode: Nullable<TransformNode>;
  14137. /** @hidden */
  14138. _waitingTransformNodeId: Nullable<string>;
  14139. /** @hidden */
  14140. get _matrix(): Matrix;
  14141. /** @hidden */
  14142. set _matrix(value: Matrix);
  14143. /**
  14144. * Create a new bone
  14145. * @param name defines the bone name
  14146. * @param skeleton defines the parent skeleton
  14147. * @param parentBone defines the parent (can be null if the bone is the root)
  14148. * @param localMatrix defines the local matrix
  14149. * @param restPose defines the rest pose matrix
  14150. * @param baseMatrix defines the base matrix
  14151. * @param index defines index of the bone in the hiearchy
  14152. */
  14153. constructor(
  14154. /**
  14155. * defines the bone name
  14156. */
  14157. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14158. /**
  14159. * Gets the current object class name.
  14160. * @return the class name
  14161. */
  14162. getClassName(): string;
  14163. /**
  14164. * Gets the parent skeleton
  14165. * @returns a skeleton
  14166. */
  14167. getSkeleton(): Skeleton;
  14168. /**
  14169. * Gets parent bone
  14170. * @returns a bone or null if the bone is the root of the bone hierarchy
  14171. */
  14172. getParent(): Nullable<Bone>;
  14173. /**
  14174. * Returns an array containing the root bones
  14175. * @returns an array containing the root bones
  14176. */
  14177. getChildren(): Array<Bone>;
  14178. /**
  14179. * Gets the node index in matrix array generated for rendering
  14180. * @returns the node index
  14181. */
  14182. getIndex(): number;
  14183. /**
  14184. * Sets the parent bone
  14185. * @param parent defines the parent (can be null if the bone is the root)
  14186. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14187. */
  14188. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14189. /**
  14190. * Gets the local matrix
  14191. * @returns a matrix
  14192. */
  14193. getLocalMatrix(): Matrix;
  14194. /**
  14195. * Gets the base matrix (initial matrix which remains unchanged)
  14196. * @returns a matrix
  14197. */
  14198. getBaseMatrix(): Matrix;
  14199. /**
  14200. * Gets the rest pose matrix
  14201. * @returns a matrix
  14202. */
  14203. getRestPose(): Matrix;
  14204. /**
  14205. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14206. */
  14207. getWorldMatrix(): Matrix;
  14208. /**
  14209. * Sets the local matrix to rest pose matrix
  14210. */
  14211. returnToRest(): void;
  14212. /**
  14213. * Gets the inverse of the absolute transform matrix.
  14214. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14215. * @returns a matrix
  14216. */
  14217. getInvertedAbsoluteTransform(): Matrix;
  14218. /**
  14219. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14220. * @returns a matrix
  14221. */
  14222. getAbsoluteTransform(): Matrix;
  14223. /**
  14224. * Links with the given transform node.
  14225. * The local matrix of this bone is copied from the transform node every frame.
  14226. * @param transformNode defines the transform node to link to
  14227. */
  14228. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14229. /**
  14230. * Gets the node used to drive the bone's transformation
  14231. * @returns a transform node or null
  14232. */
  14233. getTransformNode(): Nullable<TransformNode>;
  14234. /** Gets or sets current position (in local space) */
  14235. get position(): Vector3;
  14236. set position(newPosition: Vector3);
  14237. /** Gets or sets current rotation (in local space) */
  14238. get rotation(): Vector3;
  14239. set rotation(newRotation: Vector3);
  14240. /** Gets or sets current rotation quaternion (in local space) */
  14241. get rotationQuaternion(): Quaternion;
  14242. set rotationQuaternion(newRotation: Quaternion);
  14243. /** Gets or sets current scaling (in local space) */
  14244. get scaling(): Vector3;
  14245. set scaling(newScaling: Vector3);
  14246. /**
  14247. * Gets the animation properties override
  14248. */
  14249. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14250. private _decompose;
  14251. private _compose;
  14252. /**
  14253. * Update the base and local matrices
  14254. * @param matrix defines the new base or local matrix
  14255. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14256. * @param updateLocalMatrix defines if the local matrix should be updated
  14257. */
  14258. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14259. /** @hidden */
  14260. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14261. /**
  14262. * Flag the bone as dirty (Forcing it to update everything)
  14263. */
  14264. markAsDirty(): void;
  14265. /** @hidden */
  14266. _markAsDirtyAndCompose(): void;
  14267. private _markAsDirtyAndDecompose;
  14268. /**
  14269. * Translate the bone in local or world space
  14270. * @param vec The amount to translate the bone
  14271. * @param space The space that the translation is in
  14272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14273. */
  14274. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14275. /**
  14276. * Set the postion of the bone in local or world space
  14277. * @param position The position to set the bone
  14278. * @param space The space that the position is in
  14279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14280. */
  14281. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14282. /**
  14283. * Set the absolute position of the bone (world space)
  14284. * @param position The position to set the bone
  14285. * @param mesh The mesh that this bone is attached to
  14286. */
  14287. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14288. /**
  14289. * Scale the bone on the x, y and z axes (in local space)
  14290. * @param x The amount to scale the bone on the x axis
  14291. * @param y The amount to scale the bone on the y axis
  14292. * @param z The amount to scale the bone on the z axis
  14293. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14294. */
  14295. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14296. /**
  14297. * Set the bone scaling in local space
  14298. * @param scale defines the scaling vector
  14299. */
  14300. setScale(scale: Vector3): void;
  14301. /**
  14302. * Gets the current scaling in local space
  14303. * @returns the current scaling vector
  14304. */
  14305. getScale(): Vector3;
  14306. /**
  14307. * Gets the current scaling in local space and stores it in a target vector
  14308. * @param result defines the target vector
  14309. */
  14310. getScaleToRef(result: Vector3): void;
  14311. /**
  14312. * Set the yaw, pitch, and roll of the bone in local or world space
  14313. * @param yaw The rotation of the bone on the y axis
  14314. * @param pitch The rotation of the bone on the x axis
  14315. * @param roll The rotation of the bone on the z axis
  14316. * @param space The space that the axes of rotation are in
  14317. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14318. */
  14319. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14320. /**
  14321. * Add a rotation to the bone on an axis in local or world space
  14322. * @param axis The axis to rotate the bone on
  14323. * @param amount The amount to rotate the bone
  14324. * @param space The space that the axis is in
  14325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14326. */
  14327. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14328. /**
  14329. * Set the rotation of the bone to a particular axis angle in local or world space
  14330. * @param axis The axis to rotate the bone on
  14331. * @param angle The angle that the bone should be rotated to
  14332. * @param space The space that the axis is in
  14333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14334. */
  14335. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14336. /**
  14337. * Set the euler rotation of the bone in local of world space
  14338. * @param rotation The euler rotation that the bone should be set to
  14339. * @param space The space that the rotation is in
  14340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14341. */
  14342. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14343. /**
  14344. * Set the quaternion rotation of the bone in local of world space
  14345. * @param quat The quaternion rotation that the bone should be set to
  14346. * @param space The space that the rotation is in
  14347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14348. */
  14349. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14350. /**
  14351. * Set the rotation matrix of the bone in local of world space
  14352. * @param rotMat The rotation matrix that the bone should be set to
  14353. * @param space The space that the rotation is in
  14354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14355. */
  14356. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14357. private _rotateWithMatrix;
  14358. private _getNegativeRotationToRef;
  14359. /**
  14360. * Get the position of the bone in local or world space
  14361. * @param space The space that the returned position is in
  14362. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14363. * @returns The position of the bone
  14364. */
  14365. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14366. /**
  14367. * Copy the position of the bone to a vector3 in local or world space
  14368. * @param space The space that the returned position is in
  14369. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14370. * @param result The vector3 to copy the position to
  14371. */
  14372. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14373. /**
  14374. * Get the absolute position of the bone (world space)
  14375. * @param mesh The mesh that this bone is attached to
  14376. * @returns The absolute position of the bone
  14377. */
  14378. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14379. /**
  14380. * Copy the absolute position of the bone (world space) to the result param
  14381. * @param mesh The mesh that this bone is attached to
  14382. * @param result The vector3 to copy the absolute position to
  14383. */
  14384. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14385. /**
  14386. * Compute the absolute transforms of this bone and its children
  14387. */
  14388. computeAbsoluteTransforms(): void;
  14389. /**
  14390. * Get the world direction from an axis that is in the local space of the bone
  14391. * @param localAxis The local direction that is used to compute the world direction
  14392. * @param mesh The mesh that this bone is attached to
  14393. * @returns The world direction
  14394. */
  14395. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14396. /**
  14397. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14398. * @param localAxis The local direction that is used to compute the world direction
  14399. * @param mesh The mesh that this bone is attached to
  14400. * @param result The vector3 that the world direction will be copied to
  14401. */
  14402. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14403. /**
  14404. * Get the euler rotation of the bone in local or world space
  14405. * @param space The space that the rotation should be in
  14406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14407. * @returns The euler rotation
  14408. */
  14409. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14410. /**
  14411. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14412. * @param space The space that the rotation should be in
  14413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14414. * @param result The vector3 that the rotation should be copied to
  14415. */
  14416. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14417. /**
  14418. * Get the quaternion rotation of the bone in either local or world space
  14419. * @param space The space that the rotation should be in
  14420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14421. * @returns The quaternion rotation
  14422. */
  14423. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14424. /**
  14425. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14426. * @param space The space that the rotation should be in
  14427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14428. * @param result The quaternion that the rotation should be copied to
  14429. */
  14430. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14431. /**
  14432. * Get the rotation matrix of the bone in local or world space
  14433. * @param space The space that the rotation should be in
  14434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14435. * @returns The rotation matrix
  14436. */
  14437. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14438. /**
  14439. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14440. * @param space The space that the rotation should be in
  14441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14442. * @param result The quaternion that the rotation should be copied to
  14443. */
  14444. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14445. /**
  14446. * Get the world position of a point that is in the local space of the bone
  14447. * @param position The local position
  14448. * @param mesh The mesh that this bone is attached to
  14449. * @returns The world position
  14450. */
  14451. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14452. /**
  14453. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14454. * @param position The local position
  14455. * @param mesh The mesh that this bone is attached to
  14456. * @param result The vector3 that the world position should be copied to
  14457. */
  14458. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14459. /**
  14460. * Get the local position of a point that is in world space
  14461. * @param position The world position
  14462. * @param mesh The mesh that this bone is attached to
  14463. * @returns The local position
  14464. */
  14465. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14466. /**
  14467. * Get the local position of a point that is in world space and copy it to the result param
  14468. * @param position The world position
  14469. * @param mesh The mesh that this bone is attached to
  14470. * @param result The vector3 that the local position should be copied to
  14471. */
  14472. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14473. }
  14474. }
  14475. declare module BABYLON {
  14476. /**
  14477. * Defines a runtime animation
  14478. */
  14479. export class RuntimeAnimation {
  14480. private _events;
  14481. /**
  14482. * The current frame of the runtime animation
  14483. */
  14484. private _currentFrame;
  14485. /**
  14486. * The animation used by the runtime animation
  14487. */
  14488. private _animation;
  14489. /**
  14490. * The target of the runtime animation
  14491. */
  14492. private _target;
  14493. /**
  14494. * The initiating animatable
  14495. */
  14496. private _host;
  14497. /**
  14498. * The original value of the runtime animation
  14499. */
  14500. private _originalValue;
  14501. /**
  14502. * The original blend value of the runtime animation
  14503. */
  14504. private _originalBlendValue;
  14505. /**
  14506. * The offsets cache of the runtime animation
  14507. */
  14508. private _offsetsCache;
  14509. /**
  14510. * The high limits cache of the runtime animation
  14511. */
  14512. private _highLimitsCache;
  14513. /**
  14514. * Specifies if the runtime animation has been stopped
  14515. */
  14516. private _stopped;
  14517. /**
  14518. * The blending factor of the runtime animation
  14519. */
  14520. private _blendingFactor;
  14521. /**
  14522. * The BabylonJS scene
  14523. */
  14524. private _scene;
  14525. /**
  14526. * The current value of the runtime animation
  14527. */
  14528. private _currentValue;
  14529. /** @hidden */
  14530. _animationState: _IAnimationState;
  14531. /**
  14532. * The active target of the runtime animation
  14533. */
  14534. private _activeTargets;
  14535. private _currentActiveTarget;
  14536. private _directTarget;
  14537. /**
  14538. * The target path of the runtime animation
  14539. */
  14540. private _targetPath;
  14541. /**
  14542. * The weight of the runtime animation
  14543. */
  14544. private _weight;
  14545. /**
  14546. * The ratio offset of the runtime animation
  14547. */
  14548. private _ratioOffset;
  14549. /**
  14550. * The previous delay of the runtime animation
  14551. */
  14552. private _previousDelay;
  14553. /**
  14554. * The previous ratio of the runtime animation
  14555. */
  14556. private _previousRatio;
  14557. private _enableBlending;
  14558. private _keys;
  14559. private _minFrame;
  14560. private _maxFrame;
  14561. private _minValue;
  14562. private _maxValue;
  14563. private _targetIsArray;
  14564. /**
  14565. * Gets the current frame of the runtime animation
  14566. */
  14567. get currentFrame(): number;
  14568. /**
  14569. * Gets the weight of the runtime animation
  14570. */
  14571. get weight(): number;
  14572. /**
  14573. * Gets the current value of the runtime animation
  14574. */
  14575. get currentValue(): any;
  14576. /**
  14577. * Gets the target path of the runtime animation
  14578. */
  14579. get targetPath(): string;
  14580. /**
  14581. * Gets the actual target of the runtime animation
  14582. */
  14583. get target(): any;
  14584. /**
  14585. * Gets the additive state of the runtime animation
  14586. */
  14587. get isAdditive(): boolean;
  14588. /** @hidden */
  14589. _onLoop: () => void;
  14590. /**
  14591. * Create a new RuntimeAnimation object
  14592. * @param target defines the target of the animation
  14593. * @param animation defines the source animation object
  14594. * @param scene defines the hosting scene
  14595. * @param host defines the initiating Animatable
  14596. */
  14597. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14598. private _preparePath;
  14599. /**
  14600. * Gets the animation from the runtime animation
  14601. */
  14602. get animation(): Animation;
  14603. /**
  14604. * Resets the runtime animation to the beginning
  14605. * @param restoreOriginal defines whether to restore the target property to the original value
  14606. */
  14607. reset(restoreOriginal?: boolean): void;
  14608. /**
  14609. * Specifies if the runtime animation is stopped
  14610. * @returns Boolean specifying if the runtime animation is stopped
  14611. */
  14612. isStopped(): boolean;
  14613. /**
  14614. * Disposes of the runtime animation
  14615. */
  14616. dispose(): void;
  14617. /**
  14618. * Apply the interpolated value to the target
  14619. * @param currentValue defines the value computed by the animation
  14620. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14621. */
  14622. setValue(currentValue: any, weight: number): void;
  14623. private _getOriginalValues;
  14624. private _setValue;
  14625. /**
  14626. * Gets the loop pmode of the runtime animation
  14627. * @returns Loop Mode
  14628. */
  14629. private _getCorrectLoopMode;
  14630. /**
  14631. * Move the current animation to a given frame
  14632. * @param frame defines the frame to move to
  14633. */
  14634. goToFrame(frame: number): void;
  14635. /**
  14636. * @hidden Internal use only
  14637. */
  14638. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14639. /**
  14640. * Execute the current animation
  14641. * @param delay defines the delay to add to the current frame
  14642. * @param from defines the lower bound of the animation range
  14643. * @param to defines the upper bound of the animation range
  14644. * @param loop defines if the current animation must loop
  14645. * @param speedRatio defines the current speed ratio
  14646. * @param weight defines the weight of the animation (default is -1 so no weight)
  14647. * @param onLoop optional callback called when animation loops
  14648. * @returns a boolean indicating if the animation is running
  14649. */
  14650. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14651. }
  14652. }
  14653. declare module BABYLON {
  14654. /**
  14655. * Class used to store an actual running animation
  14656. */
  14657. export class Animatable {
  14658. /** defines the target object */
  14659. target: any;
  14660. /** defines the starting frame number (default is 0) */
  14661. fromFrame: number;
  14662. /** defines the ending frame number (default is 100) */
  14663. toFrame: number;
  14664. /** defines if the animation must loop (default is false) */
  14665. loopAnimation: boolean;
  14666. /** defines a callback to call when animation ends if it is not looping */
  14667. onAnimationEnd?: (() => void) | null | undefined;
  14668. /** defines a callback to call when animation loops */
  14669. onAnimationLoop?: (() => void) | null | undefined;
  14670. /** defines whether the animation should be evaluated additively */
  14671. isAdditive: boolean;
  14672. private _localDelayOffset;
  14673. private _pausedDelay;
  14674. private _runtimeAnimations;
  14675. private _paused;
  14676. private _scene;
  14677. private _speedRatio;
  14678. private _weight;
  14679. private _syncRoot;
  14680. /**
  14681. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14682. * This will only apply for non looping animation (default is true)
  14683. */
  14684. disposeOnEnd: boolean;
  14685. /**
  14686. * Gets a boolean indicating if the animation has started
  14687. */
  14688. animationStarted: boolean;
  14689. /**
  14690. * Observer raised when the animation ends
  14691. */
  14692. onAnimationEndObservable: Observable<Animatable>;
  14693. /**
  14694. * Observer raised when the animation loops
  14695. */
  14696. onAnimationLoopObservable: Observable<Animatable>;
  14697. /**
  14698. * Gets the root Animatable used to synchronize and normalize animations
  14699. */
  14700. get syncRoot(): Nullable<Animatable>;
  14701. /**
  14702. * Gets the current frame of the first RuntimeAnimation
  14703. * Used to synchronize Animatables
  14704. */
  14705. get masterFrame(): number;
  14706. /**
  14707. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14708. */
  14709. get weight(): number;
  14710. set weight(value: number);
  14711. /**
  14712. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14713. */
  14714. get speedRatio(): number;
  14715. set speedRatio(value: number);
  14716. /**
  14717. * Creates a new Animatable
  14718. * @param scene defines the hosting scene
  14719. * @param target defines the target object
  14720. * @param fromFrame defines the starting frame number (default is 0)
  14721. * @param toFrame defines the ending frame number (default is 100)
  14722. * @param loopAnimation defines if the animation must loop (default is false)
  14723. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14724. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14725. * @param animations defines a group of animation to add to the new Animatable
  14726. * @param onAnimationLoop defines a callback to call when animation loops
  14727. * @param isAdditive defines whether the animation should be evaluated additively
  14728. */
  14729. constructor(scene: Scene,
  14730. /** defines the target object */
  14731. target: any,
  14732. /** defines the starting frame number (default is 0) */
  14733. fromFrame?: number,
  14734. /** defines the ending frame number (default is 100) */
  14735. toFrame?: number,
  14736. /** defines if the animation must loop (default is false) */
  14737. loopAnimation?: boolean, speedRatio?: number,
  14738. /** defines a callback to call when animation ends if it is not looping */
  14739. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14740. /** defines a callback to call when animation loops */
  14741. onAnimationLoop?: (() => void) | null | undefined,
  14742. /** defines whether the animation should be evaluated additively */
  14743. isAdditive?: boolean);
  14744. /**
  14745. * Synchronize and normalize current Animatable with a source Animatable
  14746. * This is useful when using animation weights and when animations are not of the same length
  14747. * @param root defines the root Animatable to synchronize with
  14748. * @returns the current Animatable
  14749. */
  14750. syncWith(root: Animatable): Animatable;
  14751. /**
  14752. * Gets the list of runtime animations
  14753. * @returns an array of RuntimeAnimation
  14754. */
  14755. getAnimations(): RuntimeAnimation[];
  14756. /**
  14757. * Adds more animations to the current animatable
  14758. * @param target defines the target of the animations
  14759. * @param animations defines the new animations to add
  14760. */
  14761. appendAnimations(target: any, animations: Animation[]): void;
  14762. /**
  14763. * Gets the source animation for a specific property
  14764. * @param property defines the propertyu to look for
  14765. * @returns null or the source animation for the given property
  14766. */
  14767. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14768. /**
  14769. * Gets the runtime animation for a specific property
  14770. * @param property defines the propertyu to look for
  14771. * @returns null or the runtime animation for the given property
  14772. */
  14773. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14774. /**
  14775. * Resets the animatable to its original state
  14776. */
  14777. reset(): void;
  14778. /**
  14779. * Allows the animatable to blend with current running animations
  14780. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14781. * @param blendingSpeed defines the blending speed to use
  14782. */
  14783. enableBlending(blendingSpeed: number): void;
  14784. /**
  14785. * Disable animation blending
  14786. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14787. */
  14788. disableBlending(): void;
  14789. /**
  14790. * Jump directly to a given frame
  14791. * @param frame defines the frame to jump to
  14792. */
  14793. goToFrame(frame: number): void;
  14794. /**
  14795. * Pause the animation
  14796. */
  14797. pause(): void;
  14798. /**
  14799. * Restart the animation
  14800. */
  14801. restart(): void;
  14802. private _raiseOnAnimationEnd;
  14803. /**
  14804. * Stop and delete the current animation
  14805. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14806. * @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)
  14807. */
  14808. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14809. /**
  14810. * Wait asynchronously for the animation to end
  14811. * @returns a promise which will be fullfilled when the animation ends
  14812. */
  14813. waitAsync(): Promise<Animatable>;
  14814. /** @hidden */
  14815. _animate(delay: number): boolean;
  14816. }
  14817. interface Scene {
  14818. /** @hidden */
  14819. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14820. /** @hidden */
  14821. _processLateAnimationBindingsForMatrices(holder: {
  14822. totalWeight: number;
  14823. totalAdditiveWeight: number;
  14824. animations: RuntimeAnimation[];
  14825. additiveAnimations: RuntimeAnimation[];
  14826. originalValue: Matrix;
  14827. }): any;
  14828. /** @hidden */
  14829. _processLateAnimationBindingsForQuaternions(holder: {
  14830. totalWeight: number;
  14831. totalAdditiveWeight: number;
  14832. animations: RuntimeAnimation[];
  14833. additiveAnimations: RuntimeAnimation[];
  14834. originalValue: Quaternion;
  14835. }, refQuaternion: Quaternion): Quaternion;
  14836. /** @hidden */
  14837. _processLateAnimationBindings(): void;
  14838. /**
  14839. * Will start the animation sequence of a given target
  14840. * @param target defines the target
  14841. * @param from defines from which frame should animation start
  14842. * @param to defines until which frame should animation run.
  14843. * @param weight defines the weight to apply to the animation (1.0 by default)
  14844. * @param loop defines if the animation loops
  14845. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14846. * @param onAnimationEnd defines the function to be executed when the animation ends
  14847. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14848. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14849. * @param onAnimationLoop defines the callback to call when an animation loops
  14850. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14851. * @returns the animatable object created for this animation
  14852. */
  14853. 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;
  14854. /**
  14855. * Will start the animation sequence of a given target
  14856. * @param target defines the target
  14857. * @param from defines from which frame should animation start
  14858. * @param to defines until which frame should animation run.
  14859. * @param loop defines if the animation loops
  14860. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14861. * @param onAnimationEnd defines the function to be executed when the animation ends
  14862. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14863. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14864. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14865. * @param onAnimationLoop defines the callback to call when an animation loops
  14866. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14867. * @returns the animatable object created for this animation
  14868. */
  14869. 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;
  14870. /**
  14871. * Will start the animation sequence of a given target and its hierarchy
  14872. * @param target defines the target
  14873. * @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.
  14874. * @param from defines from which frame should animation start
  14875. * @param to defines until which frame should animation run.
  14876. * @param loop defines if the animation loops
  14877. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14878. * @param onAnimationEnd defines the function to be executed when the animation ends
  14879. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14880. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14881. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14882. * @param onAnimationLoop defines the callback to call when an animation loops
  14883. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14884. * @returns the list of created animatables
  14885. */
  14886. 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[];
  14887. /**
  14888. * Begin a new animation on a given node
  14889. * @param target defines the target where the animation will take place
  14890. * @param animations defines the list of animations to start
  14891. * @param from defines the initial value
  14892. * @param to defines the final value
  14893. * @param loop defines if you want animation to loop (off by default)
  14894. * @param speedRatio defines the speed ratio to apply to all animations
  14895. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14896. * @param onAnimationLoop defines the callback to call when an animation loops
  14897. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14898. * @returns the list of created animatables
  14899. */
  14900. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14901. /**
  14902. * Begin a new animation on a given node and its hierarchy
  14903. * @param target defines the root node where the animation will take place
  14904. * @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.
  14905. * @param animations defines the list of animations to start
  14906. * @param from defines the initial value
  14907. * @param to defines the final value
  14908. * @param loop defines if you want animation to loop (off by default)
  14909. * @param speedRatio defines the speed ratio to apply to all animations
  14910. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14911. * @param onAnimationLoop defines the callback to call when an animation loops
  14912. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14913. * @returns the list of animatables created for all nodes
  14914. */
  14915. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14916. /**
  14917. * Gets the animatable associated with a specific target
  14918. * @param target defines the target of the animatable
  14919. * @returns the required animatable if found
  14920. */
  14921. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14922. /**
  14923. * Gets all animatables associated with a given target
  14924. * @param target defines the target to look animatables for
  14925. * @returns an array of Animatables
  14926. */
  14927. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14928. /**
  14929. * Stops and removes all animations that have been applied to the scene
  14930. */
  14931. stopAllAnimations(): void;
  14932. /**
  14933. * Gets the current delta time used by animation engine
  14934. */
  14935. deltaTime: number;
  14936. }
  14937. interface Bone {
  14938. /**
  14939. * Copy an animation range from another bone
  14940. * @param source defines the source bone
  14941. * @param rangeName defines the range name to copy
  14942. * @param frameOffset defines the frame offset
  14943. * @param rescaleAsRequired defines if rescaling must be applied if required
  14944. * @param skelDimensionsRatio defines the scaling ratio
  14945. * @returns true if operation was successful
  14946. */
  14947. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14948. }
  14949. }
  14950. declare module BABYLON {
  14951. /**
  14952. * Class used to handle skinning animations
  14953. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14954. */
  14955. export class Skeleton implements IAnimatable {
  14956. /** defines the skeleton name */
  14957. name: string;
  14958. /** defines the skeleton Id */
  14959. id: string;
  14960. /**
  14961. * Defines the list of child bones
  14962. */
  14963. bones: Bone[];
  14964. /**
  14965. * Defines an estimate of the dimension of the skeleton at rest
  14966. */
  14967. dimensionsAtRest: Vector3;
  14968. /**
  14969. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14970. */
  14971. needInitialSkinMatrix: boolean;
  14972. /**
  14973. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14974. */
  14975. overrideMesh: Nullable<AbstractMesh>;
  14976. /**
  14977. * Gets the list of animations attached to this skeleton
  14978. */
  14979. animations: Array<Animation>;
  14980. private _scene;
  14981. private _isDirty;
  14982. private _transformMatrices;
  14983. private _transformMatrixTexture;
  14984. private _meshesWithPoseMatrix;
  14985. private _animatables;
  14986. private _identity;
  14987. private _synchronizedWithMesh;
  14988. private _ranges;
  14989. private _lastAbsoluteTransformsUpdateId;
  14990. private _canUseTextureForBones;
  14991. private _uniqueId;
  14992. /** @hidden */
  14993. _numBonesWithLinkedTransformNode: number;
  14994. /** @hidden */
  14995. _hasWaitingData: Nullable<boolean>;
  14996. /**
  14997. * Specifies if the skeleton should be serialized
  14998. */
  14999. doNotSerialize: boolean;
  15000. private _useTextureToStoreBoneMatrices;
  15001. /**
  15002. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15003. * Please note that this option is not available if the hardware does not support it
  15004. */
  15005. get useTextureToStoreBoneMatrices(): boolean;
  15006. set useTextureToStoreBoneMatrices(value: boolean);
  15007. private _animationPropertiesOverride;
  15008. /**
  15009. * Gets or sets the animation properties override
  15010. */
  15011. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15012. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15013. /**
  15014. * List of inspectable custom properties (used by the Inspector)
  15015. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15016. */
  15017. inspectableCustomProperties: IInspectable[];
  15018. /**
  15019. * An observable triggered before computing the skeleton's matrices
  15020. */
  15021. onBeforeComputeObservable: Observable<Skeleton>;
  15022. /**
  15023. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15024. */
  15025. get isUsingTextureForMatrices(): boolean;
  15026. /**
  15027. * Gets the unique ID of this skeleton
  15028. */
  15029. get uniqueId(): number;
  15030. /**
  15031. * Creates a new skeleton
  15032. * @param name defines the skeleton name
  15033. * @param id defines the skeleton Id
  15034. * @param scene defines the hosting scene
  15035. */
  15036. constructor(
  15037. /** defines the skeleton name */
  15038. name: string,
  15039. /** defines the skeleton Id */
  15040. id: string, scene: Scene);
  15041. /**
  15042. * Gets the current object class name.
  15043. * @return the class name
  15044. */
  15045. getClassName(): string;
  15046. /**
  15047. * Returns an array containing the root bones
  15048. * @returns an array containing the root bones
  15049. */
  15050. getChildren(): Array<Bone>;
  15051. /**
  15052. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15053. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15054. * @returns a Float32Array containing matrices data
  15055. */
  15056. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15057. /**
  15058. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15059. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15060. * @returns a raw texture containing the data
  15061. */
  15062. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15063. /**
  15064. * Gets the current hosting scene
  15065. * @returns a scene object
  15066. */
  15067. getScene(): Scene;
  15068. /**
  15069. * Gets a string representing the current skeleton data
  15070. * @param fullDetails defines a boolean indicating if we want a verbose version
  15071. * @returns a string representing the current skeleton data
  15072. */
  15073. toString(fullDetails?: boolean): string;
  15074. /**
  15075. * Get bone's index searching by name
  15076. * @param name defines bone's name to search for
  15077. * @return the indice of the bone. Returns -1 if not found
  15078. */
  15079. getBoneIndexByName(name: string): number;
  15080. /**
  15081. * Creater a new animation range
  15082. * @param name defines the name of the range
  15083. * @param from defines the start key
  15084. * @param to defines the end key
  15085. */
  15086. createAnimationRange(name: string, from: number, to: number): void;
  15087. /**
  15088. * Delete a specific animation range
  15089. * @param name defines the name of the range
  15090. * @param deleteFrames defines if frames must be removed as well
  15091. */
  15092. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15093. /**
  15094. * Gets a specific animation range
  15095. * @param name defines the name of the range to look for
  15096. * @returns the requested animation range or null if not found
  15097. */
  15098. getAnimationRange(name: string): Nullable<AnimationRange>;
  15099. /**
  15100. * Gets the list of all animation ranges defined on this skeleton
  15101. * @returns an array
  15102. */
  15103. getAnimationRanges(): Nullable<AnimationRange>[];
  15104. /**
  15105. * Copy animation range from a source skeleton.
  15106. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15107. * @param source defines the source skeleton
  15108. * @param name defines the name of the range to copy
  15109. * @param rescaleAsRequired defines if rescaling must be applied if required
  15110. * @returns true if operation was successful
  15111. */
  15112. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15113. /**
  15114. * Forces the skeleton to go to rest pose
  15115. */
  15116. returnToRest(): void;
  15117. private _getHighestAnimationFrame;
  15118. /**
  15119. * Begin a specific animation range
  15120. * @param name defines the name of the range to start
  15121. * @param loop defines if looping must be turned on (false by default)
  15122. * @param speedRatio defines the speed ratio to apply (1 by default)
  15123. * @param onAnimationEnd defines a callback which will be called when animation will end
  15124. * @returns a new animatable
  15125. */
  15126. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15127. /**
  15128. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15129. * @param skeleton defines the Skeleton containing the animation range to convert
  15130. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15131. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15132. * @returns the original skeleton
  15133. */
  15134. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15135. /** @hidden */
  15136. _markAsDirty(): void;
  15137. /** @hidden */
  15138. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15139. /** @hidden */
  15140. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15141. private _computeTransformMatrices;
  15142. /**
  15143. * Build all resources required to render a skeleton
  15144. */
  15145. prepare(): void;
  15146. /**
  15147. * Gets the list of animatables currently running for this skeleton
  15148. * @returns an array of animatables
  15149. */
  15150. getAnimatables(): IAnimatable[];
  15151. /**
  15152. * Clone the current skeleton
  15153. * @param name defines the name of the new skeleton
  15154. * @param id defines the id of the new skeleton
  15155. * @returns the new skeleton
  15156. */
  15157. clone(name: string, id?: string): Skeleton;
  15158. /**
  15159. * Enable animation blending for this skeleton
  15160. * @param blendingSpeed defines the blending speed to apply
  15161. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15162. */
  15163. enableBlending(blendingSpeed?: number): void;
  15164. /**
  15165. * Releases all resources associated with the current skeleton
  15166. */
  15167. dispose(): void;
  15168. /**
  15169. * Serialize the skeleton in a JSON object
  15170. * @returns a JSON object
  15171. */
  15172. serialize(): any;
  15173. /**
  15174. * Creates a new skeleton from serialized data
  15175. * @param parsedSkeleton defines the serialized data
  15176. * @param scene defines the hosting scene
  15177. * @returns a new skeleton
  15178. */
  15179. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15180. /**
  15181. * Compute all node absolute transforms
  15182. * @param forceUpdate defines if computation must be done even if cache is up to date
  15183. */
  15184. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15185. /**
  15186. * Gets the root pose matrix
  15187. * @returns a matrix
  15188. */
  15189. getPoseMatrix(): Nullable<Matrix>;
  15190. /**
  15191. * Sorts bones per internal index
  15192. */
  15193. sortBones(): void;
  15194. private _sortBones;
  15195. }
  15196. }
  15197. declare module BABYLON {
  15198. /**
  15199. * Creates an instance based on a source mesh.
  15200. */
  15201. export class InstancedMesh extends AbstractMesh {
  15202. private _sourceMesh;
  15203. private _currentLOD;
  15204. /** @hidden */
  15205. _indexInSourceMeshInstanceArray: number;
  15206. constructor(name: string, source: Mesh);
  15207. /**
  15208. * Returns the string "InstancedMesh".
  15209. */
  15210. getClassName(): string;
  15211. /** Gets the list of lights affecting that mesh */
  15212. get lightSources(): Light[];
  15213. _resyncLightSources(): void;
  15214. _resyncLightSource(light: Light): void;
  15215. _removeLightSource(light: Light, dispose: boolean): void;
  15216. /**
  15217. * If the source mesh receives shadows
  15218. */
  15219. get receiveShadows(): boolean;
  15220. /**
  15221. * The material of the source mesh
  15222. */
  15223. get material(): Nullable<Material>;
  15224. /**
  15225. * Visibility of the source mesh
  15226. */
  15227. get visibility(): number;
  15228. /**
  15229. * Skeleton of the source mesh
  15230. */
  15231. get skeleton(): Nullable<Skeleton>;
  15232. /**
  15233. * Rendering ground id of the source mesh
  15234. */
  15235. get renderingGroupId(): number;
  15236. set renderingGroupId(value: number);
  15237. /**
  15238. * Returns the total number of vertices (integer).
  15239. */
  15240. getTotalVertices(): number;
  15241. /**
  15242. * Returns a positive integer : the total number of indices in this mesh geometry.
  15243. * @returns the numner of indices or zero if the mesh has no geometry.
  15244. */
  15245. getTotalIndices(): number;
  15246. /**
  15247. * The source mesh of the instance
  15248. */
  15249. get sourceMesh(): Mesh;
  15250. /**
  15251. * Is this node ready to be used/rendered
  15252. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15253. * @return {boolean} is it ready
  15254. */
  15255. isReady(completeCheck?: boolean): boolean;
  15256. /**
  15257. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15258. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15259. * @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.
  15260. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15261. */
  15262. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15263. /**
  15264. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15265. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15266. * The `data` are either a numeric array either a Float32Array.
  15267. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15268. * 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).
  15269. * Note that a new underlying VertexBuffer object is created each call.
  15270. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15271. *
  15272. * Possible `kind` values :
  15273. * - VertexBuffer.PositionKind
  15274. * - VertexBuffer.UVKind
  15275. * - VertexBuffer.UV2Kind
  15276. * - VertexBuffer.UV3Kind
  15277. * - VertexBuffer.UV4Kind
  15278. * - VertexBuffer.UV5Kind
  15279. * - VertexBuffer.UV6Kind
  15280. * - VertexBuffer.ColorKind
  15281. * - VertexBuffer.MatricesIndicesKind
  15282. * - VertexBuffer.MatricesIndicesExtraKind
  15283. * - VertexBuffer.MatricesWeightsKind
  15284. * - VertexBuffer.MatricesWeightsExtraKind
  15285. *
  15286. * Returns the Mesh.
  15287. */
  15288. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15289. /**
  15290. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15291. * If the mesh has no geometry, it is simply returned as it is.
  15292. * The `data` are either a numeric array either a Float32Array.
  15293. * No new underlying VertexBuffer object is created.
  15294. * 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.
  15295. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15296. *
  15297. * Possible `kind` values :
  15298. * - VertexBuffer.PositionKind
  15299. * - VertexBuffer.UVKind
  15300. * - VertexBuffer.UV2Kind
  15301. * - VertexBuffer.UV3Kind
  15302. * - VertexBuffer.UV4Kind
  15303. * - VertexBuffer.UV5Kind
  15304. * - VertexBuffer.UV6Kind
  15305. * - VertexBuffer.ColorKind
  15306. * - VertexBuffer.MatricesIndicesKind
  15307. * - VertexBuffer.MatricesIndicesExtraKind
  15308. * - VertexBuffer.MatricesWeightsKind
  15309. * - VertexBuffer.MatricesWeightsExtraKind
  15310. *
  15311. * Returns the Mesh.
  15312. */
  15313. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15314. /**
  15315. * Sets the mesh indices.
  15316. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15317. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15318. * This method creates a new index buffer each call.
  15319. * Returns the Mesh.
  15320. */
  15321. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15322. /**
  15323. * Boolean : True if the mesh owns the requested kind of data.
  15324. */
  15325. isVerticesDataPresent(kind: string): boolean;
  15326. /**
  15327. * Returns an array of indices (IndicesArray).
  15328. */
  15329. getIndices(): Nullable<IndicesArray>;
  15330. get _positions(): Nullable<Vector3[]>;
  15331. /**
  15332. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15333. * This means the mesh underlying bounding box and sphere are recomputed.
  15334. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15335. * @returns the current mesh
  15336. */
  15337. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15338. /** @hidden */
  15339. _preActivate(): InstancedMesh;
  15340. /** @hidden */
  15341. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15342. /** @hidden */
  15343. _postActivate(): void;
  15344. getWorldMatrix(): Matrix;
  15345. get isAnInstance(): boolean;
  15346. /**
  15347. * Returns the current associated LOD AbstractMesh.
  15348. */
  15349. getLOD(camera: Camera): AbstractMesh;
  15350. /** @hidden */
  15351. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15352. /** @hidden */
  15353. _syncSubMeshes(): InstancedMesh;
  15354. /** @hidden */
  15355. _generatePointsArray(): boolean;
  15356. /**
  15357. * Creates a new InstancedMesh from the current mesh.
  15358. * - name (string) : the cloned mesh name
  15359. * - newParent (optional Node) : the optional Node to parent the clone to.
  15360. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15361. *
  15362. * Returns the clone.
  15363. */
  15364. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15365. /**
  15366. * Disposes the InstancedMesh.
  15367. * Returns nothing.
  15368. */
  15369. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15370. }
  15371. interface Mesh {
  15372. /**
  15373. * Register a custom buffer that will be instanced
  15374. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15375. * @param kind defines the buffer kind
  15376. * @param stride defines the stride in floats
  15377. */
  15378. registerInstancedBuffer(kind: string, stride: number): void;
  15379. /** @hidden */
  15380. _userInstancedBuffersStorage: {
  15381. data: {
  15382. [key: string]: Float32Array;
  15383. };
  15384. sizes: {
  15385. [key: string]: number;
  15386. };
  15387. vertexBuffers: {
  15388. [key: string]: Nullable<VertexBuffer>;
  15389. };
  15390. strides: {
  15391. [key: string]: number;
  15392. };
  15393. };
  15394. }
  15395. interface AbstractMesh {
  15396. /**
  15397. * Object used to store instanced buffers defined by user
  15398. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15399. */
  15400. instancedBuffers: {
  15401. [key: string]: any;
  15402. };
  15403. }
  15404. }
  15405. declare module BABYLON {
  15406. /**
  15407. * Defines the options associated with the creation of a shader material.
  15408. */
  15409. export interface IShaderMaterialOptions {
  15410. /**
  15411. * Does the material work in alpha blend mode
  15412. */
  15413. needAlphaBlending: boolean;
  15414. /**
  15415. * Does the material work in alpha test mode
  15416. */
  15417. needAlphaTesting: boolean;
  15418. /**
  15419. * The list of attribute names used in the shader
  15420. */
  15421. attributes: string[];
  15422. /**
  15423. * The list of unifrom names used in the shader
  15424. */
  15425. uniforms: string[];
  15426. /**
  15427. * The list of UBO names used in the shader
  15428. */
  15429. uniformBuffers: string[];
  15430. /**
  15431. * The list of sampler names used in the shader
  15432. */
  15433. samplers: string[];
  15434. /**
  15435. * The list of defines used in the shader
  15436. */
  15437. defines: string[];
  15438. }
  15439. /**
  15440. * 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.
  15441. *
  15442. * This returned material effects how the mesh will look based on the code in the shaders.
  15443. *
  15444. * @see http://doc.babylonjs.com/how_to/shader_material
  15445. */
  15446. export class ShaderMaterial extends Material {
  15447. private _shaderPath;
  15448. private _options;
  15449. private _textures;
  15450. private _textureArrays;
  15451. private _floats;
  15452. private _ints;
  15453. private _floatsArrays;
  15454. private _colors3;
  15455. private _colors3Arrays;
  15456. private _colors4;
  15457. private _colors4Arrays;
  15458. private _vectors2;
  15459. private _vectors3;
  15460. private _vectors4;
  15461. private _matrices;
  15462. private _matrixArrays;
  15463. private _matrices3x3;
  15464. private _matrices2x2;
  15465. private _vectors2Arrays;
  15466. private _vectors3Arrays;
  15467. private _vectors4Arrays;
  15468. private _cachedWorldViewMatrix;
  15469. private _cachedWorldViewProjectionMatrix;
  15470. private _renderId;
  15471. private _multiview;
  15472. /**
  15473. * Instantiate a new shader material.
  15474. * 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.
  15475. * This returned material effects how the mesh will look based on the code in the shaders.
  15476. * @see http://doc.babylonjs.com/how_to/shader_material
  15477. * @param name Define the name of the material in the scene
  15478. * @param scene Define the scene the material belongs to
  15479. * @param shaderPath Defines the route to the shader code in one of three ways:
  15480. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15481. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15482. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15483. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15484. * @param options Define the options used to create the shader
  15485. */
  15486. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15487. /**
  15488. * Gets the shader path used to define the shader code
  15489. * It can be modified to trigger a new compilation
  15490. */
  15491. get shaderPath(): any;
  15492. /**
  15493. * Sets the shader path used to define the shader code
  15494. * It can be modified to trigger a new compilation
  15495. */
  15496. set shaderPath(shaderPath: any);
  15497. /**
  15498. * Gets the options used to compile the shader.
  15499. * They can be modified to trigger a new compilation
  15500. */
  15501. get options(): IShaderMaterialOptions;
  15502. /**
  15503. * Gets the current class name of the material e.g. "ShaderMaterial"
  15504. * Mainly use in serialization.
  15505. * @returns the class name
  15506. */
  15507. getClassName(): string;
  15508. /**
  15509. * Specifies if the material will require alpha blending
  15510. * @returns a boolean specifying if alpha blending is needed
  15511. */
  15512. needAlphaBlending(): boolean;
  15513. /**
  15514. * Specifies if this material should be rendered in alpha test mode
  15515. * @returns a boolean specifying if an alpha test is needed.
  15516. */
  15517. needAlphaTesting(): boolean;
  15518. private _checkUniform;
  15519. /**
  15520. * Set a texture in the shader.
  15521. * @param name Define the name of the uniform samplers as defined in the shader
  15522. * @param texture Define the texture to bind to this sampler
  15523. * @return the material itself allowing "fluent" like uniform updates
  15524. */
  15525. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15526. /**
  15527. * Set a texture array in the shader.
  15528. * @param name Define the name of the uniform sampler array as defined in the shader
  15529. * @param textures Define the list of textures to bind to this sampler
  15530. * @return the material itself allowing "fluent" like uniform updates
  15531. */
  15532. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15533. /**
  15534. * Set a float in the shader.
  15535. * @param name Define the name of the uniform as defined in the shader
  15536. * @param value Define the value to give to the uniform
  15537. * @return the material itself allowing "fluent" like uniform updates
  15538. */
  15539. setFloat(name: string, value: number): ShaderMaterial;
  15540. /**
  15541. * Set a int in the shader.
  15542. * @param name Define the name of the uniform as defined in the shader
  15543. * @param value Define the value to give to the uniform
  15544. * @return the material itself allowing "fluent" like uniform updates
  15545. */
  15546. setInt(name: string, value: number): ShaderMaterial;
  15547. /**
  15548. * Set an array of floats in the shader.
  15549. * @param name Define the name of the uniform as defined in the shader
  15550. * @param value Define the value to give to the uniform
  15551. * @return the material itself allowing "fluent" like uniform updates
  15552. */
  15553. setFloats(name: string, value: number[]): ShaderMaterial;
  15554. /**
  15555. * Set a vec3 in the shader from a Color3.
  15556. * @param name Define the name of the uniform as defined in the shader
  15557. * @param value Define the value to give to the uniform
  15558. * @return the material itself allowing "fluent" like uniform updates
  15559. */
  15560. setColor3(name: string, value: Color3): ShaderMaterial;
  15561. /**
  15562. * Set a vec3 array in the shader from a Color3 array.
  15563. * @param name Define the name of the uniform as defined in the shader
  15564. * @param value Define the value to give to the uniform
  15565. * @return the material itself allowing "fluent" like uniform updates
  15566. */
  15567. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15568. /**
  15569. * Set a vec4 in the shader from a Color4.
  15570. * @param name Define the name of the uniform as defined in the shader
  15571. * @param value Define the value to give to the uniform
  15572. * @return the material itself allowing "fluent" like uniform updates
  15573. */
  15574. setColor4(name: string, value: Color4): ShaderMaterial;
  15575. /**
  15576. * Set a vec4 array in the shader from a Color4 array.
  15577. * @param name Define the name of the uniform as defined in the shader
  15578. * @param value Define the value to give to the uniform
  15579. * @return the material itself allowing "fluent" like uniform updates
  15580. */
  15581. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15582. /**
  15583. * Set a vec2 in the shader from a Vector2.
  15584. * @param name Define the name of the uniform as defined in the shader
  15585. * @param value Define the value to give to the uniform
  15586. * @return the material itself allowing "fluent" like uniform updates
  15587. */
  15588. setVector2(name: string, value: Vector2): ShaderMaterial;
  15589. /**
  15590. * Set a vec3 in the shader from a Vector3.
  15591. * @param name Define the name of the uniform as defined in the shader
  15592. * @param value Define the value to give to the uniform
  15593. * @return the material itself allowing "fluent" like uniform updates
  15594. */
  15595. setVector3(name: string, value: Vector3): ShaderMaterial;
  15596. /**
  15597. * Set a vec4 in the shader from a Vector4.
  15598. * @param name Define the name of the uniform as defined in the shader
  15599. * @param value Define the value to give to the uniform
  15600. * @return the material itself allowing "fluent" like uniform updates
  15601. */
  15602. setVector4(name: string, value: Vector4): ShaderMaterial;
  15603. /**
  15604. * Set a mat4 in the shader from a Matrix.
  15605. * @param name Define the name of the uniform as defined in the shader
  15606. * @param value Define the value to give to the uniform
  15607. * @return the material itself allowing "fluent" like uniform updates
  15608. */
  15609. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15610. /**
  15611. * Set a float32Array in the shader from a matrix array.
  15612. * @param name Define the name of the uniform as defined in the shader
  15613. * @param value Define the value to give to the uniform
  15614. * @return the material itself allowing "fluent" like uniform updates
  15615. */
  15616. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15617. /**
  15618. * Set a mat3 in the shader from a Float32Array.
  15619. * @param name Define the name of the uniform as defined in the shader
  15620. * @param value Define the value to give to the uniform
  15621. * @return the material itself allowing "fluent" like uniform updates
  15622. */
  15623. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15624. /**
  15625. * Set a mat2 in the shader from a Float32Array.
  15626. * @param name Define the name of the uniform as defined in the shader
  15627. * @param value Define the value to give to the uniform
  15628. * @return the material itself allowing "fluent" like uniform updates
  15629. */
  15630. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15631. /**
  15632. * Set a vec2 array in the shader from a number array.
  15633. * @param name Define the name of the uniform as defined in the shader
  15634. * @param value Define the value to give to the uniform
  15635. * @return the material itself allowing "fluent" like uniform updates
  15636. */
  15637. setArray2(name: string, value: number[]): ShaderMaterial;
  15638. /**
  15639. * Set a vec3 array in the shader from a number array.
  15640. * @param name Define the name of the uniform as defined in the shader
  15641. * @param value Define the value to give to the uniform
  15642. * @return the material itself allowing "fluent" like uniform updates
  15643. */
  15644. setArray3(name: string, value: number[]): ShaderMaterial;
  15645. /**
  15646. * Set a vec4 array in the shader from a number array.
  15647. * @param name Define the name of the uniform as defined in the shader
  15648. * @param value Define the value to give to the uniform
  15649. * @return the material itself allowing "fluent" like uniform updates
  15650. */
  15651. setArray4(name: string, value: number[]): ShaderMaterial;
  15652. private _checkCache;
  15653. /**
  15654. * Specifies that the submesh is ready to be used
  15655. * @param mesh defines the mesh to check
  15656. * @param subMesh defines which submesh to check
  15657. * @param useInstances specifies that instances should be used
  15658. * @returns a boolean indicating that the submesh is ready or not
  15659. */
  15660. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15661. /**
  15662. * Checks if the material is ready to render the requested mesh
  15663. * @param mesh Define the mesh to render
  15664. * @param useInstances Define whether or not the material is used with instances
  15665. * @returns true if ready, otherwise false
  15666. */
  15667. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15668. /**
  15669. * Binds the world matrix to the material
  15670. * @param world defines the world transformation matrix
  15671. */
  15672. bindOnlyWorldMatrix(world: Matrix): void;
  15673. /**
  15674. * Binds the material to the mesh
  15675. * @param world defines the world transformation matrix
  15676. * @param mesh defines the mesh to bind the material to
  15677. */
  15678. bind(world: Matrix, mesh?: Mesh): void;
  15679. /**
  15680. * Gets the active textures from the material
  15681. * @returns an array of textures
  15682. */
  15683. getActiveTextures(): BaseTexture[];
  15684. /**
  15685. * Specifies if the material uses a texture
  15686. * @param texture defines the texture to check against the material
  15687. * @returns a boolean specifying if the material uses the texture
  15688. */
  15689. hasTexture(texture: BaseTexture): boolean;
  15690. /**
  15691. * Makes a duplicate of the material, and gives it a new name
  15692. * @param name defines the new name for the duplicated material
  15693. * @returns the cloned material
  15694. */
  15695. clone(name: string): ShaderMaterial;
  15696. /**
  15697. * Disposes the material
  15698. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15699. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15700. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15701. */
  15702. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15703. /**
  15704. * Serializes this material in a JSON representation
  15705. * @returns the serialized material object
  15706. */
  15707. serialize(): any;
  15708. /**
  15709. * Creates a shader material from parsed shader material data
  15710. * @param source defines the JSON represnetation of the material
  15711. * @param scene defines the hosting scene
  15712. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15713. * @returns a new material
  15714. */
  15715. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15716. }
  15717. }
  15718. declare module BABYLON {
  15719. /** @hidden */
  15720. export var colorPixelShader: {
  15721. name: string;
  15722. shader: string;
  15723. };
  15724. }
  15725. declare module BABYLON {
  15726. /** @hidden */
  15727. export var colorVertexShader: {
  15728. name: string;
  15729. shader: string;
  15730. };
  15731. }
  15732. declare module BABYLON {
  15733. /**
  15734. * Line mesh
  15735. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15736. */
  15737. export class LinesMesh extends Mesh {
  15738. /**
  15739. * If vertex color should be applied to the mesh
  15740. */
  15741. readonly useVertexColor?: boolean | undefined;
  15742. /**
  15743. * If vertex alpha should be applied to the mesh
  15744. */
  15745. readonly useVertexAlpha?: boolean | undefined;
  15746. /**
  15747. * Color of the line (Default: White)
  15748. */
  15749. color: Color3;
  15750. /**
  15751. * Alpha of the line (Default: 1)
  15752. */
  15753. alpha: number;
  15754. /**
  15755. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15756. * This margin is expressed in world space coordinates, so its value may vary.
  15757. * Default value is 0.1
  15758. */
  15759. intersectionThreshold: number;
  15760. private _colorShader;
  15761. private color4;
  15762. /**
  15763. * Creates a new LinesMesh
  15764. * @param name defines the name
  15765. * @param scene defines the hosting scene
  15766. * @param parent defines the parent mesh if any
  15767. * @param source defines the optional source LinesMesh used to clone data from
  15768. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15769. * When false, achieved by calling a clone(), also passing False.
  15770. * This will make creation of children, recursive.
  15771. * @param useVertexColor defines if this LinesMesh supports vertex color
  15772. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15773. */
  15774. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15775. /**
  15776. * If vertex color should be applied to the mesh
  15777. */
  15778. useVertexColor?: boolean | undefined,
  15779. /**
  15780. * If vertex alpha should be applied to the mesh
  15781. */
  15782. useVertexAlpha?: boolean | undefined);
  15783. private _addClipPlaneDefine;
  15784. private _removeClipPlaneDefine;
  15785. isReady(): boolean;
  15786. /**
  15787. * Returns the string "LineMesh"
  15788. */
  15789. getClassName(): string;
  15790. /**
  15791. * @hidden
  15792. */
  15793. get material(): Material;
  15794. /**
  15795. * @hidden
  15796. */
  15797. set material(value: Material);
  15798. /**
  15799. * @hidden
  15800. */
  15801. get checkCollisions(): boolean;
  15802. /** @hidden */
  15803. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15804. /** @hidden */
  15805. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15806. /**
  15807. * Disposes of the line mesh
  15808. * @param doNotRecurse If children should be disposed
  15809. */
  15810. dispose(doNotRecurse?: boolean): void;
  15811. /**
  15812. * Returns a new LineMesh object cloned from the current one.
  15813. */
  15814. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15815. /**
  15816. * Creates a new InstancedLinesMesh object from the mesh model.
  15817. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15818. * @param name defines the name of the new instance
  15819. * @returns a new InstancedLinesMesh
  15820. */
  15821. createInstance(name: string): InstancedLinesMesh;
  15822. }
  15823. /**
  15824. * Creates an instance based on a source LinesMesh
  15825. */
  15826. export class InstancedLinesMesh extends InstancedMesh {
  15827. /**
  15828. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15829. * This margin is expressed in world space coordinates, so its value may vary.
  15830. * Initilized with the intersectionThreshold value of the source LinesMesh
  15831. */
  15832. intersectionThreshold: number;
  15833. constructor(name: string, source: LinesMesh);
  15834. /**
  15835. * Returns the string "InstancedLinesMesh".
  15836. */
  15837. getClassName(): string;
  15838. }
  15839. }
  15840. declare module BABYLON {
  15841. /** @hidden */
  15842. export var linePixelShader: {
  15843. name: string;
  15844. shader: string;
  15845. };
  15846. }
  15847. declare module BABYLON {
  15848. /** @hidden */
  15849. export var lineVertexShader: {
  15850. name: string;
  15851. shader: string;
  15852. };
  15853. }
  15854. declare module BABYLON {
  15855. interface AbstractMesh {
  15856. /**
  15857. * Gets the edgesRenderer associated with the mesh
  15858. */
  15859. edgesRenderer: Nullable<EdgesRenderer>;
  15860. }
  15861. interface LinesMesh {
  15862. /**
  15863. * Enables the edge rendering mode on the mesh.
  15864. * This mode makes the mesh edges visible
  15865. * @param epsilon defines the maximal distance between two angles to detect a face
  15866. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15867. * @returns the currentAbstractMesh
  15868. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15869. */
  15870. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15871. }
  15872. interface InstancedLinesMesh {
  15873. /**
  15874. * Enables the edge rendering mode on the mesh.
  15875. * This mode makes the mesh edges visible
  15876. * @param epsilon defines the maximal distance between two angles to detect a face
  15877. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15878. * @returns the current InstancedLinesMesh
  15879. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15880. */
  15881. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15882. }
  15883. /**
  15884. * Defines the minimum contract an Edges renderer should follow.
  15885. */
  15886. export interface IEdgesRenderer extends IDisposable {
  15887. /**
  15888. * Gets or sets a boolean indicating if the edgesRenderer is active
  15889. */
  15890. isEnabled: boolean;
  15891. /**
  15892. * Renders the edges of the attached mesh,
  15893. */
  15894. render(): void;
  15895. /**
  15896. * Checks wether or not the edges renderer is ready to render.
  15897. * @return true if ready, otherwise false.
  15898. */
  15899. isReady(): boolean;
  15900. }
  15901. /**
  15902. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15903. */
  15904. export class EdgesRenderer implements IEdgesRenderer {
  15905. /**
  15906. * Define the size of the edges with an orthographic camera
  15907. */
  15908. edgesWidthScalerForOrthographic: number;
  15909. /**
  15910. * Define the size of the edges with a perspective camera
  15911. */
  15912. edgesWidthScalerForPerspective: number;
  15913. protected _source: AbstractMesh;
  15914. protected _linesPositions: number[];
  15915. protected _linesNormals: number[];
  15916. protected _linesIndices: number[];
  15917. protected _epsilon: number;
  15918. protected _indicesCount: number;
  15919. protected _lineShader: ShaderMaterial;
  15920. protected _ib: DataBuffer;
  15921. protected _buffers: {
  15922. [key: string]: Nullable<VertexBuffer>;
  15923. };
  15924. protected _checkVerticesInsteadOfIndices: boolean;
  15925. private _meshRebuildObserver;
  15926. private _meshDisposeObserver;
  15927. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15928. isEnabled: boolean;
  15929. /**
  15930. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15931. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15932. * @param source Mesh used to create edges
  15933. * @param epsilon sum of angles in adjacency to check for edge
  15934. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15935. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15936. */
  15937. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15938. protected _prepareRessources(): void;
  15939. /** @hidden */
  15940. _rebuild(): void;
  15941. /**
  15942. * Releases the required resources for the edges renderer
  15943. */
  15944. dispose(): void;
  15945. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15946. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15947. /**
  15948. * Checks if the pair of p0 and p1 is en edge
  15949. * @param faceIndex
  15950. * @param edge
  15951. * @param faceNormals
  15952. * @param p0
  15953. * @param p1
  15954. * @private
  15955. */
  15956. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15957. /**
  15958. * push line into the position, normal and index buffer
  15959. * @protected
  15960. */
  15961. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15962. /**
  15963. * Generates lines edges from adjacencjes
  15964. * @private
  15965. */
  15966. _generateEdgesLines(): void;
  15967. /**
  15968. * Checks wether or not the edges renderer is ready to render.
  15969. * @return true if ready, otherwise false.
  15970. */
  15971. isReady(): boolean;
  15972. /**
  15973. * Renders the edges of the attached mesh,
  15974. */
  15975. render(): void;
  15976. }
  15977. /**
  15978. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15979. */
  15980. export class LineEdgesRenderer extends EdgesRenderer {
  15981. /**
  15982. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15983. * @param source LineMesh used to generate edges
  15984. * @param epsilon not important (specified angle for edge detection)
  15985. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15986. */
  15987. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15988. /**
  15989. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15990. */
  15991. _generateEdgesLines(): void;
  15992. }
  15993. }
  15994. declare module BABYLON {
  15995. /**
  15996. * This represents the object necessary to create a rendering group.
  15997. * This is exclusively used and created by the rendering manager.
  15998. * To modify the behavior, you use the available helpers in your scene or meshes.
  15999. * @hidden
  16000. */
  16001. export class RenderingGroup {
  16002. index: number;
  16003. private static _zeroVector;
  16004. private _scene;
  16005. private _opaqueSubMeshes;
  16006. private _transparentSubMeshes;
  16007. private _alphaTestSubMeshes;
  16008. private _depthOnlySubMeshes;
  16009. private _particleSystems;
  16010. private _spriteManagers;
  16011. private _opaqueSortCompareFn;
  16012. private _alphaTestSortCompareFn;
  16013. private _transparentSortCompareFn;
  16014. private _renderOpaque;
  16015. private _renderAlphaTest;
  16016. private _renderTransparent;
  16017. /** @hidden */
  16018. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16019. onBeforeTransparentRendering: () => void;
  16020. /**
  16021. * Set the opaque sort comparison function.
  16022. * If null the sub meshes will be render in the order they were created
  16023. */
  16024. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16025. /**
  16026. * Set the alpha test sort comparison function.
  16027. * If null the sub meshes will be render in the order they were created
  16028. */
  16029. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16030. /**
  16031. * Set the transparent sort comparison function.
  16032. * If null the sub meshes will be render in the order they were created
  16033. */
  16034. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16035. /**
  16036. * Creates a new rendering group.
  16037. * @param index The rendering group index
  16038. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16039. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16040. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16041. */
  16042. 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>);
  16043. /**
  16044. * Render all the sub meshes contained in the group.
  16045. * @param customRenderFunction Used to override the default render behaviour of the group.
  16046. * @returns true if rendered some submeshes.
  16047. */
  16048. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16049. /**
  16050. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16051. * @param subMeshes The submeshes to render
  16052. */
  16053. private renderOpaqueSorted;
  16054. /**
  16055. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16056. * @param subMeshes The submeshes to render
  16057. */
  16058. private renderAlphaTestSorted;
  16059. /**
  16060. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16061. * @param subMeshes The submeshes to render
  16062. */
  16063. private renderTransparentSorted;
  16064. /**
  16065. * Renders the submeshes in a specified order.
  16066. * @param subMeshes The submeshes to sort before render
  16067. * @param sortCompareFn The comparison function use to sort
  16068. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16069. * @param transparent Specifies to activate blending if true
  16070. */
  16071. private static renderSorted;
  16072. /**
  16073. * Renders the submeshes in the order they were dispatched (no sort applied).
  16074. * @param subMeshes The submeshes to render
  16075. */
  16076. private static renderUnsorted;
  16077. /**
  16078. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16079. * are rendered back to front if in the same alpha index.
  16080. *
  16081. * @param a The first submesh
  16082. * @param b The second submesh
  16083. * @returns The result of the comparison
  16084. */
  16085. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16086. /**
  16087. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16088. * are rendered back to front.
  16089. *
  16090. * @param a The first submesh
  16091. * @param b The second submesh
  16092. * @returns The result of the comparison
  16093. */
  16094. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16095. /**
  16096. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16097. * are rendered front to back (prevent overdraw).
  16098. *
  16099. * @param a The first submesh
  16100. * @param b The second submesh
  16101. * @returns The result of the comparison
  16102. */
  16103. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16104. /**
  16105. * Resets the different lists of submeshes to prepare a new frame.
  16106. */
  16107. prepare(): void;
  16108. dispose(): void;
  16109. /**
  16110. * Inserts the submesh in its correct queue depending on its material.
  16111. * @param subMesh The submesh to dispatch
  16112. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16113. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16114. */
  16115. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16116. dispatchSprites(spriteManager: ISpriteManager): void;
  16117. dispatchParticles(particleSystem: IParticleSystem): void;
  16118. private _renderParticles;
  16119. private _renderSprites;
  16120. }
  16121. }
  16122. declare module BABYLON {
  16123. /**
  16124. * Interface describing the different options available in the rendering manager
  16125. * regarding Auto Clear between groups.
  16126. */
  16127. export interface IRenderingManagerAutoClearSetup {
  16128. /**
  16129. * Defines whether or not autoclear is enable.
  16130. */
  16131. autoClear: boolean;
  16132. /**
  16133. * Defines whether or not to autoclear the depth buffer.
  16134. */
  16135. depth: boolean;
  16136. /**
  16137. * Defines whether or not to autoclear the stencil buffer.
  16138. */
  16139. stencil: boolean;
  16140. }
  16141. /**
  16142. * This class is used by the onRenderingGroupObservable
  16143. */
  16144. export class RenderingGroupInfo {
  16145. /**
  16146. * The Scene that being rendered
  16147. */
  16148. scene: Scene;
  16149. /**
  16150. * The camera currently used for the rendering pass
  16151. */
  16152. camera: Nullable<Camera>;
  16153. /**
  16154. * The ID of the renderingGroup being processed
  16155. */
  16156. renderingGroupId: number;
  16157. }
  16158. /**
  16159. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16160. * It is enable to manage the different groups as well as the different necessary sort functions.
  16161. * This should not be used directly aside of the few static configurations
  16162. */
  16163. export class RenderingManager {
  16164. /**
  16165. * The max id used for rendering groups (not included)
  16166. */
  16167. static MAX_RENDERINGGROUPS: number;
  16168. /**
  16169. * The min id used for rendering groups (included)
  16170. */
  16171. static MIN_RENDERINGGROUPS: number;
  16172. /**
  16173. * Used to globally prevent autoclearing scenes.
  16174. */
  16175. static AUTOCLEAR: boolean;
  16176. /**
  16177. * @hidden
  16178. */
  16179. _useSceneAutoClearSetup: boolean;
  16180. private _scene;
  16181. private _renderingGroups;
  16182. private _depthStencilBufferAlreadyCleaned;
  16183. private _autoClearDepthStencil;
  16184. private _customOpaqueSortCompareFn;
  16185. private _customAlphaTestSortCompareFn;
  16186. private _customTransparentSortCompareFn;
  16187. private _renderingGroupInfo;
  16188. /**
  16189. * Instantiates a new rendering group for a particular scene
  16190. * @param scene Defines the scene the groups belongs to
  16191. */
  16192. constructor(scene: Scene);
  16193. private _clearDepthStencilBuffer;
  16194. /**
  16195. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16196. * @hidden
  16197. */
  16198. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16199. /**
  16200. * Resets the different information of the group to prepare a new frame
  16201. * @hidden
  16202. */
  16203. reset(): void;
  16204. /**
  16205. * Dispose and release the group and its associated resources.
  16206. * @hidden
  16207. */
  16208. dispose(): void;
  16209. /**
  16210. * Clear the info related to rendering groups preventing retention points during dispose.
  16211. */
  16212. freeRenderingGroups(): void;
  16213. private _prepareRenderingGroup;
  16214. /**
  16215. * Add a sprite manager to the rendering manager in order to render it this frame.
  16216. * @param spriteManager Define the sprite manager to render
  16217. */
  16218. dispatchSprites(spriteManager: ISpriteManager): void;
  16219. /**
  16220. * Add a particle system to the rendering manager in order to render it this frame.
  16221. * @param particleSystem Define the particle system to render
  16222. */
  16223. dispatchParticles(particleSystem: IParticleSystem): void;
  16224. /**
  16225. * Add a submesh to the manager in order to render it this frame
  16226. * @param subMesh The submesh to dispatch
  16227. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16228. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16229. */
  16230. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16231. /**
  16232. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16233. * This allowed control for front to back rendering or reversly depending of the special needs.
  16234. *
  16235. * @param renderingGroupId The rendering group id corresponding to its index
  16236. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16237. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16238. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16239. */
  16240. 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;
  16241. /**
  16242. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16243. *
  16244. * @param renderingGroupId The rendering group id corresponding to its index
  16245. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16246. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16247. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16248. */
  16249. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16250. /**
  16251. * Gets the current auto clear configuration for one rendering group of the rendering
  16252. * manager.
  16253. * @param index the rendering group index to get the information for
  16254. * @returns The auto clear setup for the requested rendering group
  16255. */
  16256. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16257. }
  16258. }
  16259. declare module BABYLON {
  16260. /**
  16261. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16262. */
  16263. export interface ICustomShaderOptions {
  16264. /**
  16265. * Gets or sets the custom shader name to use
  16266. */
  16267. shaderName: string;
  16268. /**
  16269. * The list of attribute names used in the shader
  16270. */
  16271. attributes?: string[];
  16272. /**
  16273. * The list of unifrom names used in the shader
  16274. */
  16275. uniforms?: string[];
  16276. /**
  16277. * The list of sampler names used in the shader
  16278. */
  16279. samplers?: string[];
  16280. /**
  16281. * The list of defines used in the shader
  16282. */
  16283. defines?: string[];
  16284. }
  16285. /**
  16286. * Interface to implement to create a shadow generator compatible with BJS.
  16287. */
  16288. export interface IShadowGenerator {
  16289. /**
  16290. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16291. * @returns The render target texture if present otherwise, null
  16292. */
  16293. getShadowMap(): Nullable<RenderTargetTexture>;
  16294. /**
  16295. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16296. * @param subMesh The submesh we want to render in the shadow map
  16297. * @param useInstances Defines wether will draw in the map using instances
  16298. * @returns true if ready otherwise, false
  16299. */
  16300. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16301. /**
  16302. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16303. * @param defines Defines of the material we want to update
  16304. * @param lightIndex Index of the light in the enabled light list of the material
  16305. */
  16306. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16307. /**
  16308. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16309. * defined in the generator but impacting the effect).
  16310. * It implies the unifroms available on the materials are the standard BJS ones.
  16311. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16312. * @param effect The effect we are binfing the information for
  16313. */
  16314. bindShadowLight(lightIndex: string, effect: Effect): void;
  16315. /**
  16316. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16317. * (eq to shadow prjection matrix * light transform matrix)
  16318. * @returns The transform matrix used to create the shadow map
  16319. */
  16320. getTransformMatrix(): Matrix;
  16321. /**
  16322. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16323. * Cube and 2D textures for instance.
  16324. */
  16325. recreateShadowMap(): void;
  16326. /**
  16327. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16328. * @param onCompiled Callback triggered at the and of the effects compilation
  16329. * @param options Sets of optional options forcing the compilation with different modes
  16330. */
  16331. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16332. useInstances: boolean;
  16333. }>): void;
  16334. /**
  16335. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16336. * @param options Sets of optional options forcing the compilation with different modes
  16337. * @returns A promise that resolves when the compilation completes
  16338. */
  16339. forceCompilationAsync(options?: Partial<{
  16340. useInstances: boolean;
  16341. }>): Promise<void>;
  16342. /**
  16343. * Serializes the shadow generator setup to a json object.
  16344. * @returns The serialized JSON object
  16345. */
  16346. serialize(): any;
  16347. /**
  16348. * Disposes the Shadow map and related Textures and effects.
  16349. */
  16350. dispose(): void;
  16351. }
  16352. /**
  16353. * Default implementation IShadowGenerator.
  16354. * This is the main object responsible of generating shadows in the framework.
  16355. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16356. */
  16357. export class ShadowGenerator implements IShadowGenerator {
  16358. /**
  16359. * Name of the shadow generator class
  16360. */
  16361. static CLASSNAME: string;
  16362. /**
  16363. * Shadow generator mode None: no filtering applied.
  16364. */
  16365. static readonly FILTER_NONE: number;
  16366. /**
  16367. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16368. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16369. */
  16370. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16371. /**
  16372. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16373. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16374. */
  16375. static readonly FILTER_POISSONSAMPLING: number;
  16376. /**
  16377. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16378. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16379. */
  16380. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16381. /**
  16382. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16383. * edge artifacts on steep falloff.
  16384. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16385. */
  16386. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16387. /**
  16388. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16389. * edge artifacts on steep falloff.
  16390. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16391. */
  16392. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16393. /**
  16394. * Shadow generator mode PCF: Percentage Closer Filtering
  16395. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16396. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16397. */
  16398. static readonly FILTER_PCF: number;
  16399. /**
  16400. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16401. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16402. * Contact Hardening
  16403. */
  16404. static readonly FILTER_PCSS: number;
  16405. /**
  16406. * Reserved for PCF and PCSS
  16407. * Highest Quality.
  16408. *
  16409. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16410. *
  16411. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16412. */
  16413. static readonly QUALITY_HIGH: number;
  16414. /**
  16415. * Reserved for PCF and PCSS
  16416. * Good tradeoff for quality/perf cross devices
  16417. *
  16418. * Execute PCF on a 3*3 kernel.
  16419. *
  16420. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16421. */
  16422. static readonly QUALITY_MEDIUM: number;
  16423. /**
  16424. * Reserved for PCF and PCSS
  16425. * The lowest quality but the fastest.
  16426. *
  16427. * Execute PCF on a 1*1 kernel.
  16428. *
  16429. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16430. */
  16431. static readonly QUALITY_LOW: number;
  16432. /** Gets or sets the custom shader name to use */
  16433. customShaderOptions: ICustomShaderOptions;
  16434. /**
  16435. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16436. */
  16437. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16438. /**
  16439. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16440. */
  16441. onAfterShadowMapRenderObservable: Observable<Effect>;
  16442. /**
  16443. * Observable triggered before a mesh is rendered in the shadow map.
  16444. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16445. */
  16446. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16447. /**
  16448. * Observable triggered after a mesh is rendered in the shadow map.
  16449. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16450. */
  16451. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16452. protected _bias: number;
  16453. /**
  16454. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16455. */
  16456. get bias(): number;
  16457. /**
  16458. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16459. */
  16460. set bias(bias: number);
  16461. protected _normalBias: number;
  16462. /**
  16463. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16464. */
  16465. get normalBias(): number;
  16466. /**
  16467. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16468. */
  16469. set normalBias(normalBias: number);
  16470. protected _blurBoxOffset: number;
  16471. /**
  16472. * Gets the blur box offset: offset applied during the blur pass.
  16473. * Only useful if useKernelBlur = false
  16474. */
  16475. get blurBoxOffset(): number;
  16476. /**
  16477. * Sets the blur box offset: offset applied during the blur pass.
  16478. * Only useful if useKernelBlur = false
  16479. */
  16480. set blurBoxOffset(value: number);
  16481. protected _blurScale: number;
  16482. /**
  16483. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16484. * 2 means half of the size.
  16485. */
  16486. get blurScale(): number;
  16487. /**
  16488. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16489. * 2 means half of the size.
  16490. */
  16491. set blurScale(value: number);
  16492. protected _blurKernel: number;
  16493. /**
  16494. * Gets the blur kernel: kernel size of the blur pass.
  16495. * Only useful if useKernelBlur = true
  16496. */
  16497. get blurKernel(): number;
  16498. /**
  16499. * Sets the blur kernel: kernel size of the blur pass.
  16500. * Only useful if useKernelBlur = true
  16501. */
  16502. set blurKernel(value: number);
  16503. protected _useKernelBlur: boolean;
  16504. /**
  16505. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16506. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16507. */
  16508. get useKernelBlur(): boolean;
  16509. /**
  16510. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16511. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16512. */
  16513. set useKernelBlur(value: boolean);
  16514. protected _depthScale: number;
  16515. /**
  16516. * Gets the depth scale used in ESM mode.
  16517. */
  16518. get depthScale(): number;
  16519. /**
  16520. * Sets the depth scale used in ESM mode.
  16521. * This can override the scale stored on the light.
  16522. */
  16523. set depthScale(value: number);
  16524. protected _validateFilter(filter: number): number;
  16525. protected _filter: number;
  16526. /**
  16527. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16528. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16529. */
  16530. get filter(): number;
  16531. /**
  16532. * Sets 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. set filter(value: number);
  16536. /**
  16537. * Gets if the current filter is set to Poisson Sampling.
  16538. */
  16539. get usePoissonSampling(): boolean;
  16540. /**
  16541. * Sets the current filter to Poisson Sampling.
  16542. */
  16543. set usePoissonSampling(value: boolean);
  16544. /**
  16545. * Gets if the current filter is set to ESM.
  16546. */
  16547. get useExponentialShadowMap(): boolean;
  16548. /**
  16549. * Sets the current filter is to ESM.
  16550. */
  16551. set useExponentialShadowMap(value: boolean);
  16552. /**
  16553. * Gets if the current filter is set to filtered ESM.
  16554. */
  16555. get useBlurExponentialShadowMap(): boolean;
  16556. /**
  16557. * Gets if the current filter is set to filtered ESM.
  16558. */
  16559. set useBlurExponentialShadowMap(value: boolean);
  16560. /**
  16561. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16562. * exponential to prevent steep falloff artifacts).
  16563. */
  16564. get useCloseExponentialShadowMap(): boolean;
  16565. /**
  16566. * Sets the current filter to "close ESM" (using the inverse of the
  16567. * exponential to prevent steep falloff artifacts).
  16568. */
  16569. set useCloseExponentialShadowMap(value: boolean);
  16570. /**
  16571. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16572. * exponential to prevent steep falloff artifacts).
  16573. */
  16574. get useBlurCloseExponentialShadowMap(): boolean;
  16575. /**
  16576. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16577. * exponential to prevent steep falloff artifacts).
  16578. */
  16579. set useBlurCloseExponentialShadowMap(value: boolean);
  16580. /**
  16581. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16582. */
  16583. get usePercentageCloserFiltering(): boolean;
  16584. /**
  16585. * Sets the current filter to "PCF" (percentage closer filtering).
  16586. */
  16587. set usePercentageCloserFiltering(value: boolean);
  16588. protected _filteringQuality: number;
  16589. /**
  16590. * Gets the PCF or PCSS Quality.
  16591. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16592. */
  16593. get filteringQuality(): number;
  16594. /**
  16595. * Sets the PCF or PCSS Quality.
  16596. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16597. */
  16598. set filteringQuality(filteringQuality: number);
  16599. /**
  16600. * Gets if the current filter is set to "PCSS" (contact hardening).
  16601. */
  16602. get useContactHardeningShadow(): boolean;
  16603. /**
  16604. * Sets the current filter to "PCSS" (contact hardening).
  16605. */
  16606. set useContactHardeningShadow(value: boolean);
  16607. protected _contactHardeningLightSizeUVRatio: number;
  16608. /**
  16609. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16610. * Using a ratio helps keeping shape stability independently of the map size.
  16611. *
  16612. * It does not account for the light projection as it was having too much
  16613. * instability during the light setup or during light position changes.
  16614. *
  16615. * Only valid if useContactHardeningShadow is true.
  16616. */
  16617. get contactHardeningLightSizeUVRatio(): number;
  16618. /**
  16619. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16620. * Using a ratio helps keeping shape stability independently of the map size.
  16621. *
  16622. * It does not account for the light projection as it was having too much
  16623. * instability during the light setup or during light position changes.
  16624. *
  16625. * Only valid if useContactHardeningShadow is true.
  16626. */
  16627. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16628. protected _darkness: number;
  16629. /** Gets or sets the actual darkness of a shadow */
  16630. get darkness(): number;
  16631. set darkness(value: number);
  16632. /**
  16633. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16634. * 0 means strongest and 1 would means no shadow.
  16635. * @returns the darkness.
  16636. */
  16637. getDarkness(): number;
  16638. /**
  16639. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16640. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16641. * @returns the shadow generator allowing fluent coding.
  16642. */
  16643. setDarkness(darkness: number): ShadowGenerator;
  16644. protected _transparencyShadow: boolean;
  16645. /** Gets or sets the ability to have transparent shadow */
  16646. get transparencyShadow(): boolean;
  16647. set transparencyShadow(value: boolean);
  16648. /**
  16649. * Sets the ability to have transparent shadow (boolean).
  16650. * @param transparent True if transparent else False
  16651. * @returns the shadow generator allowing fluent coding
  16652. */
  16653. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16654. protected _shadowMap: Nullable<RenderTargetTexture>;
  16655. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16656. /**
  16657. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16658. * @returns The render target texture if present otherwise, null
  16659. */
  16660. getShadowMap(): Nullable<RenderTargetTexture>;
  16661. /**
  16662. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16663. * @returns The render target texture if the shadow map is present otherwise, null
  16664. */
  16665. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16666. /**
  16667. * Gets the class name of that object
  16668. * @returns "ShadowGenerator"
  16669. */
  16670. getClassName(): string;
  16671. /**
  16672. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16673. * @param mesh Mesh to add
  16674. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16675. * @returns the Shadow Generator itself
  16676. */
  16677. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16678. /**
  16679. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16680. * @param mesh Mesh to remove
  16681. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16682. * @returns the Shadow Generator itself
  16683. */
  16684. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16685. /**
  16686. * Controls the extent to which the shadows fade out at the edge of the frustum
  16687. */
  16688. frustumEdgeFalloff: number;
  16689. protected _light: IShadowLight;
  16690. /**
  16691. * Returns the associated light object.
  16692. * @returns the light generating the shadow
  16693. */
  16694. getLight(): IShadowLight;
  16695. /**
  16696. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16697. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16698. * It might on the other hand introduce peter panning.
  16699. */
  16700. forceBackFacesOnly: boolean;
  16701. protected _scene: Scene;
  16702. protected _lightDirection: Vector3;
  16703. protected _effect: Effect;
  16704. protected _viewMatrix: Matrix;
  16705. protected _projectionMatrix: Matrix;
  16706. protected _transformMatrix: Matrix;
  16707. protected _cachedPosition: Vector3;
  16708. protected _cachedDirection: Vector3;
  16709. protected _cachedDefines: string;
  16710. protected _currentRenderID: number;
  16711. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16712. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16713. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16714. protected _blurPostProcesses: PostProcess[];
  16715. protected _mapSize: number;
  16716. protected _currentFaceIndex: number;
  16717. protected _currentFaceIndexCache: number;
  16718. protected _textureType: number;
  16719. protected _defaultTextureMatrix: Matrix;
  16720. protected _storedUniqueId: Nullable<number>;
  16721. /** @hidden */
  16722. static _SceneComponentInitialization: (scene: Scene) => void;
  16723. /**
  16724. * Creates a ShadowGenerator object.
  16725. * A ShadowGenerator is the required tool to use the shadows.
  16726. * Each light casting shadows needs to use its own ShadowGenerator.
  16727. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16728. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16729. * @param light The light object generating the shadows.
  16730. * @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.
  16731. */
  16732. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16733. protected _initializeGenerator(): void;
  16734. protected _createTargetRenderTexture(): void;
  16735. protected _initializeShadowMap(): void;
  16736. protected _initializeBlurRTTAndPostProcesses(): void;
  16737. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16738. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16739. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16740. protected _applyFilterValues(): void;
  16741. /**
  16742. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16743. * @param onCompiled Callback triggered at the and of the effects compilation
  16744. * @param options Sets of optional options forcing the compilation with different modes
  16745. */
  16746. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16747. useInstances: boolean;
  16748. }>): void;
  16749. /**
  16750. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16751. * @param options Sets of optional options forcing the compilation with different modes
  16752. * @returns A promise that resolves when the compilation completes
  16753. */
  16754. forceCompilationAsync(options?: Partial<{
  16755. useInstances: boolean;
  16756. }>): Promise<void>;
  16757. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16758. /**
  16759. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16760. * @param subMesh The submesh we want to render in the shadow map
  16761. * @param useInstances Defines wether will draw in the map using instances
  16762. * @returns true if ready otherwise, false
  16763. */
  16764. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16765. /**
  16766. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16767. * @param defines Defines of the material we want to update
  16768. * @param lightIndex Index of the light in the enabled light list of the material
  16769. */
  16770. prepareDefines(defines: any, lightIndex: number): void;
  16771. /**
  16772. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16773. * defined in the generator but impacting the effect).
  16774. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16775. * @param effect The effect we are binfing the information for
  16776. */
  16777. bindShadowLight(lightIndex: string, effect: Effect): void;
  16778. /**
  16779. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16780. * (eq to shadow prjection matrix * light transform matrix)
  16781. * @returns The transform matrix used to create the shadow map
  16782. */
  16783. getTransformMatrix(): Matrix;
  16784. /**
  16785. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16786. * Cube and 2D textures for instance.
  16787. */
  16788. recreateShadowMap(): void;
  16789. protected _disposeBlurPostProcesses(): void;
  16790. protected _disposeRTTandPostProcesses(): void;
  16791. /**
  16792. * Disposes the ShadowGenerator.
  16793. * Returns nothing.
  16794. */
  16795. dispose(): void;
  16796. /**
  16797. * Serializes the shadow generator setup to a json object.
  16798. * @returns The serialized JSON object
  16799. */
  16800. serialize(): any;
  16801. /**
  16802. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16803. * @param parsedShadowGenerator The JSON object to parse
  16804. * @param scene The scene to create the shadow map for
  16805. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16806. * @returns The parsed shadow generator
  16807. */
  16808. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16809. }
  16810. }
  16811. declare module BABYLON {
  16812. /**
  16813. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16814. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16815. * 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.
  16816. */
  16817. export abstract class Light extends Node {
  16818. /**
  16819. * Falloff Default: light is falling off following the material specification:
  16820. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16821. */
  16822. static readonly FALLOFF_DEFAULT: number;
  16823. /**
  16824. * Falloff Physical: light is falling off following the inverse squared distance law.
  16825. */
  16826. static readonly FALLOFF_PHYSICAL: number;
  16827. /**
  16828. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16829. * to enhance interoperability with other engines.
  16830. */
  16831. static readonly FALLOFF_GLTF: number;
  16832. /**
  16833. * Falloff Standard: light is falling off like in the standard material
  16834. * to enhance interoperability with other materials.
  16835. */
  16836. static readonly FALLOFF_STANDARD: number;
  16837. /**
  16838. * If every light affecting the material is in this lightmapMode,
  16839. * material.lightmapTexture adds or multiplies
  16840. * (depends on material.useLightmapAsShadowmap)
  16841. * after every other light calculations.
  16842. */
  16843. static readonly LIGHTMAP_DEFAULT: number;
  16844. /**
  16845. * material.lightmapTexture as only diffuse lighting from this light
  16846. * adds only specular lighting from this light
  16847. * adds dynamic shadows
  16848. */
  16849. static readonly LIGHTMAP_SPECULAR: number;
  16850. /**
  16851. * material.lightmapTexture as only lighting
  16852. * no light calculation from this light
  16853. * only adds dynamic shadows from this light
  16854. */
  16855. static readonly LIGHTMAP_SHADOWSONLY: number;
  16856. /**
  16857. * Each light type uses the default quantity according to its type:
  16858. * point/spot lights use luminous intensity
  16859. * directional lights use illuminance
  16860. */
  16861. static readonly INTENSITYMODE_AUTOMATIC: number;
  16862. /**
  16863. * lumen (lm)
  16864. */
  16865. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16866. /**
  16867. * candela (lm/sr)
  16868. */
  16869. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16870. /**
  16871. * lux (lm/m^2)
  16872. */
  16873. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16874. /**
  16875. * nit (cd/m^2)
  16876. */
  16877. static readonly INTENSITYMODE_LUMINANCE: number;
  16878. /**
  16879. * Light type const id of the point light.
  16880. */
  16881. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16882. /**
  16883. * Light type const id of the directional light.
  16884. */
  16885. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16886. /**
  16887. * Light type const id of the spot light.
  16888. */
  16889. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16890. /**
  16891. * Light type const id of the hemispheric light.
  16892. */
  16893. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16894. /**
  16895. * Diffuse gives the basic color to an object.
  16896. */
  16897. diffuse: Color3;
  16898. /**
  16899. * Specular produces a highlight color on an object.
  16900. * Note: This is note affecting PBR materials.
  16901. */
  16902. specular: Color3;
  16903. /**
  16904. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16905. * falling off base on range or angle.
  16906. * This can be set to any values in Light.FALLOFF_x.
  16907. *
  16908. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16909. * other types of materials.
  16910. */
  16911. falloffType: number;
  16912. /**
  16913. * Strength of the light.
  16914. * Note: By default it is define in the framework own unit.
  16915. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16916. */
  16917. intensity: number;
  16918. private _range;
  16919. protected _inverseSquaredRange: number;
  16920. /**
  16921. * Defines how far from the source the light is impacting in scene units.
  16922. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16923. */
  16924. get range(): 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. set range(value: number);
  16930. /**
  16931. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16932. * of light.
  16933. */
  16934. private _photometricScale;
  16935. private _intensityMode;
  16936. /**
  16937. * Gets the photometric scale used to interpret the intensity.
  16938. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16939. */
  16940. get intensityMode(): number;
  16941. /**
  16942. * Sets 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. set intensityMode(value: number);
  16946. private _radius;
  16947. /**
  16948. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16949. */
  16950. get radius(): number;
  16951. /**
  16952. * sets the light radius used by PBR Materials to simulate soft area lights.
  16953. */
  16954. set radius(value: number);
  16955. private _renderPriority;
  16956. /**
  16957. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16958. * exceeding the number allowed of the materials.
  16959. */
  16960. renderPriority: number;
  16961. private _shadowEnabled;
  16962. /**
  16963. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16964. * the current shadow generator.
  16965. */
  16966. get shadowEnabled(): boolean;
  16967. /**
  16968. * Sets 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. set shadowEnabled(value: boolean);
  16972. private _includedOnlyMeshes;
  16973. /**
  16974. * Gets the only meshes impacted by this light.
  16975. */
  16976. get includedOnlyMeshes(): AbstractMesh[];
  16977. /**
  16978. * Sets the only meshes impacted by this light.
  16979. */
  16980. set includedOnlyMeshes(value: AbstractMesh[]);
  16981. private _excludedMeshes;
  16982. /**
  16983. * Gets the meshes not impacted by this light.
  16984. */
  16985. get excludedMeshes(): AbstractMesh[];
  16986. /**
  16987. * Sets the meshes not impacted by this light.
  16988. */
  16989. set excludedMeshes(value: AbstractMesh[]);
  16990. private _excludeWithLayerMask;
  16991. /**
  16992. * Gets the layer id use to find what meshes are not impacted by the light.
  16993. * Inactive if 0
  16994. */
  16995. get excludeWithLayerMask(): number;
  16996. /**
  16997. * Sets the layer id use to find what meshes are not impacted by the light.
  16998. * Inactive if 0
  16999. */
  17000. set excludeWithLayerMask(value: number);
  17001. private _includeOnlyWithLayerMask;
  17002. /**
  17003. * Gets the layer id use to find what meshes are impacted by the light.
  17004. * Inactive if 0
  17005. */
  17006. get includeOnlyWithLayerMask(): number;
  17007. /**
  17008. * Sets the layer id use to find what meshes are impacted by the light.
  17009. * Inactive if 0
  17010. */
  17011. set includeOnlyWithLayerMask(value: number);
  17012. private _lightmapMode;
  17013. /**
  17014. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17015. */
  17016. get lightmapMode(): number;
  17017. /**
  17018. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17019. */
  17020. set lightmapMode(value: number);
  17021. /**
  17022. * Shadow generator associted to the light.
  17023. * @hidden Internal use only.
  17024. */
  17025. _shadowGenerator: Nullable<IShadowGenerator>;
  17026. /**
  17027. * @hidden Internal use only.
  17028. */
  17029. _excludedMeshesIds: string[];
  17030. /**
  17031. * @hidden Internal use only.
  17032. */
  17033. _includedOnlyMeshesIds: string[];
  17034. /**
  17035. * The current light unifom buffer.
  17036. * @hidden Internal use only.
  17037. */
  17038. _uniformBuffer: UniformBuffer;
  17039. /** @hidden */
  17040. _renderId: number;
  17041. /**
  17042. * Creates a Light object in the scene.
  17043. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17044. * @param name The firendly name of the light
  17045. * @param scene The scene the light belongs too
  17046. */
  17047. constructor(name: string, scene: Scene);
  17048. protected abstract _buildUniformLayout(): void;
  17049. /**
  17050. * Sets the passed Effect "effect" with the Light information.
  17051. * @param effect The effect to update
  17052. * @param lightIndex The index of the light in the effect to update
  17053. * @returns The light
  17054. */
  17055. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17056. /**
  17057. * Sets the passed Effect "effect" with the Light textures.
  17058. * @param effect The effect to update
  17059. * @param lightIndex The index of the light in the effect to update
  17060. * @returns The light
  17061. */
  17062. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17063. /**
  17064. * Binds the lights information from the scene to the effect for the given mesh.
  17065. * @param lightIndex Light index
  17066. * @param scene The scene where the light belongs to
  17067. * @param effect The effect we are binding the data to
  17068. * @param useSpecular Defines if specular is supported
  17069. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17070. */
  17071. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17072. /**
  17073. * Sets the passed Effect "effect" with the Light information.
  17074. * @param effect The effect to update
  17075. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17076. * @returns The light
  17077. */
  17078. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17079. /**
  17080. * Returns the string "Light".
  17081. * @returns the class name
  17082. */
  17083. getClassName(): string;
  17084. /** @hidden */
  17085. readonly _isLight: boolean;
  17086. /**
  17087. * Converts the light information to a readable string for debug purpose.
  17088. * @param fullDetails Supports for multiple levels of logging within scene loading
  17089. * @returns the human readable light info
  17090. */
  17091. toString(fullDetails?: boolean): string;
  17092. /** @hidden */
  17093. protected _syncParentEnabledState(): void;
  17094. /**
  17095. * Set the enabled state of this node.
  17096. * @param value - the new enabled state
  17097. */
  17098. setEnabled(value: boolean): void;
  17099. /**
  17100. * Returns the Light associated shadow generator if any.
  17101. * @return the associated shadow generator.
  17102. */
  17103. getShadowGenerator(): Nullable<IShadowGenerator>;
  17104. /**
  17105. * Returns a Vector3, the absolute light position in the World.
  17106. * @returns the world space position of the light
  17107. */
  17108. getAbsolutePosition(): Vector3;
  17109. /**
  17110. * Specifies if the light will affect the passed mesh.
  17111. * @param mesh The mesh to test against the light
  17112. * @return true the mesh is affected otherwise, false.
  17113. */
  17114. canAffectMesh(mesh: AbstractMesh): boolean;
  17115. /**
  17116. * Sort function to order lights for rendering.
  17117. * @param a First Light object to compare to second.
  17118. * @param b Second Light object to compare first.
  17119. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17120. */
  17121. static CompareLightsPriority(a: Light, b: Light): number;
  17122. /**
  17123. * Releases resources associated with this node.
  17124. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17125. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17126. */
  17127. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17128. /**
  17129. * Returns the light type ID (integer).
  17130. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17131. */
  17132. getTypeID(): number;
  17133. /**
  17134. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17135. * @returns the scaled intensity in intensity mode unit
  17136. */
  17137. getScaledIntensity(): number;
  17138. /**
  17139. * Returns a new Light object, named "name", from the current one.
  17140. * @param name The name of the cloned light
  17141. * @returns the new created light
  17142. */
  17143. clone(name: string): Nullable<Light>;
  17144. /**
  17145. * Serializes the current light into a Serialization object.
  17146. * @returns the serialized object.
  17147. */
  17148. serialize(): any;
  17149. /**
  17150. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17151. * This new light is named "name" and added to the passed scene.
  17152. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17153. * @param name The friendly name of the light
  17154. * @param scene The scene the new light will belong to
  17155. * @returns the constructor function
  17156. */
  17157. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17158. /**
  17159. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17160. * @param parsedLight The JSON representation of the light
  17161. * @param scene The scene to create the parsed light in
  17162. * @returns the created light after parsing
  17163. */
  17164. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17165. private _hookArrayForExcluded;
  17166. private _hookArrayForIncludedOnly;
  17167. private _resyncMeshes;
  17168. /**
  17169. * Forces the meshes to update their light related information in their rendering used effects
  17170. * @hidden Internal Use Only
  17171. */
  17172. _markMeshesAsLightDirty(): void;
  17173. /**
  17174. * Recomputes the cached photometric scale if needed.
  17175. */
  17176. private _computePhotometricScale;
  17177. /**
  17178. * Returns the Photometric Scale according to the light type and intensity mode.
  17179. */
  17180. private _getPhotometricScale;
  17181. /**
  17182. * Reorder the light in the scene according to their defined priority.
  17183. * @hidden Internal Use Only
  17184. */
  17185. _reorderLightsInScene(): void;
  17186. /**
  17187. * Prepares the list of defines specific to the light type.
  17188. * @param defines the list of defines
  17189. * @param lightIndex defines the index of the light for the effect
  17190. */
  17191. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17192. }
  17193. }
  17194. declare module BABYLON {
  17195. /**
  17196. * Interface used to define Action
  17197. */
  17198. export interface IAction {
  17199. /**
  17200. * Trigger for the action
  17201. */
  17202. trigger: number;
  17203. /** Options of the trigger */
  17204. triggerOptions: any;
  17205. /**
  17206. * Gets the trigger parameters
  17207. * @returns the trigger parameters
  17208. */
  17209. getTriggerParameter(): any;
  17210. /**
  17211. * Internal only - executes current action event
  17212. * @hidden
  17213. */
  17214. _executeCurrent(evt?: ActionEvent): void;
  17215. /**
  17216. * Serialize placeholder for child classes
  17217. * @param parent of child
  17218. * @returns the serialized object
  17219. */
  17220. serialize(parent: any): any;
  17221. /**
  17222. * Internal only
  17223. * @hidden
  17224. */
  17225. _prepare(): void;
  17226. /**
  17227. * Internal only - manager for action
  17228. * @hidden
  17229. */
  17230. _actionManager: AbstractActionManager;
  17231. /**
  17232. * Adds action to chain of actions, may be a DoNothingAction
  17233. * @param action defines the next action to execute
  17234. * @returns The action passed in
  17235. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17236. */
  17237. then(action: IAction): IAction;
  17238. }
  17239. /**
  17240. * The action to be carried out following a trigger
  17241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17242. */
  17243. export class Action implements IAction {
  17244. /** the trigger, with or without parameters, for the action */
  17245. triggerOptions: any;
  17246. /**
  17247. * Trigger for the action
  17248. */
  17249. trigger: number;
  17250. /**
  17251. * Internal only - manager for action
  17252. * @hidden
  17253. */
  17254. _actionManager: ActionManager;
  17255. private _nextActiveAction;
  17256. private _child;
  17257. private _condition?;
  17258. private _triggerParameter;
  17259. /**
  17260. * An event triggered prior to action being executed.
  17261. */
  17262. onBeforeExecuteObservable: Observable<Action>;
  17263. /**
  17264. * Creates a new Action
  17265. * @param triggerOptions the trigger, with or without parameters, for the action
  17266. * @param condition an optional determinant of action
  17267. */
  17268. constructor(
  17269. /** the trigger, with or without parameters, for the action */
  17270. triggerOptions: any, condition?: Condition);
  17271. /**
  17272. * Internal only
  17273. * @hidden
  17274. */
  17275. _prepare(): void;
  17276. /**
  17277. * Gets the trigger parameters
  17278. * @returns the trigger parameters
  17279. */
  17280. getTriggerParameter(): any;
  17281. /**
  17282. * Internal only - executes current action event
  17283. * @hidden
  17284. */
  17285. _executeCurrent(evt?: ActionEvent): void;
  17286. /**
  17287. * Execute placeholder for child classes
  17288. * @param evt optional action event
  17289. */
  17290. execute(evt?: ActionEvent): void;
  17291. /**
  17292. * Skips to next active action
  17293. */
  17294. skipToNextActiveAction(): void;
  17295. /**
  17296. * Adds action to chain of actions, may be a DoNothingAction
  17297. * @param action defines the next action to execute
  17298. * @returns The action passed in
  17299. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17300. */
  17301. then(action: Action): Action;
  17302. /**
  17303. * Internal only
  17304. * @hidden
  17305. */
  17306. _getProperty(propertyPath: string): string;
  17307. /**
  17308. * Internal only
  17309. * @hidden
  17310. */
  17311. _getEffectiveTarget(target: any, propertyPath: string): any;
  17312. /**
  17313. * Serialize placeholder for child classes
  17314. * @param parent of child
  17315. * @returns the serialized object
  17316. */
  17317. serialize(parent: any): any;
  17318. /**
  17319. * Internal only called by serialize
  17320. * @hidden
  17321. */
  17322. protected _serialize(serializedAction: any, parent?: any): any;
  17323. /**
  17324. * Internal only
  17325. * @hidden
  17326. */
  17327. static _SerializeValueAsString: (value: any) => string;
  17328. /**
  17329. * Internal only
  17330. * @hidden
  17331. */
  17332. static _GetTargetProperty: (target: Node | Scene) => {
  17333. name: string;
  17334. targetType: string;
  17335. value: string;
  17336. };
  17337. }
  17338. }
  17339. declare module BABYLON {
  17340. /**
  17341. * A Condition applied to an Action
  17342. */
  17343. export class Condition {
  17344. /**
  17345. * Internal only - manager for action
  17346. * @hidden
  17347. */
  17348. _actionManager: ActionManager;
  17349. /**
  17350. * Internal only
  17351. * @hidden
  17352. */
  17353. _evaluationId: number;
  17354. /**
  17355. * Internal only
  17356. * @hidden
  17357. */
  17358. _currentResult: boolean;
  17359. /**
  17360. * Creates a new Condition
  17361. * @param actionManager the manager of the action the condition is applied to
  17362. */
  17363. constructor(actionManager: ActionManager);
  17364. /**
  17365. * Check if the current condition is valid
  17366. * @returns a boolean
  17367. */
  17368. isValid(): boolean;
  17369. /**
  17370. * Internal only
  17371. * @hidden
  17372. */
  17373. _getProperty(propertyPath: string): string;
  17374. /**
  17375. * Internal only
  17376. * @hidden
  17377. */
  17378. _getEffectiveTarget(target: any, propertyPath: string): any;
  17379. /**
  17380. * Serialize placeholder for child classes
  17381. * @returns the serialized object
  17382. */
  17383. serialize(): any;
  17384. /**
  17385. * Internal only
  17386. * @hidden
  17387. */
  17388. protected _serialize(serializedCondition: any): any;
  17389. }
  17390. /**
  17391. * Defines specific conditional operators as extensions of Condition
  17392. */
  17393. export class ValueCondition extends Condition {
  17394. /** path to specify the property of the target the conditional operator uses */
  17395. propertyPath: string;
  17396. /** the value compared by the conditional operator against the current value of the property */
  17397. value: any;
  17398. /** the conditional operator, default ValueCondition.IsEqual */
  17399. operator: number;
  17400. /**
  17401. * Internal only
  17402. * @hidden
  17403. */
  17404. private static _IsEqual;
  17405. /**
  17406. * Internal only
  17407. * @hidden
  17408. */
  17409. private static _IsDifferent;
  17410. /**
  17411. * Internal only
  17412. * @hidden
  17413. */
  17414. private static _IsGreater;
  17415. /**
  17416. * Internal only
  17417. * @hidden
  17418. */
  17419. private static _IsLesser;
  17420. /**
  17421. * returns the number for IsEqual
  17422. */
  17423. static get IsEqual(): number;
  17424. /**
  17425. * Returns the number for IsDifferent
  17426. */
  17427. static get IsDifferent(): number;
  17428. /**
  17429. * Returns the number for IsGreater
  17430. */
  17431. static get IsGreater(): number;
  17432. /**
  17433. * Returns the number for IsLesser
  17434. */
  17435. static get IsLesser(): number;
  17436. /**
  17437. * Internal only The action manager for the condition
  17438. * @hidden
  17439. */
  17440. _actionManager: ActionManager;
  17441. /**
  17442. * Internal only
  17443. * @hidden
  17444. */
  17445. private _target;
  17446. /**
  17447. * Internal only
  17448. * @hidden
  17449. */
  17450. private _effectiveTarget;
  17451. /**
  17452. * Internal only
  17453. * @hidden
  17454. */
  17455. private _property;
  17456. /**
  17457. * Creates a new ValueCondition
  17458. * @param actionManager manager for the action the condition applies to
  17459. * @param target for the action
  17460. * @param propertyPath path to specify the property of the target the conditional operator uses
  17461. * @param value the value compared by the conditional operator against the current value of the property
  17462. * @param operator the conditional operator, default ValueCondition.IsEqual
  17463. */
  17464. constructor(actionManager: ActionManager, target: any,
  17465. /** path to specify the property of the target the conditional operator uses */
  17466. propertyPath: string,
  17467. /** the value compared by the conditional operator against the current value of the property */
  17468. value: any,
  17469. /** the conditional operator, default ValueCondition.IsEqual */
  17470. operator?: number);
  17471. /**
  17472. * Compares the given value with the property value for the specified conditional operator
  17473. * @returns the result of the comparison
  17474. */
  17475. isValid(): boolean;
  17476. /**
  17477. * Serialize the ValueCondition into a JSON compatible object
  17478. * @returns serialization object
  17479. */
  17480. serialize(): any;
  17481. /**
  17482. * Gets the name of the conditional operator for the ValueCondition
  17483. * @param operator the conditional operator
  17484. * @returns the name
  17485. */
  17486. static GetOperatorName(operator: number): string;
  17487. }
  17488. /**
  17489. * Defines a predicate condition as an extension of Condition
  17490. */
  17491. export class PredicateCondition extends Condition {
  17492. /** defines the predicate function used to validate the condition */
  17493. predicate: () => boolean;
  17494. /**
  17495. * Internal only - manager for action
  17496. * @hidden
  17497. */
  17498. _actionManager: ActionManager;
  17499. /**
  17500. * Creates a new PredicateCondition
  17501. * @param actionManager manager for the action the condition applies to
  17502. * @param predicate defines the predicate function used to validate the condition
  17503. */
  17504. constructor(actionManager: ActionManager,
  17505. /** defines the predicate function used to validate the condition */
  17506. predicate: () => boolean);
  17507. /**
  17508. * @returns the validity of the predicate condition
  17509. */
  17510. isValid(): boolean;
  17511. }
  17512. /**
  17513. * Defines a state condition as an extension of Condition
  17514. */
  17515. export class StateCondition extends Condition {
  17516. /** Value to compare with target state */
  17517. value: string;
  17518. /**
  17519. * Internal only - manager for action
  17520. * @hidden
  17521. */
  17522. _actionManager: ActionManager;
  17523. /**
  17524. * Internal only
  17525. * @hidden
  17526. */
  17527. private _target;
  17528. /**
  17529. * Creates a new StateCondition
  17530. * @param actionManager manager for the action the condition applies to
  17531. * @param target of the condition
  17532. * @param value to compare with target state
  17533. */
  17534. constructor(actionManager: ActionManager, target: any,
  17535. /** Value to compare with target state */
  17536. value: string);
  17537. /**
  17538. * Gets a boolean indicating if the current condition is met
  17539. * @returns the validity of the state
  17540. */
  17541. isValid(): boolean;
  17542. /**
  17543. * Serialize the StateCondition into a JSON compatible object
  17544. * @returns serialization object
  17545. */
  17546. serialize(): any;
  17547. }
  17548. }
  17549. declare module BABYLON {
  17550. /**
  17551. * This defines an action responsible to toggle a boolean once triggered.
  17552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17553. */
  17554. export class SwitchBooleanAction extends Action {
  17555. /**
  17556. * The path to the boolean property in the target object
  17557. */
  17558. propertyPath: string;
  17559. private _target;
  17560. private _effectiveTarget;
  17561. private _property;
  17562. /**
  17563. * Instantiate the action
  17564. * @param triggerOptions defines the trigger options
  17565. * @param target defines the object containing the boolean
  17566. * @param propertyPath defines the path to the boolean property in the target object
  17567. * @param condition defines the trigger related conditions
  17568. */
  17569. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17570. /** @hidden */
  17571. _prepare(): void;
  17572. /**
  17573. * Execute the action toggle the boolean value.
  17574. */
  17575. execute(): void;
  17576. /**
  17577. * Serializes the actions and its related information.
  17578. * @param parent defines the object to serialize in
  17579. * @returns the serialized object
  17580. */
  17581. serialize(parent: any): any;
  17582. }
  17583. /**
  17584. * This defines an action responsible to set a the state field of the target
  17585. * to a desired value once triggered.
  17586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17587. */
  17588. export class SetStateAction extends Action {
  17589. /**
  17590. * The value to store in the state field.
  17591. */
  17592. value: string;
  17593. private _target;
  17594. /**
  17595. * Instantiate the action
  17596. * @param triggerOptions defines the trigger options
  17597. * @param target defines the object containing the state property
  17598. * @param value defines the value to store in the state field
  17599. * @param condition defines the trigger related conditions
  17600. */
  17601. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17602. /**
  17603. * Execute the action and store the value on the target state property.
  17604. */
  17605. execute(): void;
  17606. /**
  17607. * Serializes the actions and its related information.
  17608. * @param parent defines the object to serialize in
  17609. * @returns the serialized object
  17610. */
  17611. serialize(parent: any): any;
  17612. }
  17613. /**
  17614. * This defines an action responsible to set a property of the target
  17615. * to a desired value once triggered.
  17616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17617. */
  17618. export class SetValueAction extends Action {
  17619. /**
  17620. * The path of the property to set in the target.
  17621. */
  17622. propertyPath: string;
  17623. /**
  17624. * The value to set in the property
  17625. */
  17626. value: any;
  17627. private _target;
  17628. private _effectiveTarget;
  17629. private _property;
  17630. /**
  17631. * Instantiate the action
  17632. * @param triggerOptions defines the trigger options
  17633. * @param target defines the object containing the property
  17634. * @param propertyPath defines the path of the property to set in the target
  17635. * @param value defines the value to set in the property
  17636. * @param condition defines the trigger related conditions
  17637. */
  17638. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17639. /** @hidden */
  17640. _prepare(): void;
  17641. /**
  17642. * Execute the action and set the targetted property to the desired value.
  17643. */
  17644. execute(): void;
  17645. /**
  17646. * Serializes the actions and its related information.
  17647. * @param parent defines the object to serialize in
  17648. * @returns the serialized object
  17649. */
  17650. serialize(parent: any): any;
  17651. }
  17652. /**
  17653. * This defines an action responsible to increment the target value
  17654. * to a desired value once triggered.
  17655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17656. */
  17657. export class IncrementValueAction extends Action {
  17658. /**
  17659. * The path of the property to increment in the target.
  17660. */
  17661. propertyPath: string;
  17662. /**
  17663. * The value we should increment the property by.
  17664. */
  17665. value: any;
  17666. private _target;
  17667. private _effectiveTarget;
  17668. private _property;
  17669. /**
  17670. * Instantiate the action
  17671. * @param triggerOptions defines the trigger options
  17672. * @param target defines the object containing the property
  17673. * @param propertyPath defines the path of the property to increment in the target
  17674. * @param value defines the value value we should increment the property by
  17675. * @param condition defines the trigger related conditions
  17676. */
  17677. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17678. /** @hidden */
  17679. _prepare(): void;
  17680. /**
  17681. * Execute the action and increment the target of the value amount.
  17682. */
  17683. execute(): void;
  17684. /**
  17685. * Serializes the actions and its related information.
  17686. * @param parent defines the object to serialize in
  17687. * @returns the serialized object
  17688. */
  17689. serialize(parent: any): any;
  17690. }
  17691. /**
  17692. * This defines an action responsible to start an animation once triggered.
  17693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17694. */
  17695. export class PlayAnimationAction extends Action {
  17696. /**
  17697. * Where the animation should start (animation frame)
  17698. */
  17699. from: number;
  17700. /**
  17701. * Where the animation should stop (animation frame)
  17702. */
  17703. to: number;
  17704. /**
  17705. * Define if the animation should loop or stop after the first play.
  17706. */
  17707. loop?: boolean;
  17708. private _target;
  17709. /**
  17710. * Instantiate the action
  17711. * @param triggerOptions defines the trigger options
  17712. * @param target defines the target animation or animation name
  17713. * @param from defines from where the animation should start (animation frame)
  17714. * @param end defines where the animation should stop (animation frame)
  17715. * @param loop defines if the animation should loop or stop after the first play
  17716. * @param condition defines the trigger related conditions
  17717. */
  17718. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17719. /** @hidden */
  17720. _prepare(): void;
  17721. /**
  17722. * Execute the action and play the animation.
  17723. */
  17724. execute(): void;
  17725. /**
  17726. * Serializes the actions and its related information.
  17727. * @param parent defines the object to serialize in
  17728. * @returns the serialized object
  17729. */
  17730. serialize(parent: any): any;
  17731. }
  17732. /**
  17733. * This defines an action responsible to stop an animation once triggered.
  17734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17735. */
  17736. export class StopAnimationAction extends Action {
  17737. private _target;
  17738. /**
  17739. * Instantiate the action
  17740. * @param triggerOptions defines the trigger options
  17741. * @param target defines the target animation or animation name
  17742. * @param condition defines the trigger related conditions
  17743. */
  17744. constructor(triggerOptions: any, target: any, condition?: Condition);
  17745. /** @hidden */
  17746. _prepare(): void;
  17747. /**
  17748. * Execute the action and stop the animation.
  17749. */
  17750. execute(): void;
  17751. /**
  17752. * Serializes the actions and its related information.
  17753. * @param parent defines the object to serialize in
  17754. * @returns the serialized object
  17755. */
  17756. serialize(parent: any): any;
  17757. }
  17758. /**
  17759. * This defines an action responsible that does nothing once triggered.
  17760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17761. */
  17762. export class DoNothingAction extends Action {
  17763. /**
  17764. * Instantiate the action
  17765. * @param triggerOptions defines the trigger options
  17766. * @param condition defines the trigger related conditions
  17767. */
  17768. constructor(triggerOptions?: any, condition?: Condition);
  17769. /**
  17770. * Execute the action and do nothing.
  17771. */
  17772. execute(): void;
  17773. /**
  17774. * Serializes the actions and its related information.
  17775. * @param parent defines the object to serialize in
  17776. * @returns the serialized object
  17777. */
  17778. serialize(parent: any): any;
  17779. }
  17780. /**
  17781. * This defines an action responsible to trigger several actions once triggered.
  17782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17783. */
  17784. export class CombineAction extends Action {
  17785. /**
  17786. * The list of aggregated animations to run.
  17787. */
  17788. children: Action[];
  17789. /**
  17790. * Instantiate the action
  17791. * @param triggerOptions defines the trigger options
  17792. * @param children defines the list of aggregated animations to run
  17793. * @param condition defines the trigger related conditions
  17794. */
  17795. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17796. /** @hidden */
  17797. _prepare(): void;
  17798. /**
  17799. * Execute the action and executes all the aggregated actions.
  17800. */
  17801. execute(evt: ActionEvent): void;
  17802. /**
  17803. * Serializes the actions and its related information.
  17804. * @param parent defines the object to serialize in
  17805. * @returns the serialized object
  17806. */
  17807. serialize(parent: any): any;
  17808. }
  17809. /**
  17810. * This defines an action responsible to run code (external event) once triggered.
  17811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17812. */
  17813. export class ExecuteCodeAction extends Action {
  17814. /**
  17815. * The callback function to run.
  17816. */
  17817. func: (evt: ActionEvent) => void;
  17818. /**
  17819. * Instantiate the action
  17820. * @param triggerOptions defines the trigger options
  17821. * @param func defines the callback function to run
  17822. * @param condition defines the trigger related conditions
  17823. */
  17824. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17825. /**
  17826. * Execute the action and run the attached code.
  17827. */
  17828. execute(evt: ActionEvent): void;
  17829. }
  17830. /**
  17831. * This defines an action responsible to set the parent property of the target once triggered.
  17832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17833. */
  17834. export class SetParentAction extends Action {
  17835. private _parent;
  17836. private _target;
  17837. /**
  17838. * Instantiate the action
  17839. * @param triggerOptions defines the trigger options
  17840. * @param target defines the target containing the parent property
  17841. * @param parent defines from where the animation should start (animation frame)
  17842. * @param condition defines the trigger related conditions
  17843. */
  17844. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17845. /** @hidden */
  17846. _prepare(): void;
  17847. /**
  17848. * Execute the action and set the parent property.
  17849. */
  17850. execute(): void;
  17851. /**
  17852. * Serializes the actions and its related information.
  17853. * @param parent defines the object to serialize in
  17854. * @returns the serialized object
  17855. */
  17856. serialize(parent: any): any;
  17857. }
  17858. }
  17859. declare module BABYLON {
  17860. /**
  17861. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17862. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17864. */
  17865. export class ActionManager extends AbstractActionManager {
  17866. /**
  17867. * Nothing
  17868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17869. */
  17870. static readonly NothingTrigger: number;
  17871. /**
  17872. * On pick
  17873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17874. */
  17875. static readonly OnPickTrigger: number;
  17876. /**
  17877. * On left pick
  17878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17879. */
  17880. static readonly OnLeftPickTrigger: number;
  17881. /**
  17882. * On right pick
  17883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17884. */
  17885. static readonly OnRightPickTrigger: number;
  17886. /**
  17887. * On center pick
  17888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17889. */
  17890. static readonly OnCenterPickTrigger: number;
  17891. /**
  17892. * On pick down
  17893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17894. */
  17895. static readonly OnPickDownTrigger: number;
  17896. /**
  17897. * On double pick
  17898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17899. */
  17900. static readonly OnDoublePickTrigger: number;
  17901. /**
  17902. * On pick up
  17903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17904. */
  17905. static readonly OnPickUpTrigger: number;
  17906. /**
  17907. * On pick out.
  17908. * This trigger will only be raised if you also declared a OnPickDown
  17909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17910. */
  17911. static readonly OnPickOutTrigger: number;
  17912. /**
  17913. * On long press
  17914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17915. */
  17916. static readonly OnLongPressTrigger: number;
  17917. /**
  17918. * On pointer over
  17919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17920. */
  17921. static readonly OnPointerOverTrigger: number;
  17922. /**
  17923. * On pointer out
  17924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17925. */
  17926. static readonly OnPointerOutTrigger: number;
  17927. /**
  17928. * On every frame
  17929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17930. */
  17931. static readonly OnEveryFrameTrigger: number;
  17932. /**
  17933. * On intersection enter
  17934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17935. */
  17936. static readonly OnIntersectionEnterTrigger: number;
  17937. /**
  17938. * On intersection exit
  17939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17940. */
  17941. static readonly OnIntersectionExitTrigger: number;
  17942. /**
  17943. * On key down
  17944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17945. */
  17946. static readonly OnKeyDownTrigger: number;
  17947. /**
  17948. * On key up
  17949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17950. */
  17951. static readonly OnKeyUpTrigger: number;
  17952. private _scene;
  17953. /**
  17954. * Creates a new action manager
  17955. * @param scene defines the hosting scene
  17956. */
  17957. constructor(scene: Scene);
  17958. /**
  17959. * Releases all associated resources
  17960. */
  17961. dispose(): void;
  17962. /**
  17963. * Gets hosting scene
  17964. * @returns the hosting scene
  17965. */
  17966. getScene(): Scene;
  17967. /**
  17968. * Does this action manager handles actions of any of the given triggers
  17969. * @param triggers defines the triggers to be tested
  17970. * @return a boolean indicating whether one (or more) of the triggers is handled
  17971. */
  17972. hasSpecificTriggers(triggers: number[]): boolean;
  17973. /**
  17974. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17975. * speed.
  17976. * @param triggerA defines the trigger to be tested
  17977. * @param triggerB defines the trigger to be tested
  17978. * @return a boolean indicating whether one (or more) of the triggers is handled
  17979. */
  17980. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17981. /**
  17982. * Does this action manager handles actions of a given trigger
  17983. * @param trigger defines the trigger to be tested
  17984. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17985. * @return whether the trigger is handled
  17986. */
  17987. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17988. /**
  17989. * Does this action manager has pointer triggers
  17990. */
  17991. get hasPointerTriggers(): boolean;
  17992. /**
  17993. * Does this action manager has pick triggers
  17994. */
  17995. get hasPickTriggers(): boolean;
  17996. /**
  17997. * Registers an action to this action manager
  17998. * @param action defines the action to be registered
  17999. * @return the action amended (prepared) after registration
  18000. */
  18001. registerAction(action: IAction): Nullable<IAction>;
  18002. /**
  18003. * Unregisters an action to this action manager
  18004. * @param action defines the action to be unregistered
  18005. * @return a boolean indicating whether the action has been unregistered
  18006. */
  18007. unregisterAction(action: IAction): Boolean;
  18008. /**
  18009. * Process a specific trigger
  18010. * @param trigger defines the trigger to process
  18011. * @param evt defines the event details to be processed
  18012. */
  18013. processTrigger(trigger: number, evt?: IActionEvent): void;
  18014. /** @hidden */
  18015. _getEffectiveTarget(target: any, propertyPath: string): any;
  18016. /** @hidden */
  18017. _getProperty(propertyPath: string): string;
  18018. /**
  18019. * Serialize this manager to a JSON object
  18020. * @param name defines the property name to store this manager
  18021. * @returns a JSON representation of this manager
  18022. */
  18023. serialize(name: string): any;
  18024. /**
  18025. * Creates a new ActionManager from a JSON data
  18026. * @param parsedActions defines the JSON data to read from
  18027. * @param object defines the hosting mesh
  18028. * @param scene defines the hosting scene
  18029. */
  18030. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18031. /**
  18032. * Get a trigger name by index
  18033. * @param trigger defines the trigger index
  18034. * @returns a trigger name
  18035. */
  18036. static GetTriggerName(trigger: number): string;
  18037. }
  18038. }
  18039. declare module BABYLON {
  18040. /**
  18041. * Class used to represent a sprite
  18042. * @see http://doc.babylonjs.com/babylon101/sprites
  18043. */
  18044. export class Sprite {
  18045. /** defines the name */
  18046. name: string;
  18047. /** Gets or sets the current world position */
  18048. position: Vector3;
  18049. /** Gets or sets the main color */
  18050. color: Color4;
  18051. /** Gets or sets the width */
  18052. width: number;
  18053. /** Gets or sets the height */
  18054. height: number;
  18055. /** Gets or sets rotation angle */
  18056. angle: number;
  18057. /** Gets or sets the cell index in the sprite sheet */
  18058. cellIndex: number;
  18059. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18060. cellRef: string;
  18061. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18062. invertU: number;
  18063. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18064. invertV: number;
  18065. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18066. disposeWhenFinishedAnimating: boolean;
  18067. /** Gets the list of attached animations */
  18068. animations: Animation[];
  18069. /** Gets or sets a boolean indicating if the sprite can be picked */
  18070. isPickable: boolean;
  18071. /**
  18072. * Gets or sets the associated action manager
  18073. */
  18074. actionManager: Nullable<ActionManager>;
  18075. private _animationStarted;
  18076. private _loopAnimation;
  18077. private _fromIndex;
  18078. private _toIndex;
  18079. private _delay;
  18080. private _direction;
  18081. private _manager;
  18082. private _time;
  18083. private _onAnimationEnd;
  18084. /**
  18085. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18086. */
  18087. isVisible: boolean;
  18088. /**
  18089. * Gets or sets the sprite size
  18090. */
  18091. get size(): number;
  18092. set size(value: number);
  18093. /**
  18094. * Creates a new Sprite
  18095. * @param name defines the name
  18096. * @param manager defines the manager
  18097. */
  18098. constructor(
  18099. /** defines the name */
  18100. name: string, manager: ISpriteManager);
  18101. /**
  18102. * Starts an animation
  18103. * @param from defines the initial key
  18104. * @param to defines the end key
  18105. * @param loop defines if the animation must loop
  18106. * @param delay defines the start delay (in ms)
  18107. * @param onAnimationEnd defines a callback to call when animation ends
  18108. */
  18109. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18110. /** Stops current animation (if any) */
  18111. stopAnimation(): void;
  18112. /** @hidden */
  18113. _animate(deltaTime: number): void;
  18114. /** Release associated resources */
  18115. dispose(): void;
  18116. }
  18117. }
  18118. declare module BABYLON {
  18119. /**
  18120. * Information about the result of picking within a scene
  18121. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18122. */
  18123. export class PickingInfo {
  18124. /** @hidden */
  18125. _pickingUnavailable: boolean;
  18126. /**
  18127. * If the pick collided with an object
  18128. */
  18129. hit: boolean;
  18130. /**
  18131. * Distance away where the pick collided
  18132. */
  18133. distance: number;
  18134. /**
  18135. * The location of pick collision
  18136. */
  18137. pickedPoint: Nullable<Vector3>;
  18138. /**
  18139. * The mesh corresponding the the pick collision
  18140. */
  18141. pickedMesh: Nullable<AbstractMesh>;
  18142. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18143. bu: number;
  18144. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18145. bv: number;
  18146. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18147. faceId: number;
  18148. /** Id of the the submesh that was picked */
  18149. subMeshId: number;
  18150. /** If a sprite was picked, this will be the sprite the pick collided with */
  18151. pickedSprite: Nullable<Sprite>;
  18152. /**
  18153. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18154. */
  18155. originMesh: Nullable<AbstractMesh>;
  18156. /**
  18157. * The ray that was used to perform the picking.
  18158. */
  18159. ray: Nullable<Ray>;
  18160. /**
  18161. * Gets the normal correspodning to the face the pick collided with
  18162. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18163. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18164. * @returns The normal correspodning to the face the pick collided with
  18165. */
  18166. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18167. /**
  18168. * Gets the texture coordinates of where the pick occured
  18169. * @returns the vector containing the coordnates of the texture
  18170. */
  18171. getTextureCoordinates(): Nullable<Vector2>;
  18172. }
  18173. }
  18174. declare module BABYLON {
  18175. /**
  18176. * Gather the list of pointer event types as constants.
  18177. */
  18178. export class PointerEventTypes {
  18179. /**
  18180. * 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.
  18181. */
  18182. static readonly POINTERDOWN: number;
  18183. /**
  18184. * The pointerup event is fired when a pointer is no longer active.
  18185. */
  18186. static readonly POINTERUP: number;
  18187. /**
  18188. * The pointermove event is fired when a pointer changes coordinates.
  18189. */
  18190. static readonly POINTERMOVE: number;
  18191. /**
  18192. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18193. */
  18194. static readonly POINTERWHEEL: number;
  18195. /**
  18196. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18197. */
  18198. static readonly POINTERPICK: number;
  18199. /**
  18200. * The pointertap event is fired when a the object has been touched and released without drag.
  18201. */
  18202. static readonly POINTERTAP: number;
  18203. /**
  18204. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18205. */
  18206. static readonly POINTERDOUBLETAP: number;
  18207. }
  18208. /**
  18209. * Base class of pointer info types.
  18210. */
  18211. export class PointerInfoBase {
  18212. /**
  18213. * Defines the type of event (PointerEventTypes)
  18214. */
  18215. type: number;
  18216. /**
  18217. * Defines the related dom event
  18218. */
  18219. event: PointerEvent | MouseWheelEvent;
  18220. /**
  18221. * Instantiates the base class of pointers info.
  18222. * @param type Defines the type of event (PointerEventTypes)
  18223. * @param event Defines the related dom event
  18224. */
  18225. constructor(
  18226. /**
  18227. * Defines the type of event (PointerEventTypes)
  18228. */
  18229. type: number,
  18230. /**
  18231. * Defines the related dom event
  18232. */
  18233. event: PointerEvent | MouseWheelEvent);
  18234. }
  18235. /**
  18236. * This class is used to store pointer related info for the onPrePointerObservable event.
  18237. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18238. */
  18239. export class PointerInfoPre extends PointerInfoBase {
  18240. /**
  18241. * Ray from a pointer if availible (eg. 6dof controller)
  18242. */
  18243. ray: Nullable<Ray>;
  18244. /**
  18245. * Defines the local position of the pointer on the canvas.
  18246. */
  18247. localPosition: Vector2;
  18248. /**
  18249. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18250. */
  18251. skipOnPointerObservable: boolean;
  18252. /**
  18253. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18254. * @param type Defines the type of event (PointerEventTypes)
  18255. * @param event Defines the related dom event
  18256. * @param localX Defines the local x coordinates of the pointer when the event occured
  18257. * @param localY Defines the local y coordinates of the pointer when the event occured
  18258. */
  18259. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18260. }
  18261. /**
  18262. * This type contains all the data related to a pointer event in Babylon.js.
  18263. * 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.
  18264. */
  18265. export class PointerInfo extends PointerInfoBase {
  18266. /**
  18267. * Defines the picking info associated to the info (if any)\
  18268. */
  18269. pickInfo: Nullable<PickingInfo>;
  18270. /**
  18271. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18272. * @param type Defines the type of event (PointerEventTypes)
  18273. * @param event Defines the related dom event
  18274. * @param pickInfo Defines the picking info associated to the info (if any)\
  18275. */
  18276. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18277. /**
  18278. * Defines the picking info associated to the info (if any)\
  18279. */
  18280. pickInfo: Nullable<PickingInfo>);
  18281. }
  18282. /**
  18283. * Data relating to a touch event on the screen.
  18284. */
  18285. export interface PointerTouch {
  18286. /**
  18287. * X coordinate of touch.
  18288. */
  18289. x: number;
  18290. /**
  18291. * Y coordinate of touch.
  18292. */
  18293. y: number;
  18294. /**
  18295. * Id of touch. Unique for each finger.
  18296. */
  18297. pointerId: number;
  18298. /**
  18299. * Event type passed from DOM.
  18300. */
  18301. type: any;
  18302. }
  18303. }
  18304. declare module BABYLON {
  18305. /**
  18306. * Manage the mouse inputs to control the movement of a free camera.
  18307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18308. */
  18309. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18310. /**
  18311. * Define if touch is enabled in the mouse input
  18312. */
  18313. touchEnabled: boolean;
  18314. /**
  18315. * Defines the camera the input is attached to.
  18316. */
  18317. camera: FreeCamera;
  18318. /**
  18319. * Defines the buttons associated with the input to handle camera move.
  18320. */
  18321. buttons: number[];
  18322. /**
  18323. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18324. */
  18325. angularSensibility: number;
  18326. private _pointerInput;
  18327. private _onMouseMove;
  18328. private _observer;
  18329. private previousPosition;
  18330. /**
  18331. * Observable for when a pointer move event occurs containing the move offset
  18332. */
  18333. onPointerMovedObservable: Observable<{
  18334. offsetX: number;
  18335. offsetY: number;
  18336. }>;
  18337. /**
  18338. * @hidden
  18339. * If the camera should be rotated automatically based on pointer movement
  18340. */
  18341. _allowCameraRotation: boolean;
  18342. /**
  18343. * Manage the mouse inputs to control the movement of a free camera.
  18344. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18345. * @param touchEnabled Defines if touch is enabled or not
  18346. */
  18347. constructor(
  18348. /**
  18349. * Define if touch is enabled in the mouse input
  18350. */
  18351. touchEnabled?: boolean);
  18352. /**
  18353. * Attach the input controls to a specific dom element to get the input from.
  18354. * @param element Defines the element the controls should be listened from
  18355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18356. */
  18357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18358. /**
  18359. * Called on JS contextmenu event.
  18360. * Override this method to provide functionality.
  18361. */
  18362. protected onContextMenu(evt: PointerEvent): void;
  18363. /**
  18364. * Detach the current controls from the specified dom element.
  18365. * @param element Defines the element to stop listening the inputs from
  18366. */
  18367. detachControl(element: Nullable<HTMLElement>): void;
  18368. /**
  18369. * Gets the class name of the current intput.
  18370. * @returns the class name
  18371. */
  18372. getClassName(): string;
  18373. /**
  18374. * Get the friendly name associated with the input class.
  18375. * @returns the input friendly name
  18376. */
  18377. getSimpleName(): string;
  18378. }
  18379. }
  18380. declare module BABYLON {
  18381. /**
  18382. * Manage the touch inputs to control the movement of a free camera.
  18383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18384. */
  18385. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18386. /**
  18387. * Defines the camera the input is attached to.
  18388. */
  18389. camera: FreeCamera;
  18390. /**
  18391. * Defines the touch sensibility for rotation.
  18392. * The higher the faster.
  18393. */
  18394. touchAngularSensibility: number;
  18395. /**
  18396. * Defines the touch sensibility for move.
  18397. * The higher the faster.
  18398. */
  18399. touchMoveSensibility: number;
  18400. private _offsetX;
  18401. private _offsetY;
  18402. private _pointerPressed;
  18403. private _pointerInput;
  18404. private _observer;
  18405. private _onLostFocus;
  18406. /**
  18407. * Attach the input controls to a specific dom element to get the input from.
  18408. * @param element Defines the element the controls should be listened from
  18409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18410. */
  18411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18412. /**
  18413. * Detach the current controls from the specified dom element.
  18414. * @param element Defines the element to stop listening the inputs from
  18415. */
  18416. detachControl(element: Nullable<HTMLElement>): void;
  18417. /**
  18418. * Update the current camera state depending on the inputs that have been used this frame.
  18419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18420. */
  18421. checkInputs(): void;
  18422. /**
  18423. * Gets the class name of the current intput.
  18424. * @returns the class name
  18425. */
  18426. getClassName(): string;
  18427. /**
  18428. * Get the friendly name associated with the input class.
  18429. * @returns the input friendly name
  18430. */
  18431. getSimpleName(): string;
  18432. }
  18433. }
  18434. declare module BABYLON {
  18435. /**
  18436. * Default Inputs manager for the FreeCamera.
  18437. * It groups all the default supported inputs for ease of use.
  18438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18439. */
  18440. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18441. /**
  18442. * @hidden
  18443. */
  18444. _mouseInput: Nullable<FreeCameraMouseInput>;
  18445. /**
  18446. * Instantiates a new FreeCameraInputsManager.
  18447. * @param camera Defines the camera the inputs belong to
  18448. */
  18449. constructor(camera: FreeCamera);
  18450. /**
  18451. * Add keyboard input support to the input manager.
  18452. * @returns the current input manager
  18453. */
  18454. addKeyboard(): FreeCameraInputsManager;
  18455. /**
  18456. * Add mouse input support to the input manager.
  18457. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18458. * @returns the current input manager
  18459. */
  18460. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18461. /**
  18462. * Removes the mouse input support from the manager
  18463. * @returns the current input manager
  18464. */
  18465. removeMouse(): FreeCameraInputsManager;
  18466. /**
  18467. * Add touch input support to the input manager.
  18468. * @returns the current input manager
  18469. */
  18470. addTouch(): FreeCameraInputsManager;
  18471. /**
  18472. * Remove all attached input methods from a camera
  18473. */
  18474. clear(): void;
  18475. }
  18476. }
  18477. declare module BABYLON {
  18478. /**
  18479. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18480. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18481. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18482. */
  18483. export class FreeCamera extends TargetCamera {
  18484. /**
  18485. * Define the collision ellipsoid of the camera.
  18486. * This is helpful to simulate a camera body like the player body around the camera
  18487. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18488. */
  18489. ellipsoid: Vector3;
  18490. /**
  18491. * Define an offset for the position of the ellipsoid around the camera.
  18492. * This can be helpful to determine the center of the body near the gravity center of the body
  18493. * instead of its head.
  18494. */
  18495. ellipsoidOffset: Vector3;
  18496. /**
  18497. * Enable or disable collisions of the camera with the rest of the scene objects.
  18498. */
  18499. checkCollisions: boolean;
  18500. /**
  18501. * Enable or disable gravity on the camera.
  18502. */
  18503. applyGravity: boolean;
  18504. /**
  18505. * Define the input manager associated to the camera.
  18506. */
  18507. inputs: FreeCameraInputsManager;
  18508. /**
  18509. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18510. * Higher values reduce sensitivity.
  18511. */
  18512. get angularSensibility(): number;
  18513. /**
  18514. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18515. * Higher values reduce sensitivity.
  18516. */
  18517. set angularSensibility(value: number);
  18518. /**
  18519. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18520. */
  18521. get keysUp(): number[];
  18522. set keysUp(value: number[]);
  18523. /**
  18524. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18525. */
  18526. get keysUpward(): number[];
  18527. set keysUpward(value: number[]);
  18528. /**
  18529. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18530. */
  18531. get keysDown(): number[];
  18532. set keysDown(value: number[]);
  18533. /**
  18534. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18535. */
  18536. get keysDownward(): number[];
  18537. set keysDownward(value: number[]);
  18538. /**
  18539. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18540. */
  18541. get keysLeft(): number[];
  18542. set keysLeft(value: number[]);
  18543. /**
  18544. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18545. */
  18546. get keysRight(): number[];
  18547. set keysRight(value: number[]);
  18548. /**
  18549. * Event raised when the camera collide with a mesh in the scene.
  18550. */
  18551. onCollide: (collidedMesh: AbstractMesh) => void;
  18552. private _collider;
  18553. private _needMoveForGravity;
  18554. private _oldPosition;
  18555. private _diffPosition;
  18556. private _newPosition;
  18557. /** @hidden */
  18558. _localDirection: Vector3;
  18559. /** @hidden */
  18560. _transformedDirection: Vector3;
  18561. /**
  18562. * Instantiates a Free Camera.
  18563. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18564. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18565. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18566. * @param name Define the name of the camera in the scene
  18567. * @param position Define the start position of the camera in the scene
  18568. * @param scene Define the scene the camera belongs to
  18569. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18570. */
  18571. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18572. /**
  18573. * Attached controls to the current camera.
  18574. * @param element Defines the element the controls should be listened from
  18575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18576. */
  18577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18578. /**
  18579. * Detach the current controls from the camera.
  18580. * The camera will stop reacting to inputs.
  18581. * @param element Defines the element to stop listening the inputs from
  18582. */
  18583. detachControl(element: HTMLElement): void;
  18584. private _collisionMask;
  18585. /**
  18586. * Define a collision mask to limit the list of object the camera can collide with
  18587. */
  18588. get collisionMask(): number;
  18589. set collisionMask(mask: number);
  18590. /** @hidden */
  18591. _collideWithWorld(displacement: Vector3): void;
  18592. private _onCollisionPositionChange;
  18593. /** @hidden */
  18594. _checkInputs(): void;
  18595. /** @hidden */
  18596. _decideIfNeedsToMove(): boolean;
  18597. /** @hidden */
  18598. _updatePosition(): void;
  18599. /**
  18600. * Destroy the camera and release the current resources hold by it.
  18601. */
  18602. dispose(): void;
  18603. /**
  18604. * Gets the current object class name.
  18605. * @return the class name
  18606. */
  18607. getClassName(): string;
  18608. }
  18609. }
  18610. declare module BABYLON {
  18611. /**
  18612. * Represents a gamepad control stick position
  18613. */
  18614. export class StickValues {
  18615. /**
  18616. * The x component of the control stick
  18617. */
  18618. x: number;
  18619. /**
  18620. * The y component of the control stick
  18621. */
  18622. y: number;
  18623. /**
  18624. * Initializes the gamepad x and y control stick values
  18625. * @param x The x component of the gamepad control stick value
  18626. * @param y The y component of the gamepad control stick value
  18627. */
  18628. constructor(
  18629. /**
  18630. * The x component of the control stick
  18631. */
  18632. x: number,
  18633. /**
  18634. * The y component of the control stick
  18635. */
  18636. y: number);
  18637. }
  18638. /**
  18639. * An interface which manages callbacks for gamepad button changes
  18640. */
  18641. export interface GamepadButtonChanges {
  18642. /**
  18643. * Called when a gamepad has been changed
  18644. */
  18645. changed: boolean;
  18646. /**
  18647. * Called when a gamepad press event has been triggered
  18648. */
  18649. pressChanged: boolean;
  18650. /**
  18651. * Called when a touch event has been triggered
  18652. */
  18653. touchChanged: boolean;
  18654. /**
  18655. * Called when a value has changed
  18656. */
  18657. valueChanged: boolean;
  18658. }
  18659. /**
  18660. * Represents a gamepad
  18661. */
  18662. export class Gamepad {
  18663. /**
  18664. * The id of the gamepad
  18665. */
  18666. id: string;
  18667. /**
  18668. * The index of the gamepad
  18669. */
  18670. index: number;
  18671. /**
  18672. * The browser gamepad
  18673. */
  18674. browserGamepad: any;
  18675. /**
  18676. * Specifies what type of gamepad this represents
  18677. */
  18678. type: number;
  18679. private _leftStick;
  18680. private _rightStick;
  18681. /** @hidden */
  18682. _isConnected: boolean;
  18683. private _leftStickAxisX;
  18684. private _leftStickAxisY;
  18685. private _rightStickAxisX;
  18686. private _rightStickAxisY;
  18687. /**
  18688. * Triggered when the left control stick has been changed
  18689. */
  18690. private _onleftstickchanged;
  18691. /**
  18692. * Triggered when the right control stick has been changed
  18693. */
  18694. private _onrightstickchanged;
  18695. /**
  18696. * Represents a gamepad controller
  18697. */
  18698. static GAMEPAD: number;
  18699. /**
  18700. * Represents a generic controller
  18701. */
  18702. static GENERIC: number;
  18703. /**
  18704. * Represents an XBox controller
  18705. */
  18706. static XBOX: number;
  18707. /**
  18708. * Represents a pose-enabled controller
  18709. */
  18710. static POSE_ENABLED: number;
  18711. /**
  18712. * Represents an Dual Shock controller
  18713. */
  18714. static DUALSHOCK: number;
  18715. /**
  18716. * Specifies whether the left control stick should be Y-inverted
  18717. */
  18718. protected _invertLeftStickY: boolean;
  18719. /**
  18720. * Specifies if the gamepad has been connected
  18721. */
  18722. get isConnected(): boolean;
  18723. /**
  18724. * Initializes the gamepad
  18725. * @param id The id of the gamepad
  18726. * @param index The index of the gamepad
  18727. * @param browserGamepad The browser gamepad
  18728. * @param leftStickX The x component of the left joystick
  18729. * @param leftStickY The y component of the left joystick
  18730. * @param rightStickX The x component of the right joystick
  18731. * @param rightStickY The y component of the right joystick
  18732. */
  18733. constructor(
  18734. /**
  18735. * The id of the gamepad
  18736. */
  18737. id: string,
  18738. /**
  18739. * The index of the gamepad
  18740. */
  18741. index: number,
  18742. /**
  18743. * The browser gamepad
  18744. */
  18745. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18746. /**
  18747. * Callback triggered when the left joystick has changed
  18748. * @param callback
  18749. */
  18750. onleftstickchanged(callback: (values: StickValues) => void): void;
  18751. /**
  18752. * Callback triggered when the right joystick has changed
  18753. * @param callback
  18754. */
  18755. onrightstickchanged(callback: (values: StickValues) => void): void;
  18756. /**
  18757. * Gets the left joystick
  18758. */
  18759. get leftStick(): StickValues;
  18760. /**
  18761. * Sets the left joystick values
  18762. */
  18763. set leftStick(newValues: StickValues);
  18764. /**
  18765. * Gets the right joystick
  18766. */
  18767. get rightStick(): StickValues;
  18768. /**
  18769. * Sets the right joystick value
  18770. */
  18771. set rightStick(newValues: StickValues);
  18772. /**
  18773. * Updates the gamepad joystick positions
  18774. */
  18775. update(): void;
  18776. /**
  18777. * Disposes the gamepad
  18778. */
  18779. dispose(): void;
  18780. }
  18781. /**
  18782. * Represents a generic gamepad
  18783. */
  18784. export class GenericPad extends Gamepad {
  18785. private _buttons;
  18786. private _onbuttondown;
  18787. private _onbuttonup;
  18788. /**
  18789. * Observable triggered when a button has been pressed
  18790. */
  18791. onButtonDownObservable: Observable<number>;
  18792. /**
  18793. * Observable triggered when a button has been released
  18794. */
  18795. onButtonUpObservable: Observable<number>;
  18796. /**
  18797. * Callback triggered when a button has been pressed
  18798. * @param callback Called when a button has been pressed
  18799. */
  18800. onbuttondown(callback: (buttonPressed: number) => void): void;
  18801. /**
  18802. * Callback triggered when a button has been released
  18803. * @param callback Called when a button has been released
  18804. */
  18805. onbuttonup(callback: (buttonReleased: number) => void): void;
  18806. /**
  18807. * Initializes the generic gamepad
  18808. * @param id The id of the generic gamepad
  18809. * @param index The index of the generic gamepad
  18810. * @param browserGamepad The browser gamepad
  18811. */
  18812. constructor(id: string, index: number, browserGamepad: any);
  18813. private _setButtonValue;
  18814. /**
  18815. * Updates the generic gamepad
  18816. */
  18817. update(): void;
  18818. /**
  18819. * Disposes the generic gamepad
  18820. */
  18821. dispose(): void;
  18822. }
  18823. }
  18824. declare module BABYLON {
  18825. /**
  18826. * Defines the types of pose enabled controllers that are supported
  18827. */
  18828. export enum PoseEnabledControllerType {
  18829. /**
  18830. * HTC Vive
  18831. */
  18832. VIVE = 0,
  18833. /**
  18834. * Oculus Rift
  18835. */
  18836. OCULUS = 1,
  18837. /**
  18838. * Windows mixed reality
  18839. */
  18840. WINDOWS = 2,
  18841. /**
  18842. * Samsung gear VR
  18843. */
  18844. GEAR_VR = 3,
  18845. /**
  18846. * Google Daydream
  18847. */
  18848. DAYDREAM = 4,
  18849. /**
  18850. * Generic
  18851. */
  18852. GENERIC = 5
  18853. }
  18854. /**
  18855. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18856. */
  18857. export interface MutableGamepadButton {
  18858. /**
  18859. * Value of the button/trigger
  18860. */
  18861. value: number;
  18862. /**
  18863. * If the button/trigger is currently touched
  18864. */
  18865. touched: boolean;
  18866. /**
  18867. * If the button/trigger is currently pressed
  18868. */
  18869. pressed: boolean;
  18870. }
  18871. /**
  18872. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18873. * @hidden
  18874. */
  18875. export interface ExtendedGamepadButton extends GamepadButton {
  18876. /**
  18877. * If the button/trigger is currently pressed
  18878. */
  18879. readonly pressed: boolean;
  18880. /**
  18881. * If the button/trigger is currently touched
  18882. */
  18883. readonly touched: boolean;
  18884. /**
  18885. * Value of the button/trigger
  18886. */
  18887. readonly value: number;
  18888. }
  18889. /** @hidden */
  18890. export interface _GamePadFactory {
  18891. /**
  18892. * Returns whether or not the current gamepad can be created for this type of controller.
  18893. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18894. * @returns true if it can be created, otherwise false
  18895. */
  18896. canCreate(gamepadInfo: any): boolean;
  18897. /**
  18898. * Creates a new instance of the Gamepad.
  18899. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18900. * @returns the new gamepad instance
  18901. */
  18902. create(gamepadInfo: any): Gamepad;
  18903. }
  18904. /**
  18905. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18906. */
  18907. export class PoseEnabledControllerHelper {
  18908. /** @hidden */
  18909. static _ControllerFactories: _GamePadFactory[];
  18910. /** @hidden */
  18911. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18912. /**
  18913. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18914. * @param vrGamepad the gamepad to initialized
  18915. * @returns a vr controller of the type the gamepad identified as
  18916. */
  18917. static InitiateController(vrGamepad: any): Gamepad;
  18918. }
  18919. /**
  18920. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18921. */
  18922. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18923. /**
  18924. * If the controller is used in a webXR session
  18925. */
  18926. isXR: boolean;
  18927. private _deviceRoomPosition;
  18928. private _deviceRoomRotationQuaternion;
  18929. /**
  18930. * The device position in babylon space
  18931. */
  18932. devicePosition: Vector3;
  18933. /**
  18934. * The device rotation in babylon space
  18935. */
  18936. deviceRotationQuaternion: Quaternion;
  18937. /**
  18938. * The scale factor of the device in babylon space
  18939. */
  18940. deviceScaleFactor: number;
  18941. /**
  18942. * (Likely devicePosition should be used instead) The device position in its room space
  18943. */
  18944. position: Vector3;
  18945. /**
  18946. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18947. */
  18948. rotationQuaternion: Quaternion;
  18949. /**
  18950. * The type of controller (Eg. Windows mixed reality)
  18951. */
  18952. controllerType: PoseEnabledControllerType;
  18953. protected _calculatedPosition: Vector3;
  18954. private _calculatedRotation;
  18955. /**
  18956. * The raw pose from the device
  18957. */
  18958. rawPose: DevicePose;
  18959. private _trackPosition;
  18960. private _maxRotationDistFromHeadset;
  18961. private _draggedRoomRotation;
  18962. /**
  18963. * @hidden
  18964. */
  18965. _disableTrackPosition(fixedPosition: Vector3): void;
  18966. /**
  18967. * Internal, the mesh attached to the controller
  18968. * @hidden
  18969. */
  18970. _mesh: Nullable<AbstractMesh>;
  18971. private _poseControlledCamera;
  18972. private _leftHandSystemQuaternion;
  18973. /**
  18974. * Internal, matrix used to convert room space to babylon space
  18975. * @hidden
  18976. */
  18977. _deviceToWorld: Matrix;
  18978. /**
  18979. * Node to be used when casting a ray from the controller
  18980. * @hidden
  18981. */
  18982. _pointingPoseNode: Nullable<TransformNode>;
  18983. /**
  18984. * Name of the child mesh that can be used to cast a ray from the controller
  18985. */
  18986. static readonly POINTING_POSE: string;
  18987. /**
  18988. * Creates a new PoseEnabledController from a gamepad
  18989. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18990. */
  18991. constructor(browserGamepad: any);
  18992. private _workingMatrix;
  18993. /**
  18994. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18995. */
  18996. update(): void;
  18997. /**
  18998. * Updates only the pose device and mesh without doing any button event checking
  18999. */
  19000. protected _updatePoseAndMesh(): void;
  19001. /**
  19002. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19003. * @param poseData raw pose fromthe device
  19004. */
  19005. updateFromDevice(poseData: DevicePose): void;
  19006. /**
  19007. * @hidden
  19008. */
  19009. _meshAttachedObservable: Observable<AbstractMesh>;
  19010. /**
  19011. * Attaches a mesh to the controller
  19012. * @param mesh the mesh to be attached
  19013. */
  19014. attachToMesh(mesh: AbstractMesh): void;
  19015. /**
  19016. * Attaches the controllers mesh to a camera
  19017. * @param camera the camera the mesh should be attached to
  19018. */
  19019. attachToPoseControlledCamera(camera: TargetCamera): void;
  19020. /**
  19021. * Disposes of the controller
  19022. */
  19023. dispose(): void;
  19024. /**
  19025. * The mesh that is attached to the controller
  19026. */
  19027. get mesh(): Nullable<AbstractMesh>;
  19028. /**
  19029. * Gets the ray of the controller in the direction the controller is pointing
  19030. * @param length the length the resulting ray should be
  19031. * @returns a ray in the direction the controller is pointing
  19032. */
  19033. getForwardRay(length?: number): Ray;
  19034. }
  19035. }
  19036. declare module BABYLON {
  19037. /**
  19038. * Defines the WebVRController object that represents controllers tracked in 3D space
  19039. */
  19040. export abstract class WebVRController extends PoseEnabledController {
  19041. /**
  19042. * Internal, the default controller model for the controller
  19043. */
  19044. protected _defaultModel: Nullable<AbstractMesh>;
  19045. /**
  19046. * Fired when the trigger state has changed
  19047. */
  19048. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19049. /**
  19050. * Fired when the main button state has changed
  19051. */
  19052. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19053. /**
  19054. * Fired when the secondary button state has changed
  19055. */
  19056. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19057. /**
  19058. * Fired when the pad state has changed
  19059. */
  19060. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19061. /**
  19062. * Fired when controllers stick values have changed
  19063. */
  19064. onPadValuesChangedObservable: Observable<StickValues>;
  19065. /**
  19066. * Array of button availible on the controller
  19067. */
  19068. protected _buttons: Array<MutableGamepadButton>;
  19069. private _onButtonStateChange;
  19070. /**
  19071. * Fired when a controller button's state has changed
  19072. * @param callback the callback containing the button that was modified
  19073. */
  19074. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19075. /**
  19076. * X and Y axis corresponding to the controllers joystick
  19077. */
  19078. pad: StickValues;
  19079. /**
  19080. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19081. */
  19082. hand: string;
  19083. /**
  19084. * The default controller model for the controller
  19085. */
  19086. get defaultModel(): Nullable<AbstractMesh>;
  19087. /**
  19088. * Creates a new WebVRController from a gamepad
  19089. * @param vrGamepad the gamepad that the WebVRController should be created from
  19090. */
  19091. constructor(vrGamepad: any);
  19092. /**
  19093. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19094. */
  19095. update(): void;
  19096. /**
  19097. * Function to be called when a button is modified
  19098. */
  19099. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19100. /**
  19101. * Loads a mesh and attaches it to the controller
  19102. * @param scene the scene the mesh should be added to
  19103. * @param meshLoaded callback for when the mesh has been loaded
  19104. */
  19105. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19106. private _setButtonValue;
  19107. private _changes;
  19108. private _checkChanges;
  19109. /**
  19110. * Disposes of th webVRCOntroller
  19111. */
  19112. dispose(): void;
  19113. }
  19114. }
  19115. declare module BABYLON {
  19116. /**
  19117. * The HemisphericLight simulates the ambient environment light,
  19118. * so the passed direction is the light reflection direction, not the incoming direction.
  19119. */
  19120. export class HemisphericLight extends Light {
  19121. /**
  19122. * The groundColor is the light in the opposite direction to the one specified during creation.
  19123. * 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.
  19124. */
  19125. groundColor: Color3;
  19126. /**
  19127. * The light reflection direction, not the incoming direction.
  19128. */
  19129. direction: Vector3;
  19130. /**
  19131. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19132. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19133. * The HemisphericLight can't cast shadows.
  19134. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19135. * @param name The friendly name of the light
  19136. * @param direction The direction of the light reflection
  19137. * @param scene The scene the light belongs to
  19138. */
  19139. constructor(name: string, direction: Vector3, scene: Scene);
  19140. protected _buildUniformLayout(): void;
  19141. /**
  19142. * Returns the string "HemisphericLight".
  19143. * @return The class name
  19144. */
  19145. getClassName(): string;
  19146. /**
  19147. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19148. * Returns the updated direction.
  19149. * @param target The target the direction should point to
  19150. * @return The computed direction
  19151. */
  19152. setDirectionToTarget(target: Vector3): Vector3;
  19153. /**
  19154. * Returns the shadow generator associated to the light.
  19155. * @returns Always null for hemispheric lights because it does not support shadows.
  19156. */
  19157. getShadowGenerator(): Nullable<IShadowGenerator>;
  19158. /**
  19159. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19160. * @param effect The effect to update
  19161. * @param lightIndex The index of the light in the effect to update
  19162. * @returns The hemispheric light
  19163. */
  19164. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19165. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19166. /**
  19167. * Computes the world matrix of the node
  19168. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19169. * @param useWasUpdatedFlag defines a reserved property
  19170. * @returns the world matrix
  19171. */
  19172. computeWorldMatrix(): Matrix;
  19173. /**
  19174. * Returns the integer 3.
  19175. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19176. */
  19177. getTypeID(): number;
  19178. /**
  19179. * Prepares the list of defines specific to the light type.
  19180. * @param defines the list of defines
  19181. * @param lightIndex defines the index of the light for the effect
  19182. */
  19183. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19184. }
  19185. }
  19186. declare module BABYLON {
  19187. /** @hidden */
  19188. export var vrMultiviewToSingleviewPixelShader: {
  19189. name: string;
  19190. shader: string;
  19191. };
  19192. }
  19193. declare module BABYLON {
  19194. /**
  19195. * Renders to multiple views with a single draw call
  19196. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19197. */
  19198. export class MultiviewRenderTarget extends RenderTargetTexture {
  19199. /**
  19200. * Creates a multiview render target
  19201. * @param scene scene used with the render target
  19202. * @param size the size of the render target (used for each view)
  19203. */
  19204. constructor(scene: Scene, size?: number | {
  19205. width: number;
  19206. height: number;
  19207. } | {
  19208. ratio: number;
  19209. });
  19210. /**
  19211. * @hidden
  19212. * @param faceIndex the face index, if its a cube texture
  19213. */
  19214. _bindFrameBuffer(faceIndex?: number): void;
  19215. /**
  19216. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19217. * @returns the view count
  19218. */
  19219. getViewCount(): number;
  19220. }
  19221. }
  19222. declare module BABYLON {
  19223. /**
  19224. * Represents a camera frustum
  19225. */
  19226. export class Frustum {
  19227. /**
  19228. * Gets the planes representing the frustum
  19229. * @param transform matrix to be applied to the returned planes
  19230. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19231. */
  19232. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19233. /**
  19234. * Gets the near frustum plane transformed by the transform matrix
  19235. * @param transform transformation matrix to be applied to the resulting frustum plane
  19236. * @param frustumPlane the resuling frustum plane
  19237. */
  19238. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19239. /**
  19240. * Gets the far frustum plane transformed by the transform matrix
  19241. * @param transform transformation matrix to be applied to the resulting frustum plane
  19242. * @param frustumPlane the resuling frustum plane
  19243. */
  19244. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19245. /**
  19246. * Gets the left frustum plane transformed by the transform matrix
  19247. * @param transform transformation matrix to be applied to the resulting frustum plane
  19248. * @param frustumPlane the resuling frustum plane
  19249. */
  19250. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19251. /**
  19252. * Gets the right frustum plane transformed by the transform matrix
  19253. * @param transform transformation matrix to be applied to the resulting frustum plane
  19254. * @param frustumPlane the resuling frustum plane
  19255. */
  19256. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19257. /**
  19258. * Gets the top frustum plane transformed by the transform matrix
  19259. * @param transform transformation matrix to be applied to the resulting frustum plane
  19260. * @param frustumPlane the resuling frustum plane
  19261. */
  19262. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19263. /**
  19264. * Gets the bottom frustum plane transformed by the transform matrix
  19265. * @param transform transformation matrix to be applied to the resulting frustum plane
  19266. * @param frustumPlane the resuling frustum plane
  19267. */
  19268. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19269. /**
  19270. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19271. * @param transform transformation matrix to be applied to the resulting frustum planes
  19272. * @param frustumPlanes the resuling frustum planes
  19273. */
  19274. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19275. }
  19276. }
  19277. declare module BABYLON {
  19278. interface Engine {
  19279. /**
  19280. * Creates a new multiview render target
  19281. * @param width defines the width of the texture
  19282. * @param height defines the height of the texture
  19283. * @returns the created multiview texture
  19284. */
  19285. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19286. /**
  19287. * Binds a multiview framebuffer to be drawn to
  19288. * @param multiviewTexture texture to bind
  19289. */
  19290. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19291. }
  19292. interface Camera {
  19293. /**
  19294. * @hidden
  19295. * 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)
  19296. */
  19297. _useMultiviewToSingleView: boolean;
  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. _multiviewTexture: Nullable<RenderTargetTexture>;
  19303. /**
  19304. * @hidden
  19305. * ensures the multiview texture of the camera exists and has the specified width/height
  19306. * @param width height to set on the multiview texture
  19307. * @param height width to set on the multiview texture
  19308. */
  19309. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19310. }
  19311. interface Scene {
  19312. /** @hidden */
  19313. _transformMatrixR: Matrix;
  19314. /** @hidden */
  19315. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19316. /** @hidden */
  19317. _createMultiviewUbo(): void;
  19318. /** @hidden */
  19319. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19320. /** @hidden */
  19321. _renderMultiviewToSingleView(camera: Camera): void;
  19322. }
  19323. }
  19324. declare module BABYLON {
  19325. /**
  19326. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19327. * This will not be used for webXR as it supports displaying texture arrays directly
  19328. */
  19329. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19330. /**
  19331. * Initializes a VRMultiviewToSingleview
  19332. * @param name name of the post process
  19333. * @param camera camera to be applied to
  19334. * @param scaleFactor scaling factor to the size of the output texture
  19335. */
  19336. constructor(name: string, camera: Camera, scaleFactor: number);
  19337. }
  19338. }
  19339. declare module BABYLON {
  19340. /**
  19341. * Interface used to define additional presentation attributes
  19342. */
  19343. export interface IVRPresentationAttributes {
  19344. /**
  19345. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19346. */
  19347. highRefreshRate: boolean;
  19348. /**
  19349. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19350. */
  19351. foveationLevel: number;
  19352. }
  19353. interface Engine {
  19354. /** @hidden */
  19355. _vrDisplay: any;
  19356. /** @hidden */
  19357. _vrSupported: boolean;
  19358. /** @hidden */
  19359. _oldSize: Size;
  19360. /** @hidden */
  19361. _oldHardwareScaleFactor: number;
  19362. /** @hidden */
  19363. _vrExclusivePointerMode: boolean;
  19364. /** @hidden */
  19365. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19366. /** @hidden */
  19367. _onVRDisplayPointerRestricted: () => void;
  19368. /** @hidden */
  19369. _onVRDisplayPointerUnrestricted: () => void;
  19370. /** @hidden */
  19371. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19372. /** @hidden */
  19373. _onVrDisplayDisconnect: Nullable<() => void>;
  19374. /** @hidden */
  19375. _onVrDisplayPresentChange: Nullable<() => void>;
  19376. /**
  19377. * Observable signaled when VR display mode changes
  19378. */
  19379. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19380. /**
  19381. * Observable signaled when VR request present is complete
  19382. */
  19383. onVRRequestPresentComplete: Observable<boolean>;
  19384. /**
  19385. * Observable signaled when VR request present starts
  19386. */
  19387. onVRRequestPresentStart: Observable<Engine>;
  19388. /**
  19389. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19390. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19391. */
  19392. isInVRExclusivePointerMode: boolean;
  19393. /**
  19394. * Gets a boolean indicating if a webVR device was detected
  19395. * @returns true if a webVR device was detected
  19396. */
  19397. isVRDevicePresent(): boolean;
  19398. /**
  19399. * Gets the current webVR device
  19400. * @returns the current webVR device (or null)
  19401. */
  19402. getVRDevice(): any;
  19403. /**
  19404. * Initializes a webVR display and starts listening to display change events
  19405. * The onVRDisplayChangedObservable will be notified upon these changes
  19406. * @returns A promise containing a VRDisplay and if vr is supported
  19407. */
  19408. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19409. /** @hidden */
  19410. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19411. /**
  19412. * Gets or sets the presentation attributes used to configure VR rendering
  19413. */
  19414. vrPresentationAttributes?: IVRPresentationAttributes;
  19415. /**
  19416. * Call this function to switch to webVR mode
  19417. * Will do nothing if webVR is not supported or if there is no webVR device
  19418. * @param options the webvr options provided to the camera. mainly used for multiview
  19419. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19420. */
  19421. enableVR(options: WebVROptions): void;
  19422. /** @hidden */
  19423. _onVRFullScreenTriggered(): void;
  19424. }
  19425. }
  19426. declare module BABYLON {
  19427. /**
  19428. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19429. * IMPORTANT!! The data is right-hand data.
  19430. * @export
  19431. * @interface DevicePose
  19432. */
  19433. export interface DevicePose {
  19434. /**
  19435. * The position of the device, values in array are [x,y,z].
  19436. */
  19437. readonly position: Nullable<Float32Array>;
  19438. /**
  19439. * The linearVelocity of the device, values in array are [x,y,z].
  19440. */
  19441. readonly linearVelocity: Nullable<Float32Array>;
  19442. /**
  19443. * The linearAcceleration of the device, values in array are [x,y,z].
  19444. */
  19445. readonly linearAcceleration: Nullable<Float32Array>;
  19446. /**
  19447. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19448. */
  19449. readonly orientation: Nullable<Float32Array>;
  19450. /**
  19451. * The angularVelocity of the device, values in array are [x,y,z].
  19452. */
  19453. readonly angularVelocity: Nullable<Float32Array>;
  19454. /**
  19455. * The angularAcceleration of the device, values in array are [x,y,z].
  19456. */
  19457. readonly angularAcceleration: Nullable<Float32Array>;
  19458. }
  19459. /**
  19460. * Interface representing a pose controlled object in Babylon.
  19461. * A pose controlled object has both regular pose values as well as pose values
  19462. * from an external device such as a VR head mounted display
  19463. */
  19464. export interface PoseControlled {
  19465. /**
  19466. * The position of the object in babylon space.
  19467. */
  19468. position: Vector3;
  19469. /**
  19470. * The rotation quaternion of the object in babylon space.
  19471. */
  19472. rotationQuaternion: Quaternion;
  19473. /**
  19474. * The position of the device in babylon space.
  19475. */
  19476. devicePosition?: Vector3;
  19477. /**
  19478. * The rotation quaternion of the device in babylon space.
  19479. */
  19480. deviceRotationQuaternion: Quaternion;
  19481. /**
  19482. * The raw pose coming from the device.
  19483. */
  19484. rawPose: Nullable<DevicePose>;
  19485. /**
  19486. * The scale of the device to be used when translating from device space to babylon space.
  19487. */
  19488. deviceScaleFactor: number;
  19489. /**
  19490. * Updates the poseControlled values based on the input device pose.
  19491. * @param poseData the pose data to update the object with
  19492. */
  19493. updateFromDevice(poseData: DevicePose): void;
  19494. }
  19495. /**
  19496. * Set of options to customize the webVRCamera
  19497. */
  19498. export interface WebVROptions {
  19499. /**
  19500. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19501. */
  19502. trackPosition?: boolean;
  19503. /**
  19504. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19505. */
  19506. positionScale?: number;
  19507. /**
  19508. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19509. */
  19510. displayName?: string;
  19511. /**
  19512. * Should the native controller meshes be initialized. (default: true)
  19513. */
  19514. controllerMeshes?: boolean;
  19515. /**
  19516. * Creating a default HemiLight only on controllers. (default: true)
  19517. */
  19518. defaultLightingOnControllers?: boolean;
  19519. /**
  19520. * If you don't want to use the default VR button of the helper. (default: false)
  19521. */
  19522. useCustomVRButton?: boolean;
  19523. /**
  19524. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19525. */
  19526. customVRButton?: HTMLButtonElement;
  19527. /**
  19528. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19529. */
  19530. rayLength?: number;
  19531. /**
  19532. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19533. */
  19534. defaultHeight?: number;
  19535. /**
  19536. * If multiview should be used if availible (default: false)
  19537. */
  19538. useMultiview?: boolean;
  19539. }
  19540. /**
  19541. * This represents a WebVR camera.
  19542. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19543. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19544. */
  19545. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19546. private webVROptions;
  19547. /**
  19548. * @hidden
  19549. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19550. */
  19551. _vrDevice: any;
  19552. /**
  19553. * The rawPose of the vrDevice.
  19554. */
  19555. rawPose: Nullable<DevicePose>;
  19556. private _onVREnabled;
  19557. private _specsVersion;
  19558. private _attached;
  19559. private _frameData;
  19560. protected _descendants: Array<Node>;
  19561. private _deviceRoomPosition;
  19562. /** @hidden */
  19563. _deviceRoomRotationQuaternion: Quaternion;
  19564. private _standingMatrix;
  19565. /**
  19566. * Represents device position in babylon space.
  19567. */
  19568. devicePosition: Vector3;
  19569. /**
  19570. * Represents device rotation in babylon space.
  19571. */
  19572. deviceRotationQuaternion: Quaternion;
  19573. /**
  19574. * The scale of the device to be used when translating from device space to babylon space.
  19575. */
  19576. deviceScaleFactor: number;
  19577. private _deviceToWorld;
  19578. private _worldToDevice;
  19579. /**
  19580. * References to the webVR controllers for the vrDevice.
  19581. */
  19582. controllers: Array<WebVRController>;
  19583. /**
  19584. * Emits an event when a controller is attached.
  19585. */
  19586. onControllersAttachedObservable: Observable<WebVRController[]>;
  19587. /**
  19588. * Emits an event when a controller's mesh has been loaded;
  19589. */
  19590. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19591. /**
  19592. * Emits an event when the HMD's pose has been updated.
  19593. */
  19594. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19595. private _poseSet;
  19596. /**
  19597. * If the rig cameras be used as parent instead of this camera.
  19598. */
  19599. rigParenting: boolean;
  19600. private _lightOnControllers;
  19601. private _defaultHeight?;
  19602. /**
  19603. * Instantiates a WebVRFreeCamera.
  19604. * @param name The name of the WebVRFreeCamera
  19605. * @param position The starting anchor position for the camera
  19606. * @param scene The scene the camera belongs to
  19607. * @param webVROptions a set of customizable options for the webVRCamera
  19608. */
  19609. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19610. /**
  19611. * Gets the device distance from the ground in meters.
  19612. * @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.
  19613. */
  19614. deviceDistanceToRoomGround(): number;
  19615. /**
  19616. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19617. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19618. */
  19619. useStandingMatrix(callback?: (bool: boolean) => void): void;
  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. * @returns A promise with a boolean set to if the standing matrix is supported.
  19623. */
  19624. useStandingMatrixAsync(): Promise<boolean>;
  19625. /**
  19626. * Disposes the camera
  19627. */
  19628. dispose(): void;
  19629. /**
  19630. * Gets a vrController by name.
  19631. * @param name The name of the controller to retreive
  19632. * @returns the controller matching the name specified or null if not found
  19633. */
  19634. getControllerByName(name: string): Nullable<WebVRController>;
  19635. private _leftController;
  19636. /**
  19637. * The controller corresponding to the users left hand.
  19638. */
  19639. get leftController(): Nullable<WebVRController>;
  19640. private _rightController;
  19641. /**
  19642. * The controller corresponding to the users right hand.
  19643. */
  19644. get rightController(): Nullable<WebVRController>;
  19645. /**
  19646. * Casts a ray forward from the vrCamera's gaze.
  19647. * @param length Length of the ray (default: 100)
  19648. * @returns the ray corresponding to the gaze
  19649. */
  19650. getForwardRay(length?: number): Ray;
  19651. /**
  19652. * @hidden
  19653. * Updates the camera based on device's frame data
  19654. */
  19655. _checkInputs(): void;
  19656. /**
  19657. * Updates the poseControlled values based on the input device pose.
  19658. * @param poseData Pose coming from the device
  19659. */
  19660. updateFromDevice(poseData: DevicePose): void;
  19661. private _htmlElementAttached;
  19662. private _detachIfAttached;
  19663. /**
  19664. * WebVR's attach control will start broadcasting frames to the device.
  19665. * Note that in certain browsers (chrome for example) this function must be called
  19666. * within a user-interaction callback. Example:
  19667. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19668. *
  19669. * @param element html element to attach the vrDevice to
  19670. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19671. */
  19672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19673. /**
  19674. * Detaches the camera from the html element and disables VR
  19675. *
  19676. * @param element html element to detach from
  19677. */
  19678. detachControl(element: HTMLElement): void;
  19679. /**
  19680. * @returns the name of this class
  19681. */
  19682. getClassName(): string;
  19683. /**
  19684. * Calls resetPose on the vrDisplay
  19685. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19686. */
  19687. resetToCurrentRotation(): void;
  19688. /**
  19689. * @hidden
  19690. * Updates the rig cameras (left and right eye)
  19691. */
  19692. _updateRigCameras(): void;
  19693. private _workingVector;
  19694. private _oneVector;
  19695. private _workingMatrix;
  19696. private updateCacheCalled;
  19697. private _correctPositionIfNotTrackPosition;
  19698. /**
  19699. * @hidden
  19700. * Updates the cached values of the camera
  19701. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19702. */
  19703. _updateCache(ignoreParentClass?: boolean): void;
  19704. /**
  19705. * @hidden
  19706. * Get current device position in babylon world
  19707. */
  19708. _computeDevicePosition(): void;
  19709. /**
  19710. * Updates the current device position and rotation in the babylon world
  19711. */
  19712. update(): void;
  19713. /**
  19714. * @hidden
  19715. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19716. * @returns an identity matrix
  19717. */
  19718. _getViewMatrix(): Matrix;
  19719. private _tmpMatrix;
  19720. /**
  19721. * This function is called by the two RIG cameras.
  19722. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19723. * @hidden
  19724. */
  19725. _getWebVRViewMatrix(): Matrix;
  19726. /** @hidden */
  19727. _getWebVRProjectionMatrix(): Matrix;
  19728. private _onGamepadConnectedObserver;
  19729. private _onGamepadDisconnectedObserver;
  19730. private _updateCacheWhenTrackingDisabledObserver;
  19731. /**
  19732. * Initializes the controllers and their meshes
  19733. */
  19734. initControllers(): void;
  19735. }
  19736. }
  19737. declare module BABYLON {
  19738. /**
  19739. * Size options for a post process
  19740. */
  19741. export type PostProcessOptions = {
  19742. width: number;
  19743. height: number;
  19744. };
  19745. /**
  19746. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19747. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19748. */
  19749. export class PostProcess {
  19750. /** Name of the PostProcess. */
  19751. name: string;
  19752. /**
  19753. * Gets or sets the unique id of the post process
  19754. */
  19755. uniqueId: number;
  19756. /**
  19757. * Width of the texture to apply the post process on
  19758. */
  19759. width: number;
  19760. /**
  19761. * Height of the texture to apply the post process on
  19762. */
  19763. height: number;
  19764. /**
  19765. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19766. * @hidden
  19767. */
  19768. _outputTexture: Nullable<InternalTexture>;
  19769. /**
  19770. * Sampling mode used by the shader
  19771. * See https://doc.babylonjs.com/classes/3.1/texture
  19772. */
  19773. renderTargetSamplingMode: number;
  19774. /**
  19775. * Clear color to use when screen clearing
  19776. */
  19777. clearColor: Color4;
  19778. /**
  19779. * If the buffer needs to be cleared before applying the post process. (default: true)
  19780. * Should be set to false if shader will overwrite all previous pixels.
  19781. */
  19782. autoClear: boolean;
  19783. /**
  19784. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19785. */
  19786. alphaMode: number;
  19787. /**
  19788. * Sets the setAlphaBlendConstants of the babylon engine
  19789. */
  19790. alphaConstants: Color4;
  19791. /**
  19792. * Animations to be used for the post processing
  19793. */
  19794. animations: Animation[];
  19795. /**
  19796. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19797. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19798. */
  19799. enablePixelPerfectMode: boolean;
  19800. /**
  19801. * Force the postprocess to be applied without taking in account viewport
  19802. */
  19803. forceFullscreenViewport: boolean;
  19804. /**
  19805. * List of inspectable custom properties (used by the Inspector)
  19806. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19807. */
  19808. inspectableCustomProperties: IInspectable[];
  19809. /**
  19810. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19811. *
  19812. * | Value | Type | Description |
  19813. * | ----- | ----------------------------------- | ----------- |
  19814. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19815. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19816. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19817. *
  19818. */
  19819. scaleMode: number;
  19820. /**
  19821. * Force textures to be a power of two (default: false)
  19822. */
  19823. alwaysForcePOT: boolean;
  19824. private _samples;
  19825. /**
  19826. * Number of sample textures (default: 1)
  19827. */
  19828. get samples(): number;
  19829. set samples(n: number);
  19830. /**
  19831. * Modify the scale of the post process to be the same as the viewport (default: false)
  19832. */
  19833. adaptScaleToCurrentViewport: boolean;
  19834. private _camera;
  19835. private _scene;
  19836. private _engine;
  19837. private _options;
  19838. private _reusable;
  19839. private _textureType;
  19840. private _textureFormat;
  19841. /**
  19842. * Smart array of input and output textures for the post process.
  19843. * @hidden
  19844. */
  19845. _textures: SmartArray<InternalTexture>;
  19846. /**
  19847. * The index in _textures that corresponds to the output texture.
  19848. * @hidden
  19849. */
  19850. _currentRenderTextureInd: number;
  19851. private _effect;
  19852. private _samplers;
  19853. private _fragmentUrl;
  19854. private _vertexUrl;
  19855. private _parameters;
  19856. private _scaleRatio;
  19857. protected _indexParameters: any;
  19858. private _shareOutputWithPostProcess;
  19859. private _texelSize;
  19860. private _forcedOutputTexture;
  19861. /**
  19862. * Returns the fragment url or shader name used in the post process.
  19863. * @returns the fragment url or name in the shader store.
  19864. */
  19865. getEffectName(): string;
  19866. /**
  19867. * An event triggered when the postprocess is activated.
  19868. */
  19869. onActivateObservable: Observable<Camera>;
  19870. private _onActivateObserver;
  19871. /**
  19872. * A function that is added to the onActivateObservable
  19873. */
  19874. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19875. /**
  19876. * An event triggered when the postprocess changes its size.
  19877. */
  19878. onSizeChangedObservable: Observable<PostProcess>;
  19879. private _onSizeChangedObserver;
  19880. /**
  19881. * A function that is added to the onSizeChangedObservable
  19882. */
  19883. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19884. /**
  19885. * An event triggered when the postprocess applies its effect.
  19886. */
  19887. onApplyObservable: Observable<Effect>;
  19888. private _onApplyObserver;
  19889. /**
  19890. * A function that is added to the onApplyObservable
  19891. */
  19892. set onApply(callback: (effect: Effect) => void);
  19893. /**
  19894. * An event triggered before rendering the postprocess
  19895. */
  19896. onBeforeRenderObservable: Observable<Effect>;
  19897. private _onBeforeRenderObserver;
  19898. /**
  19899. * A function that is added to the onBeforeRenderObservable
  19900. */
  19901. set onBeforeRender(callback: (effect: Effect) => void);
  19902. /**
  19903. * An event triggered after rendering the postprocess
  19904. */
  19905. onAfterRenderObservable: Observable<Effect>;
  19906. private _onAfterRenderObserver;
  19907. /**
  19908. * A function that is added to the onAfterRenderObservable
  19909. */
  19910. set onAfterRender(callback: (efect: Effect) => void);
  19911. /**
  19912. * 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
  19913. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19914. */
  19915. get inputTexture(): InternalTexture;
  19916. set inputTexture(value: InternalTexture);
  19917. /**
  19918. * Gets the camera which post process is applied to.
  19919. * @returns The camera the post process is applied to.
  19920. */
  19921. getCamera(): Camera;
  19922. /**
  19923. * Gets the texel size of the postprocess.
  19924. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19925. */
  19926. get texelSize(): Vector2;
  19927. /**
  19928. * Creates a new instance PostProcess
  19929. * @param name The name of the PostProcess.
  19930. * @param fragmentUrl The url of the fragment shader to be used.
  19931. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19932. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19933. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19934. * @param camera The camera to apply the render pass to.
  19935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19936. * @param engine The engine which the post process will be applied. (default: current engine)
  19937. * @param reusable If the post process can be reused on the same frame. (default: false)
  19938. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19939. * @param textureType Type of textures used when performing the post process. (default: 0)
  19940. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19941. * @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
  19942. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19943. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19944. */
  19945. constructor(
  19946. /** Name of the PostProcess. */
  19947. 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);
  19948. /**
  19949. * Gets a string idenfifying the name of the class
  19950. * @returns "PostProcess" string
  19951. */
  19952. getClassName(): string;
  19953. /**
  19954. * Gets the engine which this post process belongs to.
  19955. * @returns The engine the post process was enabled with.
  19956. */
  19957. getEngine(): Engine;
  19958. /**
  19959. * The effect that is created when initializing the post process.
  19960. * @returns The created effect corresponding the the postprocess.
  19961. */
  19962. getEffect(): Effect;
  19963. /**
  19964. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19965. * @param postProcess The post process to share the output with.
  19966. * @returns This post process.
  19967. */
  19968. shareOutputWith(postProcess: PostProcess): PostProcess;
  19969. /**
  19970. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19971. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19972. */
  19973. useOwnOutput(): void;
  19974. /**
  19975. * Updates the effect with the current post process compile time values and recompiles the shader.
  19976. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19977. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19978. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19979. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  19980. * @param onCompiled Called when the shader has been compiled.
  19981. * @param onError Called if there is an error when compiling a shader.
  19982. */
  19983. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19984. /**
  19985. * The post process is reusable if it can be used multiple times within one frame.
  19986. * @returns If the post process is reusable
  19987. */
  19988. isReusable(): boolean;
  19989. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19990. markTextureDirty(): void;
  19991. /**
  19992. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19993. * 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.
  19994. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19995. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19996. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19997. * @returns The target texture that was bound to be written to.
  19998. */
  19999. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20000. /**
  20001. * If the post process is supported.
  20002. */
  20003. get isSupported(): boolean;
  20004. /**
  20005. * The aspect ratio of the output texture.
  20006. */
  20007. get aspectRatio(): number;
  20008. /**
  20009. * Get a value indicating if the post-process is ready to be used
  20010. * @returns true if the post-process is ready (shader is compiled)
  20011. */
  20012. isReady(): boolean;
  20013. /**
  20014. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20015. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20016. */
  20017. apply(): Nullable<Effect>;
  20018. private _disposeTextures;
  20019. /**
  20020. * Disposes the post process.
  20021. * @param camera The camera to dispose the post process on.
  20022. */
  20023. dispose(camera?: Camera): void;
  20024. }
  20025. }
  20026. declare module BABYLON {
  20027. /** @hidden */
  20028. export var kernelBlurVaryingDeclaration: {
  20029. name: string;
  20030. shader: string;
  20031. };
  20032. }
  20033. declare module BABYLON {
  20034. /** @hidden */
  20035. export var kernelBlurFragment: {
  20036. name: string;
  20037. shader: string;
  20038. };
  20039. }
  20040. declare module BABYLON {
  20041. /** @hidden */
  20042. export var kernelBlurFragment2: {
  20043. name: string;
  20044. shader: string;
  20045. };
  20046. }
  20047. declare module BABYLON {
  20048. /** @hidden */
  20049. export var kernelBlurPixelShader: {
  20050. name: string;
  20051. shader: string;
  20052. };
  20053. }
  20054. declare module BABYLON {
  20055. /** @hidden */
  20056. export var kernelBlurVertex: {
  20057. name: string;
  20058. shader: string;
  20059. };
  20060. }
  20061. declare module BABYLON {
  20062. /** @hidden */
  20063. export var kernelBlurVertexShader: {
  20064. name: string;
  20065. shader: string;
  20066. };
  20067. }
  20068. declare module BABYLON {
  20069. /**
  20070. * The Blur Post Process which blurs an image based on a kernel and direction.
  20071. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20072. */
  20073. export class BlurPostProcess extends PostProcess {
  20074. /** The direction in which to blur the image. */
  20075. direction: Vector2;
  20076. private blockCompilation;
  20077. protected _kernel: number;
  20078. protected _idealKernel: number;
  20079. protected _packedFloat: boolean;
  20080. private _staticDefines;
  20081. /**
  20082. * Sets the length in pixels of the blur sample region
  20083. */
  20084. set kernel(v: number);
  20085. /**
  20086. * Gets the length in pixels of the blur sample region
  20087. */
  20088. get kernel(): number;
  20089. /**
  20090. * Sets wether or not the blur needs to unpack/repack floats
  20091. */
  20092. set packedFloat(v: boolean);
  20093. /**
  20094. * Gets wether or not the blur is unpacking/repacking floats
  20095. */
  20096. get packedFloat(): boolean;
  20097. /**
  20098. * Creates a new instance BlurPostProcess
  20099. * @param name The name of the effect.
  20100. * @param direction The direction in which to blur the image.
  20101. * @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.
  20102. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20103. * @param camera The camera to apply the render pass to.
  20104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20105. * @param engine The engine which the post process will be applied. (default: current engine)
  20106. * @param reusable If the post process can be reused on the same frame. (default: false)
  20107. * @param textureType Type of textures used when performing the post process. (default: 0)
  20108. * @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)
  20109. */
  20110. constructor(name: string,
  20111. /** The direction in which to blur the image. */
  20112. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20113. /**
  20114. * Updates the effect with the current post process compile time values and recompiles the shader.
  20115. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20116. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20117. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20118. * @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
  20119. * @param onCompiled Called when the shader has been compiled.
  20120. * @param onError Called if there is an error when compiling a shader.
  20121. */
  20122. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20123. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20124. /**
  20125. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20126. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20127. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20128. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20129. * The gaps between physical kernels are compensated for in the weighting of the samples
  20130. * @param idealKernel Ideal blur kernel.
  20131. * @return Nearest best kernel.
  20132. */
  20133. protected _nearestBestKernel(idealKernel: number): number;
  20134. /**
  20135. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20136. * @param x The point on the Gaussian distribution to sample.
  20137. * @return the value of the Gaussian function at x.
  20138. */
  20139. protected _gaussianWeight(x: number): number;
  20140. /**
  20141. * Generates a string that can be used as a floating point number in GLSL.
  20142. * @param x Value to print.
  20143. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20144. * @return GLSL float string.
  20145. */
  20146. protected _glslFloat(x: number, decimalFigures?: number): string;
  20147. }
  20148. }
  20149. declare module BABYLON {
  20150. /**
  20151. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20152. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20153. * You can then easily use it as a reflectionTexture on a flat surface.
  20154. * In case the surface is not a plane, please consider relying on reflection probes.
  20155. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20156. */
  20157. export class MirrorTexture extends RenderTargetTexture {
  20158. private scene;
  20159. /**
  20160. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20161. * 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.
  20162. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20163. */
  20164. mirrorPlane: Plane;
  20165. /**
  20166. * Define the blur ratio used to blur the reflection if needed.
  20167. */
  20168. set blurRatio(value: number);
  20169. get blurRatio(): number;
  20170. /**
  20171. * Define the adaptive blur kernel used to blur the reflection if needed.
  20172. * This will autocompute the closest best match for the `blurKernel`
  20173. */
  20174. set adaptiveBlurKernel(value: number);
  20175. /**
  20176. * Define the blur kernel used to blur the reflection if needed.
  20177. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20178. */
  20179. set blurKernel(value: number);
  20180. /**
  20181. * Define the blur kernel on the X Axis 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 blurKernelX(value: number);
  20185. get blurKernelX(): number;
  20186. /**
  20187. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20188. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20189. */
  20190. set blurKernelY(value: number);
  20191. get blurKernelY(): number;
  20192. private _autoComputeBlurKernel;
  20193. protected _onRatioRescale(): void;
  20194. private _updateGammaSpace;
  20195. private _imageProcessingConfigChangeObserver;
  20196. private _transformMatrix;
  20197. private _mirrorMatrix;
  20198. private _savedViewMatrix;
  20199. private _blurX;
  20200. private _blurY;
  20201. private _adaptiveBlurKernel;
  20202. private _blurKernelX;
  20203. private _blurKernelY;
  20204. private _blurRatio;
  20205. /**
  20206. * Instantiates a Mirror Texture.
  20207. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20208. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20209. * You can then easily use it as a reflectionTexture on a flat surface.
  20210. * In case the surface is not a plane, please consider relying on reflection probes.
  20211. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20212. * @param name
  20213. * @param size
  20214. * @param scene
  20215. * @param generateMipMaps
  20216. * @param type
  20217. * @param samplingMode
  20218. * @param generateDepthBuffer
  20219. */
  20220. constructor(name: string, size: number | {
  20221. width: number;
  20222. height: number;
  20223. } | {
  20224. ratio: number;
  20225. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20226. private _preparePostProcesses;
  20227. /**
  20228. * Clone the mirror texture.
  20229. * @returns the cloned texture
  20230. */
  20231. clone(): MirrorTexture;
  20232. /**
  20233. * Serialize the texture to a JSON representation you could use in Parse later on
  20234. * @returns the serialized JSON representation
  20235. */
  20236. serialize(): any;
  20237. /**
  20238. * Dispose the texture and release its associated resources.
  20239. */
  20240. dispose(): void;
  20241. }
  20242. }
  20243. declare module BABYLON {
  20244. /**
  20245. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20246. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20247. */
  20248. export class Texture extends BaseTexture {
  20249. /**
  20250. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20251. */
  20252. static SerializeBuffers: boolean;
  20253. /** @hidden */
  20254. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20255. /** @hidden */
  20256. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20257. /** @hidden */
  20258. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20259. /** nearest is mag = nearest and min = nearest and mip = linear */
  20260. static readonly NEAREST_SAMPLINGMODE: number;
  20261. /** nearest is mag = nearest and min = nearest and mip = linear */
  20262. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20263. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20264. static readonly BILINEAR_SAMPLINGMODE: number;
  20265. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20266. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20267. /** Trilinear is mag = linear and min = linear and mip = linear */
  20268. static readonly TRILINEAR_SAMPLINGMODE: number;
  20269. /** Trilinear is mag = linear and min = linear and mip = linear */
  20270. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20271. /** mag = nearest and min = nearest and mip = nearest */
  20272. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20273. /** mag = nearest and min = linear and mip = nearest */
  20274. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20275. /** mag = nearest and min = linear and mip = linear */
  20276. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20277. /** mag = nearest and min = linear and mip = none */
  20278. static readonly NEAREST_LINEAR: number;
  20279. /** mag = nearest and min = nearest and mip = none */
  20280. static readonly NEAREST_NEAREST: number;
  20281. /** mag = linear and min = nearest and mip = nearest */
  20282. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20283. /** mag = linear and min = nearest and mip = linear */
  20284. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20285. /** mag = linear and min = linear and mip = none */
  20286. static readonly LINEAR_LINEAR: number;
  20287. /** mag = linear and min = nearest and mip = none */
  20288. static readonly LINEAR_NEAREST: number;
  20289. /** Explicit coordinates mode */
  20290. static readonly EXPLICIT_MODE: number;
  20291. /** Spherical coordinates mode */
  20292. static readonly SPHERICAL_MODE: number;
  20293. /** Planar coordinates mode */
  20294. static readonly PLANAR_MODE: number;
  20295. /** Cubic coordinates mode */
  20296. static readonly CUBIC_MODE: number;
  20297. /** Projection coordinates mode */
  20298. static readonly PROJECTION_MODE: number;
  20299. /** Inverse Cubic coordinates mode */
  20300. static readonly SKYBOX_MODE: number;
  20301. /** Inverse Cubic coordinates mode */
  20302. static readonly INVCUBIC_MODE: number;
  20303. /** Equirectangular coordinates mode */
  20304. static readonly EQUIRECTANGULAR_MODE: number;
  20305. /** Equirectangular Fixed coordinates mode */
  20306. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20307. /** Equirectangular Fixed Mirrored coordinates mode */
  20308. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20309. /** Texture is not repeating outside of 0..1 UVs */
  20310. static readonly CLAMP_ADDRESSMODE: number;
  20311. /** Texture is repeating outside of 0..1 UVs */
  20312. static readonly WRAP_ADDRESSMODE: number;
  20313. /** Texture is repeating and mirrored */
  20314. static readonly MIRROR_ADDRESSMODE: number;
  20315. /**
  20316. * 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
  20317. */
  20318. static UseSerializedUrlIfAny: boolean;
  20319. /**
  20320. * Define the url of the texture.
  20321. */
  20322. url: Nullable<string>;
  20323. /**
  20324. * Define an offset on the texture to offset the u coordinates of the UVs
  20325. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20326. */
  20327. uOffset: number;
  20328. /**
  20329. * Define an offset on the texture to offset the v coordinates of the UVs
  20330. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20331. */
  20332. vOffset: number;
  20333. /**
  20334. * Define an offset on the texture to scale the u coordinates of the UVs
  20335. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20336. */
  20337. uScale: number;
  20338. /**
  20339. * Define an offset on the texture to scale the v coordinates of the UVs
  20340. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20341. */
  20342. vScale: number;
  20343. /**
  20344. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20345. * @see http://doc.babylonjs.com/how_to/more_materials
  20346. */
  20347. uAng: number;
  20348. /**
  20349. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20350. * @see http://doc.babylonjs.com/how_to/more_materials
  20351. */
  20352. vAng: number;
  20353. /**
  20354. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20355. * @see http://doc.babylonjs.com/how_to/more_materials
  20356. */
  20357. wAng: number;
  20358. /**
  20359. * Defines the center of rotation (U)
  20360. */
  20361. uRotationCenter: number;
  20362. /**
  20363. * Defines the center of rotation (V)
  20364. */
  20365. vRotationCenter: number;
  20366. /**
  20367. * Defines the center of rotation (W)
  20368. */
  20369. wRotationCenter: number;
  20370. /**
  20371. * Are mip maps generated for this texture or not.
  20372. */
  20373. get noMipmap(): boolean;
  20374. /**
  20375. * List of inspectable custom properties (used by the Inspector)
  20376. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20377. */
  20378. inspectableCustomProperties: Nullable<IInspectable[]>;
  20379. private _noMipmap;
  20380. /** @hidden */
  20381. _invertY: boolean;
  20382. private _rowGenerationMatrix;
  20383. private _cachedTextureMatrix;
  20384. private _projectionModeMatrix;
  20385. private _t0;
  20386. private _t1;
  20387. private _t2;
  20388. private _cachedUOffset;
  20389. private _cachedVOffset;
  20390. private _cachedUScale;
  20391. private _cachedVScale;
  20392. private _cachedUAng;
  20393. private _cachedVAng;
  20394. private _cachedWAng;
  20395. private _cachedProjectionMatrixId;
  20396. private _cachedCoordinatesMode;
  20397. /** @hidden */
  20398. protected _initialSamplingMode: number;
  20399. /** @hidden */
  20400. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20401. private _deleteBuffer;
  20402. protected _format: Nullable<number>;
  20403. private _delayedOnLoad;
  20404. private _delayedOnError;
  20405. private _mimeType?;
  20406. /**
  20407. * Observable triggered once the texture has been loaded.
  20408. */
  20409. onLoadObservable: Observable<Texture>;
  20410. protected _isBlocking: boolean;
  20411. /**
  20412. * Is the texture preventing material to render while loading.
  20413. * If false, a default texture will be used instead of the loading one during the preparation step.
  20414. */
  20415. set isBlocking(value: boolean);
  20416. get isBlocking(): boolean;
  20417. /**
  20418. * Get the current sampling mode associated with the texture.
  20419. */
  20420. get samplingMode(): number;
  20421. /**
  20422. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20423. */
  20424. get invertY(): boolean;
  20425. /**
  20426. * Instantiates a new texture.
  20427. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20428. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20429. * @param url defines the url of the picture to load as a texture
  20430. * @param scene defines the scene or engine the texture will belong to
  20431. * @param noMipmap defines if the texture will require mip maps or not
  20432. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20433. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20434. * @param onLoad defines a callback triggered when the texture has been loaded
  20435. * @param onError defines a callback triggered when an error occurred during the loading session
  20436. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20437. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20438. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20439. * @param mimeType defines an optional mime type information
  20440. */
  20441. 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);
  20442. /**
  20443. * Update the url (and optional buffer) of this texture if url was null during construction.
  20444. * @param url the url of the texture
  20445. * @param buffer the buffer of the texture (defaults to null)
  20446. * @param onLoad callback called when the texture is loaded (defaults to null)
  20447. */
  20448. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20449. /**
  20450. * Finish the loading sequence of a texture flagged as delayed load.
  20451. * @hidden
  20452. */
  20453. delayLoad(): void;
  20454. private _prepareRowForTextureGeneration;
  20455. /**
  20456. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20457. * @returns the transform matrix of the texture.
  20458. */
  20459. getTextureMatrix(uBase?: number): Matrix;
  20460. /**
  20461. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20462. * @returns The reflection texture transform
  20463. */
  20464. getReflectionTextureMatrix(): Matrix;
  20465. /**
  20466. * Clones the texture.
  20467. * @returns the cloned texture
  20468. */
  20469. clone(): Texture;
  20470. /**
  20471. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20472. * @returns The JSON representation of the texture
  20473. */
  20474. serialize(): any;
  20475. /**
  20476. * Get the current class name of the texture useful for serialization or dynamic coding.
  20477. * @returns "Texture"
  20478. */
  20479. getClassName(): string;
  20480. /**
  20481. * Dispose the texture and release its associated resources.
  20482. */
  20483. dispose(): void;
  20484. /**
  20485. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20486. * @param parsedTexture Define the JSON representation of the texture
  20487. * @param scene Define the scene the parsed texture should be instantiated in
  20488. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20489. * @returns The parsed texture if successful
  20490. */
  20491. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20492. /**
  20493. * Creates a texture from its base 64 representation.
  20494. * @param data Define the base64 payload without the data: prefix
  20495. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20496. * @param scene Define the scene the texture should belong to
  20497. * @param noMipmap Forces the texture to not create mip map information if true
  20498. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20499. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20500. * @param onLoad define a callback triggered when the texture has been loaded
  20501. * @param onError define a callback triggered when an error occurred during the loading session
  20502. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20503. * @returns the created texture
  20504. */
  20505. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20506. /**
  20507. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20508. * @param data Define the base64 payload without the data: prefix
  20509. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20510. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20511. * @param scene Define the scene the texture should belong to
  20512. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20513. * @param noMipmap Forces the texture to not create mip map information if true
  20514. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20515. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20516. * @param onLoad define a callback triggered when the texture has been loaded
  20517. * @param onError define a callback triggered when an error occurred during the loading session
  20518. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20519. * @returns the created texture
  20520. */
  20521. 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;
  20522. }
  20523. }
  20524. declare module BABYLON {
  20525. /**
  20526. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20527. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20528. */
  20529. export class PostProcessManager {
  20530. private _scene;
  20531. private _indexBuffer;
  20532. private _vertexBuffers;
  20533. /**
  20534. * Creates a new instance PostProcess
  20535. * @param scene The scene that the post process is associated with.
  20536. */
  20537. constructor(scene: Scene);
  20538. private _prepareBuffers;
  20539. private _buildIndexBuffer;
  20540. /**
  20541. * Rebuilds the vertex buffers of the manager.
  20542. * @hidden
  20543. */
  20544. _rebuild(): void;
  20545. /**
  20546. * Prepares a frame to be run through a post process.
  20547. * @param sourceTexture The input texture to the post procesess. (default: null)
  20548. * @param postProcesses An array of post processes to be run. (default: null)
  20549. * @returns True if the post processes were able to be run.
  20550. * @hidden
  20551. */
  20552. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20553. /**
  20554. * Manually render a set of post processes to a texture.
  20555. * @param postProcesses An array of post processes to be run.
  20556. * @param targetTexture The target texture to render to.
  20557. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20558. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20559. * @param lodLevel defines which lod of the texture to render to
  20560. */
  20561. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20562. /**
  20563. * Finalize the result of the output of the postprocesses.
  20564. * @param doNotPresent If true the result will not be displayed to the screen.
  20565. * @param targetTexture The target texture to render to.
  20566. * @param faceIndex The index of the face to bind the target texture to.
  20567. * @param postProcesses The array of post processes to render.
  20568. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20569. * @hidden
  20570. */
  20571. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20572. /**
  20573. * Disposes of the post process manager.
  20574. */
  20575. dispose(): void;
  20576. }
  20577. }
  20578. declare module BABYLON {
  20579. /**
  20580. * This Helps creating a texture that will be created from a camera in your scene.
  20581. * It is basically a dynamic texture that could be used to create special effects for instance.
  20582. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20583. */
  20584. export class RenderTargetTexture extends Texture {
  20585. isCube: boolean;
  20586. /**
  20587. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20588. */
  20589. static readonly REFRESHRATE_RENDER_ONCE: number;
  20590. /**
  20591. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20592. */
  20593. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20594. /**
  20595. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20596. * the central point of your effect and can save a lot of performances.
  20597. */
  20598. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20599. /**
  20600. * Use this predicate to dynamically define the list of mesh you want to render.
  20601. * If set, the renderList property will be overwritten.
  20602. */
  20603. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20604. private _renderList;
  20605. /**
  20606. * Use this list to define the list of mesh you want to render.
  20607. */
  20608. get renderList(): Nullable<Array<AbstractMesh>>;
  20609. set renderList(value: Nullable<Array<AbstractMesh>>);
  20610. /**
  20611. * Use this function to overload the renderList array at rendering time.
  20612. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20613. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20614. * the cube (if the RTT is a cube, else layerOrFace=0).
  20615. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20616. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20617. * hold dummy elements!
  20618. */
  20619. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20620. private _hookArray;
  20621. /**
  20622. * Define if particles should be rendered in your texture.
  20623. */
  20624. renderParticles: boolean;
  20625. /**
  20626. * Define if sprites should be rendered in your texture.
  20627. */
  20628. renderSprites: boolean;
  20629. /**
  20630. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20631. */
  20632. coordinatesMode: number;
  20633. /**
  20634. * Define the camera used to render the texture.
  20635. */
  20636. activeCamera: Nullable<Camera>;
  20637. /**
  20638. * Override the mesh isReady function with your own one.
  20639. */
  20640. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20641. /**
  20642. * Override the render function of the texture with your own one.
  20643. */
  20644. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20645. /**
  20646. * Define if camera post processes should be use while rendering the texture.
  20647. */
  20648. useCameraPostProcesses: boolean;
  20649. /**
  20650. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20651. */
  20652. ignoreCameraViewport: boolean;
  20653. private _postProcessManager;
  20654. private _postProcesses;
  20655. private _resizeObserver;
  20656. /**
  20657. * An event triggered when the texture is unbind.
  20658. */
  20659. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20660. /**
  20661. * An event triggered when the texture is unbind.
  20662. */
  20663. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20664. private _onAfterUnbindObserver;
  20665. /**
  20666. * Set a after unbind callback in the texture.
  20667. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20668. */
  20669. set onAfterUnbind(callback: () => void);
  20670. /**
  20671. * An event triggered before rendering the texture
  20672. */
  20673. onBeforeRenderObservable: Observable<number>;
  20674. private _onBeforeRenderObserver;
  20675. /**
  20676. * Set a before render callback in the texture.
  20677. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20678. */
  20679. set onBeforeRender(callback: (faceIndex: number) => void);
  20680. /**
  20681. * An event triggered after rendering the texture
  20682. */
  20683. onAfterRenderObservable: Observable<number>;
  20684. private _onAfterRenderObserver;
  20685. /**
  20686. * Set a after render callback in the texture.
  20687. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20688. */
  20689. set onAfterRender(callback: (faceIndex: number) => void);
  20690. /**
  20691. * An event triggered after the texture clear
  20692. */
  20693. onClearObservable: Observable<Engine>;
  20694. private _onClearObserver;
  20695. /**
  20696. * Set a clear callback in the texture.
  20697. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20698. */
  20699. set onClear(callback: (Engine: Engine) => void);
  20700. /**
  20701. * An event triggered when the texture is resized.
  20702. */
  20703. onResizeObservable: Observable<RenderTargetTexture>;
  20704. /**
  20705. * Define the clear color of the Render Target if it should be different from the scene.
  20706. */
  20707. clearColor: Color4;
  20708. protected _size: number | {
  20709. width: number;
  20710. height: number;
  20711. layers?: number;
  20712. };
  20713. protected _initialSizeParameter: number | {
  20714. width: number;
  20715. height: number;
  20716. } | {
  20717. ratio: number;
  20718. };
  20719. protected _sizeRatio: Nullable<number>;
  20720. /** @hidden */
  20721. _generateMipMaps: boolean;
  20722. protected _renderingManager: RenderingManager;
  20723. /** @hidden */
  20724. _waitingRenderList: string[];
  20725. protected _doNotChangeAspectRatio: boolean;
  20726. protected _currentRefreshId: number;
  20727. protected _refreshRate: number;
  20728. protected _textureMatrix: Matrix;
  20729. protected _samples: number;
  20730. protected _renderTargetOptions: RenderTargetCreationOptions;
  20731. /**
  20732. * Gets render target creation options that were used.
  20733. */
  20734. get renderTargetOptions(): RenderTargetCreationOptions;
  20735. protected _engine: Engine;
  20736. protected _onRatioRescale(): void;
  20737. /**
  20738. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20739. * It must define where the camera used to render the texture is set
  20740. */
  20741. boundingBoxPosition: Vector3;
  20742. private _boundingBoxSize;
  20743. /**
  20744. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20745. * When defined, the cubemap will switch to local mode
  20746. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20747. * @example https://www.babylonjs-playground.com/#RNASML
  20748. */
  20749. set boundingBoxSize(value: Vector3);
  20750. get boundingBoxSize(): Vector3;
  20751. /**
  20752. * In case the RTT has been created with a depth texture, get the associated
  20753. * depth texture.
  20754. * Otherwise, return null.
  20755. */
  20756. get depthStencilTexture(): Nullable<InternalTexture>;
  20757. /**
  20758. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20759. * or used a shadow, depth texture...
  20760. * @param name The friendly name of the texture
  20761. * @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)
  20762. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20763. * @param generateMipMaps True if mip maps need to be generated after render.
  20764. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20765. * @param type The type of the buffer in the RTT (int, half float, float...)
  20766. * @param isCube True if a cube texture needs to be created
  20767. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20768. * @param generateDepthBuffer True to generate a depth buffer
  20769. * @param generateStencilBuffer True to generate a stencil buffer
  20770. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20771. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20772. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20773. */
  20774. constructor(name: string, size: number | {
  20775. width: number;
  20776. height: number;
  20777. layers?: number;
  20778. } | {
  20779. ratio: number;
  20780. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20781. /**
  20782. * Creates a depth stencil texture.
  20783. * This is only available in WebGL 2 or with the depth texture extension available.
  20784. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20785. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20786. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20787. */
  20788. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20789. private _processSizeParameter;
  20790. /**
  20791. * Define the number of samples to use in case of MSAA.
  20792. * It defaults to one meaning no MSAA has been enabled.
  20793. */
  20794. get samples(): number;
  20795. set samples(value: number);
  20796. /**
  20797. * Resets the refresh counter of the texture and start bak from scratch.
  20798. * Could be useful to regenerate the texture if it is setup to render only once.
  20799. */
  20800. resetRefreshCounter(): void;
  20801. /**
  20802. * Define the refresh rate of the texture or the rendering frequency.
  20803. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20804. */
  20805. get refreshRate(): number;
  20806. set refreshRate(value: number);
  20807. /**
  20808. * Adds a post process to the render target rendering passes.
  20809. * @param postProcess define the post process to add
  20810. */
  20811. addPostProcess(postProcess: PostProcess): void;
  20812. /**
  20813. * Clear all the post processes attached to the render target
  20814. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20815. */
  20816. clearPostProcesses(dispose?: boolean): void;
  20817. /**
  20818. * Remove one of the post process from the list of attached post processes to the texture
  20819. * @param postProcess define the post process to remove from the list
  20820. */
  20821. removePostProcess(postProcess: PostProcess): void;
  20822. /** @hidden */
  20823. _shouldRender(): boolean;
  20824. /**
  20825. * Gets the actual render size of the texture.
  20826. * @returns the width of the render size
  20827. */
  20828. getRenderSize(): number;
  20829. /**
  20830. * Gets the actual render width of the texture.
  20831. * @returns the width of the render size
  20832. */
  20833. getRenderWidth(): number;
  20834. /**
  20835. * Gets the actual render height of the texture.
  20836. * @returns the height of the render size
  20837. */
  20838. getRenderHeight(): number;
  20839. /**
  20840. * Gets the actual number of layers of the texture.
  20841. * @returns the number of layers
  20842. */
  20843. getRenderLayers(): number;
  20844. /**
  20845. * Get if the texture can be rescaled or not.
  20846. */
  20847. get canRescale(): boolean;
  20848. /**
  20849. * Resize the texture using a ratio.
  20850. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20851. */
  20852. scale(ratio: number): void;
  20853. /**
  20854. * Get the texture reflection matrix used to rotate/transform the reflection.
  20855. * @returns the reflection matrix
  20856. */
  20857. getReflectionTextureMatrix(): Matrix;
  20858. /**
  20859. * Resize the texture to a new desired size.
  20860. * Be carrefull as it will recreate all the data in the new texture.
  20861. * @param size Define the new size. It can be:
  20862. * - a number for squared texture,
  20863. * - an object containing { width: number, height: number }
  20864. * - or an object containing a ratio { ratio: number }
  20865. */
  20866. resize(size: number | {
  20867. width: number;
  20868. height: number;
  20869. } | {
  20870. ratio: number;
  20871. }): void;
  20872. private _defaultRenderListPrepared;
  20873. /**
  20874. * Renders all the objects from the render list into the texture.
  20875. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20876. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20877. */
  20878. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20879. private _bestReflectionRenderTargetDimension;
  20880. private _prepareRenderingManager;
  20881. /**
  20882. * @hidden
  20883. * @param faceIndex face index to bind to if this is a cubetexture
  20884. * @param layer defines the index of the texture to bind in the array
  20885. */
  20886. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20887. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20888. private renderToTarget;
  20889. /**
  20890. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20891. * This allowed control for front to back rendering or reversly depending of the special needs.
  20892. *
  20893. * @param renderingGroupId The rendering group id corresponding to its index
  20894. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20895. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20896. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20897. */
  20898. 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;
  20899. /**
  20900. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20901. *
  20902. * @param renderingGroupId The rendering group id corresponding to its index
  20903. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20904. */
  20905. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20906. /**
  20907. * Clones the texture.
  20908. * @returns the cloned texture
  20909. */
  20910. clone(): RenderTargetTexture;
  20911. /**
  20912. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20913. * @returns The JSON representation of the texture
  20914. */
  20915. serialize(): any;
  20916. /**
  20917. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20918. */
  20919. disposeFramebufferObjects(): void;
  20920. /**
  20921. * Dispose the texture and release its associated resources.
  20922. */
  20923. dispose(): void;
  20924. /** @hidden */
  20925. _rebuild(): void;
  20926. /**
  20927. * Clear the info related to rendering groups preventing retention point in material dispose.
  20928. */
  20929. freeRenderingGroups(): void;
  20930. /**
  20931. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20932. * @returns the view count
  20933. */
  20934. getViewCount(): number;
  20935. }
  20936. }
  20937. declare module BABYLON {
  20938. /**
  20939. * Options for compiling materials.
  20940. */
  20941. export interface IMaterialCompilationOptions {
  20942. /**
  20943. * Defines whether clip planes are enabled.
  20944. */
  20945. clipPlane: boolean;
  20946. /**
  20947. * Defines whether instances are enabled.
  20948. */
  20949. useInstances: boolean;
  20950. }
  20951. /**
  20952. * Base class for the main features of a material in Babylon.js
  20953. */
  20954. export class Material implements IAnimatable {
  20955. /**
  20956. * Returns the triangle fill mode
  20957. */
  20958. static readonly TriangleFillMode: number;
  20959. /**
  20960. * Returns the wireframe mode
  20961. */
  20962. static readonly WireFrameFillMode: number;
  20963. /**
  20964. * Returns the point fill mode
  20965. */
  20966. static readonly PointFillMode: number;
  20967. /**
  20968. * Returns the point list draw mode
  20969. */
  20970. static readonly PointListDrawMode: number;
  20971. /**
  20972. * Returns the line list draw mode
  20973. */
  20974. static readonly LineListDrawMode: number;
  20975. /**
  20976. * Returns the line loop draw mode
  20977. */
  20978. static readonly LineLoopDrawMode: number;
  20979. /**
  20980. * Returns the line strip draw mode
  20981. */
  20982. static readonly LineStripDrawMode: number;
  20983. /**
  20984. * Returns the triangle strip draw mode
  20985. */
  20986. static readonly TriangleStripDrawMode: number;
  20987. /**
  20988. * Returns the triangle fan draw mode
  20989. */
  20990. static readonly TriangleFanDrawMode: number;
  20991. /**
  20992. * Stores the clock-wise side orientation
  20993. */
  20994. static readonly ClockWiseSideOrientation: number;
  20995. /**
  20996. * Stores the counter clock-wise side orientation
  20997. */
  20998. static readonly CounterClockWiseSideOrientation: number;
  20999. /**
  21000. * The dirty texture flag value
  21001. */
  21002. static readonly TextureDirtyFlag: number;
  21003. /**
  21004. * The dirty light flag value
  21005. */
  21006. static readonly LightDirtyFlag: number;
  21007. /**
  21008. * The dirty fresnel flag value
  21009. */
  21010. static readonly FresnelDirtyFlag: number;
  21011. /**
  21012. * The dirty attribute flag value
  21013. */
  21014. static readonly AttributesDirtyFlag: number;
  21015. /**
  21016. * The dirty misc flag value
  21017. */
  21018. static readonly MiscDirtyFlag: number;
  21019. /**
  21020. * The all dirty flag value
  21021. */
  21022. static readonly AllDirtyFlag: number;
  21023. /**
  21024. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21025. */
  21026. static readonly MATERIAL_OPAQUE: number;
  21027. /**
  21028. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21029. */
  21030. static readonly MATERIAL_ALPHATEST: number;
  21031. /**
  21032. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21033. */
  21034. static readonly MATERIAL_ALPHABLEND: number;
  21035. /**
  21036. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21037. * They are also discarded below the alpha cutoff threshold to improve performances.
  21038. */
  21039. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21040. /**
  21041. * The ID of the material
  21042. */
  21043. id: string;
  21044. /**
  21045. * Gets or sets the unique id of the material
  21046. */
  21047. uniqueId: number;
  21048. /**
  21049. * The name of the material
  21050. */
  21051. name: string;
  21052. /**
  21053. * Gets or sets user defined metadata
  21054. */
  21055. metadata: any;
  21056. /**
  21057. * For internal use only. Please do not use.
  21058. */
  21059. reservedDataStore: any;
  21060. /**
  21061. * Specifies if the ready state should be checked on each call
  21062. */
  21063. checkReadyOnEveryCall: boolean;
  21064. /**
  21065. * Specifies if the ready state should be checked once
  21066. */
  21067. checkReadyOnlyOnce: boolean;
  21068. /**
  21069. * The state of the material
  21070. */
  21071. state: string;
  21072. /**
  21073. * The alpha value of the material
  21074. */
  21075. protected _alpha: number;
  21076. /**
  21077. * List of inspectable custom properties (used by the Inspector)
  21078. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21079. */
  21080. inspectableCustomProperties: IInspectable[];
  21081. /**
  21082. * Sets the alpha value of the material
  21083. */
  21084. set alpha(value: number);
  21085. /**
  21086. * Gets the alpha value of the material
  21087. */
  21088. get alpha(): number;
  21089. /**
  21090. * Specifies if back face culling is enabled
  21091. */
  21092. protected _backFaceCulling: boolean;
  21093. /**
  21094. * Sets the back-face culling state
  21095. */
  21096. set backFaceCulling(value: boolean);
  21097. /**
  21098. * Gets the back-face culling state
  21099. */
  21100. get backFaceCulling(): boolean;
  21101. /**
  21102. * Stores the value for side orientation
  21103. */
  21104. sideOrientation: number;
  21105. /**
  21106. * Callback triggered when the material is compiled
  21107. */
  21108. onCompiled: Nullable<(effect: Effect) => void>;
  21109. /**
  21110. * Callback triggered when an error occurs
  21111. */
  21112. onError: Nullable<(effect: Effect, errors: string) => void>;
  21113. /**
  21114. * Callback triggered to get the render target textures
  21115. */
  21116. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21117. /**
  21118. * Gets a boolean indicating that current material needs to register RTT
  21119. */
  21120. get hasRenderTargetTextures(): boolean;
  21121. /**
  21122. * Specifies if the material should be serialized
  21123. */
  21124. doNotSerialize: boolean;
  21125. /**
  21126. * @hidden
  21127. */
  21128. _storeEffectOnSubMeshes: boolean;
  21129. /**
  21130. * Stores the animations for the material
  21131. */
  21132. animations: Nullable<Array<Animation>>;
  21133. /**
  21134. * An event triggered when the material is disposed
  21135. */
  21136. onDisposeObservable: Observable<Material>;
  21137. /**
  21138. * An observer which watches for dispose events
  21139. */
  21140. private _onDisposeObserver;
  21141. private _onUnBindObservable;
  21142. /**
  21143. * Called during a dispose event
  21144. */
  21145. set onDispose(callback: () => void);
  21146. private _onBindObservable;
  21147. /**
  21148. * An event triggered when the material is bound
  21149. */
  21150. get onBindObservable(): Observable<AbstractMesh>;
  21151. /**
  21152. * An observer which watches for bind events
  21153. */
  21154. private _onBindObserver;
  21155. /**
  21156. * Called during a bind event
  21157. */
  21158. set onBind(callback: (Mesh: AbstractMesh) => void);
  21159. /**
  21160. * An event triggered when the material is unbound
  21161. */
  21162. get onUnBindObservable(): Observable<Material>;
  21163. /**
  21164. * Stores the value of the alpha mode
  21165. */
  21166. private _alphaMode;
  21167. /**
  21168. * Sets the value of the alpha mode.
  21169. *
  21170. * | Value | Type | Description |
  21171. * | --- | --- | --- |
  21172. * | 0 | ALPHA_DISABLE | |
  21173. * | 1 | ALPHA_ADD | |
  21174. * | 2 | ALPHA_COMBINE | |
  21175. * | 3 | ALPHA_SUBTRACT | |
  21176. * | 4 | ALPHA_MULTIPLY | |
  21177. * | 5 | ALPHA_MAXIMIZED | |
  21178. * | 6 | ALPHA_ONEONE | |
  21179. * | 7 | ALPHA_PREMULTIPLIED | |
  21180. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21181. * | 9 | ALPHA_INTERPOLATE | |
  21182. * | 10 | ALPHA_SCREENMODE | |
  21183. *
  21184. */
  21185. set alphaMode(value: number);
  21186. /**
  21187. * Gets the value of the alpha mode
  21188. */
  21189. get alphaMode(): number;
  21190. /**
  21191. * Stores the state of the need depth pre-pass value
  21192. */
  21193. private _needDepthPrePass;
  21194. /**
  21195. * Sets the need depth pre-pass value
  21196. */
  21197. set needDepthPrePass(value: boolean);
  21198. /**
  21199. * Gets the depth pre-pass value
  21200. */
  21201. get needDepthPrePass(): boolean;
  21202. /**
  21203. * Specifies if depth writing should be disabled
  21204. */
  21205. disableDepthWrite: boolean;
  21206. /**
  21207. * Specifies if depth writing should be forced
  21208. */
  21209. forceDepthWrite: boolean;
  21210. /**
  21211. * Specifies the depth function that should be used. 0 means the default engine function
  21212. */
  21213. depthFunction: number;
  21214. /**
  21215. * Specifies if there should be a separate pass for culling
  21216. */
  21217. separateCullingPass: boolean;
  21218. /**
  21219. * Stores the state specifing if fog should be enabled
  21220. */
  21221. private _fogEnabled;
  21222. /**
  21223. * Sets the state for enabling fog
  21224. */
  21225. set fogEnabled(value: boolean);
  21226. /**
  21227. * Gets the value of the fog enabled state
  21228. */
  21229. get fogEnabled(): boolean;
  21230. /**
  21231. * Stores the size of points
  21232. */
  21233. pointSize: number;
  21234. /**
  21235. * Stores the z offset value
  21236. */
  21237. zOffset: number;
  21238. /**
  21239. * Gets a value specifying if wireframe mode is enabled
  21240. */
  21241. get wireframe(): boolean;
  21242. /**
  21243. * Sets the state of wireframe mode
  21244. */
  21245. set wireframe(value: boolean);
  21246. /**
  21247. * Gets the value specifying if point clouds are enabled
  21248. */
  21249. get pointsCloud(): boolean;
  21250. /**
  21251. * Sets the state of point cloud mode
  21252. */
  21253. set pointsCloud(value: boolean);
  21254. /**
  21255. * Gets the material fill mode
  21256. */
  21257. get fillMode(): number;
  21258. /**
  21259. * Sets the material fill mode
  21260. */
  21261. set fillMode(value: number);
  21262. /**
  21263. * @hidden
  21264. * Stores the effects for the material
  21265. */
  21266. _effect: Nullable<Effect>;
  21267. /**
  21268. * Specifies if uniform buffers should be used
  21269. */
  21270. private _useUBO;
  21271. /**
  21272. * Stores a reference to the scene
  21273. */
  21274. private _scene;
  21275. /**
  21276. * Stores the fill mode state
  21277. */
  21278. private _fillMode;
  21279. /**
  21280. * Specifies if the depth write state should be cached
  21281. */
  21282. private _cachedDepthWriteState;
  21283. /**
  21284. * Specifies if the depth function state should be cached
  21285. */
  21286. private _cachedDepthFunctionState;
  21287. /**
  21288. * Stores the uniform buffer
  21289. */
  21290. protected _uniformBuffer: UniformBuffer;
  21291. /** @hidden */
  21292. _indexInSceneMaterialArray: number;
  21293. /** @hidden */
  21294. meshMap: Nullable<{
  21295. [id: string]: AbstractMesh | undefined;
  21296. }>;
  21297. /**
  21298. * Creates a material instance
  21299. * @param name defines the name of the material
  21300. * @param scene defines the scene to reference
  21301. * @param doNotAdd specifies if the material should be added to the scene
  21302. */
  21303. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21304. /**
  21305. * Returns a string representation of the current material
  21306. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21307. * @returns a string with material information
  21308. */
  21309. toString(fullDetails?: boolean): string;
  21310. /**
  21311. * Gets the class name of the material
  21312. * @returns a string with the class name of the material
  21313. */
  21314. getClassName(): string;
  21315. /**
  21316. * Specifies if updates for the material been locked
  21317. */
  21318. get isFrozen(): boolean;
  21319. /**
  21320. * Locks updates for the material
  21321. */
  21322. freeze(): void;
  21323. /**
  21324. * Unlocks updates for the material
  21325. */
  21326. unfreeze(): void;
  21327. /**
  21328. * Specifies if the material is ready to be used
  21329. * @param mesh defines the mesh to check
  21330. * @param useInstances specifies if instances should be used
  21331. * @returns a boolean indicating if the material is ready to be used
  21332. */
  21333. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21334. /**
  21335. * Specifies that the submesh is ready to be used
  21336. * @param mesh defines the mesh to check
  21337. * @param subMesh defines which submesh to check
  21338. * @param useInstances specifies that instances should be used
  21339. * @returns a boolean indicating that the submesh is ready or not
  21340. */
  21341. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21342. /**
  21343. * Returns the material effect
  21344. * @returns the effect associated with the material
  21345. */
  21346. getEffect(): Nullable<Effect>;
  21347. /**
  21348. * Returns the current scene
  21349. * @returns a Scene
  21350. */
  21351. getScene(): Scene;
  21352. /**
  21353. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21354. */
  21355. protected _forceAlphaTest: boolean;
  21356. /**
  21357. * The transparency mode of the material.
  21358. */
  21359. protected _transparencyMode: Nullable<number>;
  21360. /**
  21361. * Gets the current transparency mode.
  21362. */
  21363. get transparencyMode(): Nullable<number>;
  21364. /**
  21365. * Sets the transparency mode of the material.
  21366. *
  21367. * | Value | Type | Description |
  21368. * | ----- | ----------------------------------- | ----------- |
  21369. * | 0 | OPAQUE | |
  21370. * | 1 | ALPHATEST | |
  21371. * | 2 | ALPHABLEND | |
  21372. * | 3 | ALPHATESTANDBLEND | |
  21373. *
  21374. */
  21375. set transparencyMode(value: Nullable<number>);
  21376. /**
  21377. * Returns true if alpha blending should be disabled.
  21378. */
  21379. protected get _disableAlphaBlending(): boolean;
  21380. /**
  21381. * Specifies whether or not this material should be rendered in alpha blend mode.
  21382. * @returns a boolean specifying if alpha blending is needed
  21383. */
  21384. needAlphaBlending(): boolean;
  21385. /**
  21386. * Specifies if the mesh will require alpha blending
  21387. * @param mesh defines the mesh to check
  21388. * @returns a boolean specifying if alpha blending is needed for the mesh
  21389. */
  21390. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21391. /**
  21392. * Specifies whether or not this material should be rendered in alpha test mode.
  21393. * @returns a boolean specifying if an alpha test is needed.
  21394. */
  21395. needAlphaTesting(): boolean;
  21396. /**
  21397. * Specifies if material alpha testing should be turned on for the mesh
  21398. * @param mesh defines the mesh to check
  21399. */
  21400. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21401. /**
  21402. * Gets the texture used for the alpha test
  21403. * @returns the texture to use for alpha testing
  21404. */
  21405. getAlphaTestTexture(): Nullable<BaseTexture>;
  21406. /**
  21407. * Marks the material to indicate that it needs to be re-calculated
  21408. */
  21409. markDirty(): void;
  21410. /** @hidden */
  21411. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21412. /**
  21413. * Binds the material to the mesh
  21414. * @param world defines the world transformation matrix
  21415. * @param mesh defines the mesh to bind the material to
  21416. */
  21417. bind(world: Matrix, mesh?: Mesh): void;
  21418. /**
  21419. * Binds the submesh to the material
  21420. * @param world defines the world transformation matrix
  21421. * @param mesh defines the mesh containing the submesh
  21422. * @param subMesh defines the submesh to bind the material to
  21423. */
  21424. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21425. /**
  21426. * Binds the world matrix to the material
  21427. * @param world defines the world transformation matrix
  21428. */
  21429. bindOnlyWorldMatrix(world: Matrix): void;
  21430. /**
  21431. * Binds the scene's uniform buffer to the effect.
  21432. * @param effect defines the effect to bind to the scene uniform buffer
  21433. * @param sceneUbo defines the uniform buffer storing scene data
  21434. */
  21435. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21436. /**
  21437. * Binds the view matrix to the effect
  21438. * @param effect defines the effect to bind the view matrix to
  21439. */
  21440. bindView(effect: Effect): void;
  21441. /**
  21442. * Binds the view projection matrix to the effect
  21443. * @param effect defines the effect to bind the view projection matrix to
  21444. */
  21445. bindViewProjection(effect: Effect): void;
  21446. /**
  21447. * Processes to execute after binding the material to a mesh
  21448. * @param mesh defines the rendered mesh
  21449. */
  21450. protected _afterBind(mesh?: Mesh): void;
  21451. /**
  21452. * Unbinds the material from the mesh
  21453. */
  21454. unbind(): void;
  21455. /**
  21456. * Gets the active textures from the material
  21457. * @returns an array of textures
  21458. */
  21459. getActiveTextures(): BaseTexture[];
  21460. /**
  21461. * Specifies if the material uses a texture
  21462. * @param texture defines the texture to check against the material
  21463. * @returns a boolean specifying if the material uses the texture
  21464. */
  21465. hasTexture(texture: BaseTexture): boolean;
  21466. /**
  21467. * Makes a duplicate of the material, and gives it a new name
  21468. * @param name defines the new name for the duplicated material
  21469. * @returns the cloned material
  21470. */
  21471. clone(name: string): Nullable<Material>;
  21472. /**
  21473. * Gets the meshes bound to the material
  21474. * @returns an array of meshes bound to the material
  21475. */
  21476. getBindedMeshes(): AbstractMesh[];
  21477. /**
  21478. * Force shader compilation
  21479. * @param mesh defines the mesh associated with this material
  21480. * @param onCompiled defines a function to execute once the material is compiled
  21481. * @param options defines the options to configure the compilation
  21482. * @param onError defines a function to execute if the material fails compiling
  21483. */
  21484. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21485. /**
  21486. * Force shader compilation
  21487. * @param mesh defines the mesh that will use this material
  21488. * @param options defines additional options for compiling the shaders
  21489. * @returns a promise that resolves when the compilation completes
  21490. */
  21491. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21492. private static readonly _AllDirtyCallBack;
  21493. private static readonly _ImageProcessingDirtyCallBack;
  21494. private static readonly _TextureDirtyCallBack;
  21495. private static readonly _FresnelDirtyCallBack;
  21496. private static readonly _MiscDirtyCallBack;
  21497. private static readonly _LightsDirtyCallBack;
  21498. private static readonly _AttributeDirtyCallBack;
  21499. private static _FresnelAndMiscDirtyCallBack;
  21500. private static _TextureAndMiscDirtyCallBack;
  21501. private static readonly _DirtyCallbackArray;
  21502. private static readonly _RunDirtyCallBacks;
  21503. /**
  21504. * Marks a define in the material to indicate that it needs to be re-computed
  21505. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21506. */
  21507. markAsDirty(flag: number): void;
  21508. /**
  21509. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21510. * @param func defines a function which checks material defines against the submeshes
  21511. */
  21512. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21513. /**
  21514. * Indicates that we need to re-calculated for all submeshes
  21515. */
  21516. protected _markAllSubMeshesAsAllDirty(): void;
  21517. /**
  21518. * Indicates that image processing needs to be re-calculated for all submeshes
  21519. */
  21520. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21521. /**
  21522. * Indicates that textures need to be re-calculated for all submeshes
  21523. */
  21524. protected _markAllSubMeshesAsTexturesDirty(): void;
  21525. /**
  21526. * Indicates that fresnel needs to be re-calculated for all submeshes
  21527. */
  21528. protected _markAllSubMeshesAsFresnelDirty(): void;
  21529. /**
  21530. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21531. */
  21532. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21533. /**
  21534. * Indicates that lights need to be re-calculated for all submeshes
  21535. */
  21536. protected _markAllSubMeshesAsLightsDirty(): void;
  21537. /**
  21538. * Indicates that attributes need to be re-calculated for all submeshes
  21539. */
  21540. protected _markAllSubMeshesAsAttributesDirty(): void;
  21541. /**
  21542. * Indicates that misc needs to be re-calculated for all submeshes
  21543. */
  21544. protected _markAllSubMeshesAsMiscDirty(): void;
  21545. /**
  21546. * Indicates that textures and misc need to be re-calculated for all submeshes
  21547. */
  21548. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21549. /**
  21550. * Disposes the material
  21551. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21552. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21553. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21554. */
  21555. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21556. /** @hidden */
  21557. private releaseVertexArrayObject;
  21558. /**
  21559. * Serializes this material
  21560. * @returns the serialized material object
  21561. */
  21562. serialize(): any;
  21563. /**
  21564. * Creates a material from parsed material data
  21565. * @param parsedMaterial defines parsed material data
  21566. * @param scene defines the hosting scene
  21567. * @param rootUrl defines the root URL to use to load textures
  21568. * @returns a new material
  21569. */
  21570. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21571. }
  21572. }
  21573. declare module BABYLON {
  21574. /**
  21575. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21576. * separate meshes. This can be use to improve performances.
  21577. * @see http://doc.babylonjs.com/how_to/multi_materials
  21578. */
  21579. export class MultiMaterial extends Material {
  21580. private _subMaterials;
  21581. /**
  21582. * Gets or Sets the list of Materials used within the multi material.
  21583. * They need to be ordered according to the submeshes order in the associated mesh
  21584. */
  21585. get subMaterials(): Nullable<Material>[];
  21586. set subMaterials(value: Nullable<Material>[]);
  21587. /**
  21588. * Function used to align with Node.getChildren()
  21589. * @returns the list of Materials used within the multi material
  21590. */
  21591. getChildren(): Nullable<Material>[];
  21592. /**
  21593. * Instantiates a new Multi Material
  21594. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21595. * separate meshes. This can be use to improve performances.
  21596. * @see http://doc.babylonjs.com/how_to/multi_materials
  21597. * @param name Define the name in the scene
  21598. * @param scene Define the scene the material belongs to
  21599. */
  21600. constructor(name: string, scene: Scene);
  21601. private _hookArray;
  21602. /**
  21603. * Get one of the submaterial by its index in the submaterials array
  21604. * @param index The index to look the sub material at
  21605. * @returns The Material if the index has been defined
  21606. */
  21607. getSubMaterial(index: number): Nullable<Material>;
  21608. /**
  21609. * Get the list of active textures for the whole sub materials list.
  21610. * @returns All the textures that will be used during the rendering
  21611. */
  21612. getActiveTextures(): BaseTexture[];
  21613. /**
  21614. * Gets the current class name of the material e.g. "MultiMaterial"
  21615. * Mainly use in serialization.
  21616. * @returns the class name
  21617. */
  21618. getClassName(): string;
  21619. /**
  21620. * Checks if the material is ready to render the requested sub mesh
  21621. * @param mesh Define the mesh the submesh belongs to
  21622. * @param subMesh Define the sub mesh to look readyness for
  21623. * @param useInstances Define whether or not the material is used with instances
  21624. * @returns true if ready, otherwise false
  21625. */
  21626. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21627. /**
  21628. * Clones the current material and its related sub materials
  21629. * @param name Define the name of the newly cloned material
  21630. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21631. * @returns the cloned material
  21632. */
  21633. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21634. /**
  21635. * Serializes the materials into a JSON representation.
  21636. * @returns the JSON representation
  21637. */
  21638. serialize(): any;
  21639. /**
  21640. * Dispose the material and release its associated resources
  21641. * @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)
  21642. * @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)
  21643. * @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)
  21644. */
  21645. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21646. /**
  21647. * Creates a MultiMaterial from parsed MultiMaterial data.
  21648. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21649. * @param scene defines the hosting scene
  21650. * @returns a new MultiMaterial
  21651. */
  21652. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21653. }
  21654. }
  21655. declare module BABYLON {
  21656. /**
  21657. * Base class for submeshes
  21658. */
  21659. export class BaseSubMesh {
  21660. /** @hidden */
  21661. _materialDefines: Nullable<MaterialDefines>;
  21662. /** @hidden */
  21663. _materialEffect: Nullable<Effect>;
  21664. /**
  21665. * Gets material defines used by the effect associated to the sub mesh
  21666. */
  21667. get materialDefines(): Nullable<MaterialDefines>;
  21668. /**
  21669. * Sets material defines used by the effect associated to the sub mesh
  21670. */
  21671. set materialDefines(defines: Nullable<MaterialDefines>);
  21672. /**
  21673. * Gets associated effect
  21674. */
  21675. get effect(): Nullable<Effect>;
  21676. /**
  21677. * Sets associated effect (effect used to render this submesh)
  21678. * @param effect defines the effect to associate with
  21679. * @param defines defines the set of defines used to compile this effect
  21680. */
  21681. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21682. }
  21683. /**
  21684. * Defines a subdivision inside a mesh
  21685. */
  21686. export class SubMesh extends BaseSubMesh implements ICullable {
  21687. /** the material index to use */
  21688. materialIndex: number;
  21689. /** vertex index start */
  21690. verticesStart: number;
  21691. /** vertices count */
  21692. verticesCount: number;
  21693. /** index start */
  21694. indexStart: number;
  21695. /** indices count */
  21696. indexCount: number;
  21697. /** @hidden */
  21698. _linesIndexCount: number;
  21699. private _mesh;
  21700. private _renderingMesh;
  21701. private _boundingInfo;
  21702. private _linesIndexBuffer;
  21703. /** @hidden */
  21704. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21705. /** @hidden */
  21706. _trianglePlanes: Plane[];
  21707. /** @hidden */
  21708. _lastColliderTransformMatrix: Nullable<Matrix>;
  21709. /** @hidden */
  21710. _renderId: number;
  21711. /** @hidden */
  21712. _alphaIndex: number;
  21713. /** @hidden */
  21714. _distanceToCamera: number;
  21715. /** @hidden */
  21716. _id: number;
  21717. private _currentMaterial;
  21718. /**
  21719. * Add a new submesh to a mesh
  21720. * @param materialIndex defines the material index to use
  21721. * @param verticesStart defines vertex index start
  21722. * @param verticesCount defines vertices count
  21723. * @param indexStart defines index start
  21724. * @param indexCount defines indices count
  21725. * @param mesh defines the parent mesh
  21726. * @param renderingMesh defines an optional rendering mesh
  21727. * @param createBoundingBox defines if bounding box should be created for this submesh
  21728. * @returns the new submesh
  21729. */
  21730. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21731. /**
  21732. * Creates a new submesh
  21733. * @param materialIndex defines the material index to use
  21734. * @param verticesStart defines vertex index start
  21735. * @param verticesCount defines vertices count
  21736. * @param indexStart defines index start
  21737. * @param indexCount defines indices count
  21738. * @param mesh defines the parent mesh
  21739. * @param renderingMesh defines an optional rendering mesh
  21740. * @param createBoundingBox defines if bounding box should be created for this submesh
  21741. */
  21742. constructor(
  21743. /** the material index to use */
  21744. materialIndex: number,
  21745. /** vertex index start */
  21746. verticesStart: number,
  21747. /** vertices count */
  21748. verticesCount: number,
  21749. /** index start */
  21750. indexStart: number,
  21751. /** indices count */
  21752. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21753. /**
  21754. * Returns true if this submesh covers the entire parent mesh
  21755. * @ignorenaming
  21756. */
  21757. get IsGlobal(): boolean;
  21758. /**
  21759. * Returns the submesh BoudingInfo object
  21760. * @returns current bounding info (or mesh's one if the submesh is global)
  21761. */
  21762. getBoundingInfo(): BoundingInfo;
  21763. /**
  21764. * Sets the submesh BoundingInfo
  21765. * @param boundingInfo defines the new bounding info to use
  21766. * @returns the SubMesh
  21767. */
  21768. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21769. /**
  21770. * Returns the mesh of the current submesh
  21771. * @return the parent mesh
  21772. */
  21773. getMesh(): AbstractMesh;
  21774. /**
  21775. * Returns the rendering mesh of the submesh
  21776. * @returns the rendering mesh (could be different from parent mesh)
  21777. */
  21778. getRenderingMesh(): Mesh;
  21779. /**
  21780. * Returns the submesh material
  21781. * @returns null or the current material
  21782. */
  21783. getMaterial(): Nullable<Material>;
  21784. /**
  21785. * Sets a new updated BoundingInfo object to the submesh
  21786. * @param data defines an optional position array to use to determine the bounding info
  21787. * @returns the SubMesh
  21788. */
  21789. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21790. /** @hidden */
  21791. _checkCollision(collider: Collider): boolean;
  21792. /**
  21793. * Updates the submesh BoundingInfo
  21794. * @param world defines the world matrix to use to update the bounding info
  21795. * @returns the submesh
  21796. */
  21797. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21798. /**
  21799. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21800. * @param frustumPlanes defines the frustum planes
  21801. * @returns true if the submesh is intersecting with the frustum
  21802. */
  21803. isInFrustum(frustumPlanes: Plane[]): boolean;
  21804. /**
  21805. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21806. * @param frustumPlanes defines the frustum planes
  21807. * @returns true if the submesh is inside the frustum
  21808. */
  21809. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21810. /**
  21811. * Renders the submesh
  21812. * @param enableAlphaMode defines if alpha needs to be used
  21813. * @returns the submesh
  21814. */
  21815. render(enableAlphaMode: boolean): SubMesh;
  21816. /**
  21817. * @hidden
  21818. */
  21819. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21820. /**
  21821. * Checks if the submesh intersects with a ray
  21822. * @param ray defines the ray to test
  21823. * @returns true is the passed ray intersects the submesh bounding box
  21824. */
  21825. canIntersects(ray: Ray): boolean;
  21826. /**
  21827. * Intersects current submesh with a ray
  21828. * @param ray defines the ray to test
  21829. * @param positions defines mesh's positions array
  21830. * @param indices defines mesh's indices array
  21831. * @param fastCheck defines if only bounding info should be used
  21832. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21833. * @returns intersection info or null if no intersection
  21834. */
  21835. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21836. /** @hidden */
  21837. private _intersectLines;
  21838. /** @hidden */
  21839. private _intersectUnIndexedLines;
  21840. /** @hidden */
  21841. private _intersectTriangles;
  21842. /** @hidden */
  21843. private _intersectUnIndexedTriangles;
  21844. /** @hidden */
  21845. _rebuild(): void;
  21846. /**
  21847. * Creates a new submesh from the passed mesh
  21848. * @param newMesh defines the new hosting mesh
  21849. * @param newRenderingMesh defines an optional rendering mesh
  21850. * @returns the new submesh
  21851. */
  21852. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21853. /**
  21854. * Release associated resources
  21855. */
  21856. dispose(): void;
  21857. /**
  21858. * Gets the class name
  21859. * @returns the string "SubMesh".
  21860. */
  21861. getClassName(): string;
  21862. /**
  21863. * Creates a new submesh from indices data
  21864. * @param materialIndex the index of the main mesh material
  21865. * @param startIndex the index where to start the copy in the mesh indices array
  21866. * @param indexCount the number of indices to copy then from the startIndex
  21867. * @param mesh the main mesh to create the submesh from
  21868. * @param renderingMesh the optional rendering mesh
  21869. * @returns a new submesh
  21870. */
  21871. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21872. }
  21873. }
  21874. declare module BABYLON {
  21875. /**
  21876. * Class used to represent data loading progression
  21877. */
  21878. export class SceneLoaderFlags {
  21879. private static _ForceFullSceneLoadingForIncremental;
  21880. private static _ShowLoadingScreen;
  21881. private static _CleanBoneMatrixWeights;
  21882. private static _loggingLevel;
  21883. /**
  21884. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21885. */
  21886. static get ForceFullSceneLoadingForIncremental(): boolean;
  21887. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21888. /**
  21889. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21890. */
  21891. static get ShowLoadingScreen(): boolean;
  21892. static set ShowLoadingScreen(value: boolean);
  21893. /**
  21894. * Defines the current logging level (while loading the scene)
  21895. * @ignorenaming
  21896. */
  21897. static get loggingLevel(): number;
  21898. static set loggingLevel(value: number);
  21899. /**
  21900. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21901. */
  21902. static get CleanBoneMatrixWeights(): boolean;
  21903. static set CleanBoneMatrixWeights(value: boolean);
  21904. }
  21905. }
  21906. declare module BABYLON {
  21907. /**
  21908. * Class used to store geometry data (vertex buffers + index buffer)
  21909. */
  21910. export class Geometry implements IGetSetVerticesData {
  21911. /**
  21912. * Gets or sets the ID of the geometry
  21913. */
  21914. id: string;
  21915. /**
  21916. * Gets or sets the unique ID of the geometry
  21917. */
  21918. uniqueId: number;
  21919. /**
  21920. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21921. */
  21922. delayLoadState: number;
  21923. /**
  21924. * Gets the file containing the data to load when running in delay load state
  21925. */
  21926. delayLoadingFile: Nullable<string>;
  21927. /**
  21928. * Callback called when the geometry is updated
  21929. */
  21930. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21931. private _scene;
  21932. private _engine;
  21933. private _meshes;
  21934. private _totalVertices;
  21935. /** @hidden */
  21936. _indices: IndicesArray;
  21937. /** @hidden */
  21938. _vertexBuffers: {
  21939. [key: string]: VertexBuffer;
  21940. };
  21941. private _isDisposed;
  21942. private _extend;
  21943. private _boundingBias;
  21944. /** @hidden */
  21945. _delayInfo: Array<string>;
  21946. private _indexBuffer;
  21947. private _indexBufferIsUpdatable;
  21948. /** @hidden */
  21949. _boundingInfo: Nullable<BoundingInfo>;
  21950. /** @hidden */
  21951. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21952. /** @hidden */
  21953. _softwareSkinningFrameId: number;
  21954. private _vertexArrayObjects;
  21955. private _updatable;
  21956. /** @hidden */
  21957. _positions: Nullable<Vector3[]>;
  21958. /**
  21959. * 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
  21960. */
  21961. get boundingBias(): Vector2;
  21962. /**
  21963. * 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
  21964. */
  21965. set boundingBias(value: Vector2);
  21966. /**
  21967. * Static function used to attach a new empty geometry to a mesh
  21968. * @param mesh defines the mesh to attach the geometry to
  21969. * @returns the new Geometry
  21970. */
  21971. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21972. /**
  21973. * Creates a new geometry
  21974. * @param id defines the unique ID
  21975. * @param scene defines the hosting scene
  21976. * @param vertexData defines the VertexData used to get geometry data
  21977. * @param updatable defines if geometry must be updatable (false by default)
  21978. * @param mesh defines the mesh that will be associated with the geometry
  21979. */
  21980. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21981. /**
  21982. * Gets the current extend of the geometry
  21983. */
  21984. get extend(): {
  21985. minimum: Vector3;
  21986. maximum: Vector3;
  21987. };
  21988. /**
  21989. * Gets the hosting scene
  21990. * @returns the hosting Scene
  21991. */
  21992. getScene(): Scene;
  21993. /**
  21994. * Gets the hosting engine
  21995. * @returns the hosting Engine
  21996. */
  21997. getEngine(): Engine;
  21998. /**
  21999. * Defines if the geometry is ready to use
  22000. * @returns true if the geometry is ready to be used
  22001. */
  22002. isReady(): boolean;
  22003. /**
  22004. * Gets a value indicating that the geometry should not be serialized
  22005. */
  22006. get doNotSerialize(): boolean;
  22007. /** @hidden */
  22008. _rebuild(): void;
  22009. /**
  22010. * Affects all geometry data in one call
  22011. * @param vertexData defines the geometry data
  22012. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22013. */
  22014. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22015. /**
  22016. * Set specific vertex data
  22017. * @param kind defines the data kind (Position, normal, etc...)
  22018. * @param data defines the vertex data to use
  22019. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22020. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22021. */
  22022. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22023. /**
  22024. * Removes a specific vertex data
  22025. * @param kind defines the data kind (Position, normal, etc...)
  22026. */
  22027. removeVerticesData(kind: string): void;
  22028. /**
  22029. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22030. * @param buffer defines the vertex buffer to use
  22031. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22032. */
  22033. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22034. /**
  22035. * Update a specific vertex buffer
  22036. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22037. * It will do nothing if the buffer is not updatable
  22038. * @param kind defines the data kind (Position, normal, etc...)
  22039. * @param data defines the data to use
  22040. * @param offset defines the offset in the target buffer where to store the data
  22041. * @param useBytes set to true if the offset is in bytes
  22042. */
  22043. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22044. /**
  22045. * Update a specific vertex buffer
  22046. * This function will create a new buffer if the current one is not updatable
  22047. * @param kind defines the data kind (Position, normal, etc...)
  22048. * @param data defines the data to use
  22049. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22050. */
  22051. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22052. private _updateBoundingInfo;
  22053. /** @hidden */
  22054. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22055. /**
  22056. * Gets total number of vertices
  22057. * @returns the total number of vertices
  22058. */
  22059. getTotalVertices(): number;
  22060. /**
  22061. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22062. * @param kind defines the data kind (Position, normal, etc...)
  22063. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22064. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22065. * @returns a float array containing vertex data
  22066. */
  22067. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22068. /**
  22069. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22070. * @param kind defines the data kind (Position, normal, etc...)
  22071. * @returns true if the vertex buffer with the specified kind is updatable
  22072. */
  22073. isVertexBufferUpdatable(kind: string): boolean;
  22074. /**
  22075. * Gets a specific vertex buffer
  22076. * @param kind defines the data kind (Position, normal, etc...)
  22077. * @returns a VertexBuffer
  22078. */
  22079. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22080. /**
  22081. * Returns all vertex buffers
  22082. * @return an object holding all vertex buffers indexed by kind
  22083. */
  22084. getVertexBuffers(): Nullable<{
  22085. [key: string]: VertexBuffer;
  22086. }>;
  22087. /**
  22088. * Gets a boolean indicating if specific vertex buffer is present
  22089. * @param kind defines the data kind (Position, normal, etc...)
  22090. * @returns true if data is present
  22091. */
  22092. isVerticesDataPresent(kind: string): boolean;
  22093. /**
  22094. * Gets a list of all attached data kinds (Position, normal, etc...)
  22095. * @returns a list of string containing all kinds
  22096. */
  22097. getVerticesDataKinds(): string[];
  22098. /**
  22099. * Update index buffer
  22100. * @param indices defines the indices to store in the index buffer
  22101. * @param offset defines the offset in the target buffer where to store the data
  22102. * @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)
  22103. */
  22104. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22105. /**
  22106. * Creates a new index buffer
  22107. * @param indices defines the indices to store in the index buffer
  22108. * @param totalVertices defines the total number of vertices (could be null)
  22109. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22110. */
  22111. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22112. /**
  22113. * Return the total number of indices
  22114. * @returns the total number of indices
  22115. */
  22116. getTotalIndices(): number;
  22117. /**
  22118. * Gets the index buffer array
  22119. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22120. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22121. * @returns the index buffer array
  22122. */
  22123. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22124. /**
  22125. * Gets the index buffer
  22126. * @return the index buffer
  22127. */
  22128. getIndexBuffer(): Nullable<DataBuffer>;
  22129. /** @hidden */
  22130. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22131. /**
  22132. * Release the associated resources for a specific mesh
  22133. * @param mesh defines the source mesh
  22134. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22135. */
  22136. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22137. /**
  22138. * Apply current geometry to a given mesh
  22139. * @param mesh defines the mesh to apply geometry to
  22140. */
  22141. applyToMesh(mesh: Mesh): void;
  22142. private _updateExtend;
  22143. private _applyToMesh;
  22144. private notifyUpdate;
  22145. /**
  22146. * Load the geometry if it was flagged as delay loaded
  22147. * @param scene defines the hosting scene
  22148. * @param onLoaded defines a callback called when the geometry is loaded
  22149. */
  22150. load(scene: Scene, onLoaded?: () => void): void;
  22151. private _queueLoad;
  22152. /**
  22153. * Invert the geometry to move from a right handed system to a left handed one.
  22154. */
  22155. toLeftHanded(): void;
  22156. /** @hidden */
  22157. _resetPointsArrayCache(): void;
  22158. /** @hidden */
  22159. _generatePointsArray(): boolean;
  22160. /**
  22161. * Gets a value indicating if the geometry is disposed
  22162. * @returns true if the geometry was disposed
  22163. */
  22164. isDisposed(): boolean;
  22165. private _disposeVertexArrayObjects;
  22166. /**
  22167. * Free all associated resources
  22168. */
  22169. dispose(): void;
  22170. /**
  22171. * Clone the current geometry into a new geometry
  22172. * @param id defines the unique ID of the new geometry
  22173. * @returns a new geometry object
  22174. */
  22175. copy(id: string): Geometry;
  22176. /**
  22177. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22178. * @return a JSON representation of the current geometry data (without the vertices data)
  22179. */
  22180. serialize(): any;
  22181. private toNumberArray;
  22182. /**
  22183. * Serialize all vertices data into a JSON oject
  22184. * @returns a JSON representation of the current geometry data
  22185. */
  22186. serializeVerticeData(): any;
  22187. /**
  22188. * Extracts a clone of a mesh geometry
  22189. * @param mesh defines the source mesh
  22190. * @param id defines the unique ID of the new geometry object
  22191. * @returns the new geometry object
  22192. */
  22193. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22194. /**
  22195. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22196. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22197. * Be aware Math.random() could cause collisions, but:
  22198. * "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"
  22199. * @returns a string containing a new GUID
  22200. */
  22201. static RandomId(): string;
  22202. /** @hidden */
  22203. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22204. private static _CleanMatricesWeights;
  22205. /**
  22206. * Create a new geometry from persisted data (Using .babylon file format)
  22207. * @param parsedVertexData defines the persisted data
  22208. * @param scene defines the hosting scene
  22209. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22210. * @returns the new geometry object
  22211. */
  22212. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22213. }
  22214. }
  22215. declare module BABYLON {
  22216. /**
  22217. * Define an interface for all classes that will get and set the data on vertices
  22218. */
  22219. export interface IGetSetVerticesData {
  22220. /**
  22221. * Gets a boolean indicating if specific vertex data is present
  22222. * @param kind defines the vertex data kind to use
  22223. * @returns true is data kind is present
  22224. */
  22225. isVerticesDataPresent(kind: string): boolean;
  22226. /**
  22227. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22228. * @param kind defines the data kind (Position, normal, etc...)
  22229. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22230. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22231. * @returns a float array containing vertex data
  22232. */
  22233. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22234. /**
  22235. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22236. * @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.
  22237. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22238. * @returns the indices array or an empty array if the mesh has no geometry
  22239. */
  22240. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22241. /**
  22242. * Set specific vertex data
  22243. * @param kind defines the data kind (Position, normal, etc...)
  22244. * @param data defines the vertex data to use
  22245. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22246. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22247. */
  22248. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22249. /**
  22250. * Update a specific associated vertex buffer
  22251. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22252. * - VertexBuffer.PositionKind
  22253. * - VertexBuffer.UVKind
  22254. * - VertexBuffer.UV2Kind
  22255. * - VertexBuffer.UV3Kind
  22256. * - VertexBuffer.UV4Kind
  22257. * - VertexBuffer.UV5Kind
  22258. * - VertexBuffer.UV6Kind
  22259. * - VertexBuffer.ColorKind
  22260. * - VertexBuffer.MatricesIndicesKind
  22261. * - VertexBuffer.MatricesIndicesExtraKind
  22262. * - VertexBuffer.MatricesWeightsKind
  22263. * - VertexBuffer.MatricesWeightsExtraKind
  22264. * @param data defines the data source
  22265. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22266. * @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)
  22267. */
  22268. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22269. /**
  22270. * Creates a new index buffer
  22271. * @param indices defines the indices to store in the index buffer
  22272. * @param totalVertices defines the total number of vertices (could be null)
  22273. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22274. */
  22275. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22276. }
  22277. /**
  22278. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22279. */
  22280. export class VertexData {
  22281. /**
  22282. * Mesh side orientation : usually the external or front surface
  22283. */
  22284. static readonly FRONTSIDE: number;
  22285. /**
  22286. * Mesh side orientation : usually the internal or back surface
  22287. */
  22288. static readonly BACKSIDE: number;
  22289. /**
  22290. * Mesh side orientation : both internal and external or front and back surfaces
  22291. */
  22292. static readonly DOUBLESIDE: number;
  22293. /**
  22294. * Mesh side orientation : by default, `FRONTSIDE`
  22295. */
  22296. static readonly DEFAULTSIDE: number;
  22297. /**
  22298. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22299. */
  22300. positions: Nullable<FloatArray>;
  22301. /**
  22302. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22303. */
  22304. normals: Nullable<FloatArray>;
  22305. /**
  22306. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22307. */
  22308. tangents: Nullable<FloatArray>;
  22309. /**
  22310. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22311. */
  22312. uvs: Nullable<FloatArray>;
  22313. /**
  22314. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22315. */
  22316. uvs2: Nullable<FloatArray>;
  22317. /**
  22318. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22319. */
  22320. uvs3: Nullable<FloatArray>;
  22321. /**
  22322. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22323. */
  22324. uvs4: Nullable<FloatArray>;
  22325. /**
  22326. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22327. */
  22328. uvs5: Nullable<FloatArray>;
  22329. /**
  22330. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22331. */
  22332. uvs6: Nullable<FloatArray>;
  22333. /**
  22334. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22335. */
  22336. colors: Nullable<FloatArray>;
  22337. /**
  22338. * 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).
  22339. */
  22340. matricesIndices: Nullable<FloatArray>;
  22341. /**
  22342. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22343. */
  22344. matricesWeights: Nullable<FloatArray>;
  22345. /**
  22346. * An array extending the number of possible indices
  22347. */
  22348. matricesIndicesExtra: Nullable<FloatArray>;
  22349. /**
  22350. * An array extending the number of possible weights when the number of indices is extended
  22351. */
  22352. matricesWeightsExtra: Nullable<FloatArray>;
  22353. /**
  22354. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22355. */
  22356. indices: Nullable<IndicesArray>;
  22357. /**
  22358. * Uses the passed data array to set the set the values for the specified kind of data
  22359. * @param data a linear array of floating numbers
  22360. * @param kind the type of data that is being set, eg positions, colors etc
  22361. */
  22362. set(data: FloatArray, kind: string): void;
  22363. /**
  22364. * Associates the vertexData to the passed Mesh.
  22365. * Sets it as updatable or not (default `false`)
  22366. * @param mesh the mesh the vertexData is applied to
  22367. * @param updatable when used and having the value true allows new data to update the vertexData
  22368. * @returns the VertexData
  22369. */
  22370. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22371. /**
  22372. * Associates the vertexData to the passed Geometry.
  22373. * Sets it as updatable or not (default `false`)
  22374. * @param geometry the geometry the vertexData is applied to
  22375. * @param updatable when used and having the value true allows new data to update the vertexData
  22376. * @returns VertexData
  22377. */
  22378. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22379. /**
  22380. * Updates the associated mesh
  22381. * @param mesh the mesh to be updated
  22382. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22383. * @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
  22384. * @returns VertexData
  22385. */
  22386. updateMesh(mesh: Mesh): VertexData;
  22387. /**
  22388. * Updates the associated geometry
  22389. * @param geometry the geometry to be updated
  22390. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22391. * @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
  22392. * @returns VertexData.
  22393. */
  22394. updateGeometry(geometry: Geometry): VertexData;
  22395. private _applyTo;
  22396. private _update;
  22397. /**
  22398. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22399. * @param matrix the transforming matrix
  22400. * @returns the VertexData
  22401. */
  22402. transform(matrix: Matrix): VertexData;
  22403. /**
  22404. * Merges the passed VertexData into the current one
  22405. * @param other the VertexData to be merged into the current one
  22406. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22407. * @returns the modified VertexData
  22408. */
  22409. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22410. private _mergeElement;
  22411. private _validate;
  22412. /**
  22413. * Serializes the VertexData
  22414. * @returns a serialized object
  22415. */
  22416. serialize(): any;
  22417. /**
  22418. * Extracts the vertexData from a mesh
  22419. * @param mesh the mesh from which to extract the VertexData
  22420. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22421. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22422. * @returns the object VertexData associated to the passed mesh
  22423. */
  22424. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22425. /**
  22426. * Extracts the vertexData from the geometry
  22427. * @param geometry the geometry from which to extract the VertexData
  22428. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22429. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22430. * @returns the object VertexData associated to the passed mesh
  22431. */
  22432. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22433. private static _ExtractFrom;
  22434. /**
  22435. * Creates the VertexData for a Ribbon
  22436. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22437. * * pathArray array of paths, each of which an array of successive Vector3
  22438. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22439. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22440. * * 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
  22441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22442. * * 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)
  22443. * * 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)
  22444. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22445. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22446. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22447. * @returns the VertexData of the ribbon
  22448. */
  22449. static CreateRibbon(options: {
  22450. pathArray: Vector3[][];
  22451. closeArray?: boolean;
  22452. closePath?: boolean;
  22453. offset?: number;
  22454. sideOrientation?: number;
  22455. frontUVs?: Vector4;
  22456. backUVs?: Vector4;
  22457. invertUV?: boolean;
  22458. uvs?: Vector2[];
  22459. colors?: Color4[];
  22460. }): VertexData;
  22461. /**
  22462. * Creates the VertexData for a box
  22463. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22464. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22465. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22466. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22467. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22468. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22469. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22471. * * 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)
  22472. * * 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)
  22473. * @returns the VertexData of the box
  22474. */
  22475. static CreateBox(options: {
  22476. size?: number;
  22477. width?: number;
  22478. height?: number;
  22479. depth?: number;
  22480. faceUV?: Vector4[];
  22481. faceColors?: Color4[];
  22482. sideOrientation?: number;
  22483. frontUVs?: Vector4;
  22484. backUVs?: Vector4;
  22485. }): VertexData;
  22486. /**
  22487. * Creates the VertexData for a tiled box
  22488. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22489. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22490. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22491. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22492. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22493. * @returns the VertexData of the box
  22494. */
  22495. static CreateTiledBox(options: {
  22496. pattern?: number;
  22497. width?: number;
  22498. height?: number;
  22499. depth?: number;
  22500. tileSize?: number;
  22501. tileWidth?: number;
  22502. tileHeight?: number;
  22503. alignHorizontal?: number;
  22504. alignVertical?: number;
  22505. faceUV?: Vector4[];
  22506. faceColors?: Color4[];
  22507. sideOrientation?: number;
  22508. }): VertexData;
  22509. /**
  22510. * Creates the VertexData for a tiled plane
  22511. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22512. * * pattern a limited pattern arrangement depending on the number
  22513. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22514. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22515. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22517. * * 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)
  22518. * * 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)
  22519. * @returns the VertexData of the tiled plane
  22520. */
  22521. static CreateTiledPlane(options: {
  22522. pattern?: number;
  22523. tileSize?: number;
  22524. tileWidth?: number;
  22525. tileHeight?: number;
  22526. size?: number;
  22527. width?: number;
  22528. height?: number;
  22529. alignHorizontal?: number;
  22530. alignVertical?: number;
  22531. sideOrientation?: number;
  22532. frontUVs?: Vector4;
  22533. backUVs?: Vector4;
  22534. }): VertexData;
  22535. /**
  22536. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22537. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22538. * * segments sets the number of horizontal strips optional, default 32
  22539. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22540. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22541. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22542. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22543. * * 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
  22544. * * 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
  22545. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22546. * * 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)
  22547. * * 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)
  22548. * @returns the VertexData of the ellipsoid
  22549. */
  22550. static CreateSphere(options: {
  22551. segments?: number;
  22552. diameter?: number;
  22553. diameterX?: number;
  22554. diameterY?: number;
  22555. diameterZ?: number;
  22556. arc?: number;
  22557. slice?: number;
  22558. sideOrientation?: number;
  22559. frontUVs?: Vector4;
  22560. backUVs?: Vector4;
  22561. }): VertexData;
  22562. /**
  22563. * Creates the VertexData for a cylinder, cone or prism
  22564. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22565. * * height sets the height (y direction) of the cylinder, optional, default 2
  22566. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22567. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22568. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22569. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22570. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22571. * * 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
  22572. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22573. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22574. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22575. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22576. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22577. * * 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)
  22578. * * 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)
  22579. * @returns the VertexData of the cylinder, cone or prism
  22580. */
  22581. static CreateCylinder(options: {
  22582. height?: number;
  22583. diameterTop?: number;
  22584. diameterBottom?: number;
  22585. diameter?: number;
  22586. tessellation?: number;
  22587. subdivisions?: number;
  22588. arc?: number;
  22589. faceColors?: Color4[];
  22590. faceUV?: Vector4[];
  22591. hasRings?: boolean;
  22592. enclose?: boolean;
  22593. sideOrientation?: number;
  22594. frontUVs?: Vector4;
  22595. backUVs?: Vector4;
  22596. }): VertexData;
  22597. /**
  22598. * Creates the VertexData for a torus
  22599. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22600. * * diameter the diameter of the torus, optional default 1
  22601. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22602. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22603. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22604. * * 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)
  22605. * * 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)
  22606. * @returns the VertexData of the torus
  22607. */
  22608. static CreateTorus(options: {
  22609. diameter?: number;
  22610. thickness?: number;
  22611. tessellation?: number;
  22612. sideOrientation?: number;
  22613. frontUVs?: Vector4;
  22614. backUVs?: Vector4;
  22615. }): VertexData;
  22616. /**
  22617. * Creates the VertexData of the LineSystem
  22618. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22619. * - lines an array of lines, each line being an array of successive Vector3
  22620. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22621. * @returns the VertexData of the LineSystem
  22622. */
  22623. static CreateLineSystem(options: {
  22624. lines: Vector3[][];
  22625. colors?: Nullable<Color4[][]>;
  22626. }): VertexData;
  22627. /**
  22628. * Create the VertexData for a DashedLines
  22629. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22630. * - points an array successive Vector3
  22631. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22632. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22633. * - dashNb the intended total number of dashes, optional, default 200
  22634. * @returns the VertexData for the DashedLines
  22635. */
  22636. static CreateDashedLines(options: {
  22637. points: Vector3[];
  22638. dashSize?: number;
  22639. gapSize?: number;
  22640. dashNb?: number;
  22641. }): VertexData;
  22642. /**
  22643. * Creates the VertexData for a Ground
  22644. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22645. * - width the width (x direction) of the ground, optional, default 1
  22646. * - height the height (z direction) of the ground, optional, default 1
  22647. * - subdivisions the number of subdivisions per side, optional, default 1
  22648. * @returns the VertexData of the Ground
  22649. */
  22650. static CreateGround(options: {
  22651. width?: number;
  22652. height?: number;
  22653. subdivisions?: number;
  22654. subdivisionsX?: number;
  22655. subdivisionsY?: number;
  22656. }): VertexData;
  22657. /**
  22658. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22659. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22660. * * xmin the ground minimum X coordinate, optional, default -1
  22661. * * zmin the ground minimum Z coordinate, optional, default -1
  22662. * * xmax the ground maximum X coordinate, optional, default 1
  22663. * * zmax the ground maximum Z coordinate, optional, default 1
  22664. * * 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}
  22665. * * 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}
  22666. * @returns the VertexData of the TiledGround
  22667. */
  22668. static CreateTiledGround(options: {
  22669. xmin: number;
  22670. zmin: number;
  22671. xmax: number;
  22672. zmax: number;
  22673. subdivisions?: {
  22674. w: number;
  22675. h: number;
  22676. };
  22677. precision?: {
  22678. w: number;
  22679. h: number;
  22680. };
  22681. }): VertexData;
  22682. /**
  22683. * Creates the VertexData of the Ground designed from a heightmap
  22684. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22685. * * width the width (x direction) of the ground
  22686. * * height the height (z direction) of the ground
  22687. * * subdivisions the number of subdivisions per side
  22688. * * minHeight the minimum altitude on the ground, optional, default 0
  22689. * * maxHeight the maximum altitude on the ground, optional default 1
  22690. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22691. * * buffer the array holding the image color data
  22692. * * bufferWidth the width of image
  22693. * * bufferHeight the height of image
  22694. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22695. * @returns the VertexData of the Ground designed from a heightmap
  22696. */
  22697. static CreateGroundFromHeightMap(options: {
  22698. width: number;
  22699. height: number;
  22700. subdivisions: number;
  22701. minHeight: number;
  22702. maxHeight: number;
  22703. colorFilter: Color3;
  22704. buffer: Uint8Array;
  22705. bufferWidth: number;
  22706. bufferHeight: number;
  22707. alphaFilter: number;
  22708. }): VertexData;
  22709. /**
  22710. * Creates the VertexData for a Plane
  22711. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22712. * * size sets the width and height of the plane to the value of size, optional default 1
  22713. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22714. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22715. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22716. * * 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)
  22717. * * 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)
  22718. * @returns the VertexData of the box
  22719. */
  22720. static CreatePlane(options: {
  22721. size?: number;
  22722. width?: number;
  22723. height?: number;
  22724. sideOrientation?: number;
  22725. frontUVs?: Vector4;
  22726. backUVs?: Vector4;
  22727. }): VertexData;
  22728. /**
  22729. * Creates the VertexData of the Disc or regular Polygon
  22730. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22731. * * radius the radius of the disc, optional default 0.5
  22732. * * tessellation the number of polygon sides, optional, default 64
  22733. * * 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
  22734. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22735. * * 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)
  22736. * * 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)
  22737. * @returns the VertexData of the box
  22738. */
  22739. static CreateDisc(options: {
  22740. radius?: number;
  22741. tessellation?: number;
  22742. arc?: number;
  22743. sideOrientation?: number;
  22744. frontUVs?: Vector4;
  22745. backUVs?: Vector4;
  22746. }): VertexData;
  22747. /**
  22748. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22749. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22750. * @param polygon a mesh built from polygonTriangulation.build()
  22751. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22752. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22753. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22754. * @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)
  22755. * @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)
  22756. * @returns the VertexData of the Polygon
  22757. */
  22758. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22759. /**
  22760. * Creates the VertexData of the IcoSphere
  22761. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22762. * * radius the radius of the IcoSphere, optional default 1
  22763. * * radiusX allows stretching in the x direction, optional, default radius
  22764. * * radiusY allows stretching in the y direction, optional, default radius
  22765. * * radiusZ allows stretching in the z direction, optional, default radius
  22766. * * flat when true creates a flat shaded mesh, optional, default true
  22767. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22768. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22769. * * 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)
  22770. * * 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)
  22771. * @returns the VertexData of the IcoSphere
  22772. */
  22773. static CreateIcoSphere(options: {
  22774. radius?: number;
  22775. radiusX?: number;
  22776. radiusY?: number;
  22777. radiusZ?: number;
  22778. flat?: boolean;
  22779. subdivisions?: number;
  22780. sideOrientation?: number;
  22781. frontUVs?: Vector4;
  22782. backUVs?: Vector4;
  22783. }): VertexData;
  22784. /**
  22785. * Creates the VertexData for a Polyhedron
  22786. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22787. * * type provided types are:
  22788. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22789. * * 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)
  22790. * * size the size of the IcoSphere, optional default 1
  22791. * * sizeX allows stretching in the x direction, optional, default size
  22792. * * sizeY allows stretching in the y direction, optional, default size
  22793. * * sizeZ allows stretching in the z direction, optional, default size
  22794. * * 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
  22795. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22796. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22797. * * flat when true creates a flat shaded mesh, optional, default true
  22798. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22799. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22800. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22801. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22802. * @returns the VertexData of the Polyhedron
  22803. */
  22804. static CreatePolyhedron(options: {
  22805. type?: number;
  22806. size?: number;
  22807. sizeX?: number;
  22808. sizeY?: number;
  22809. sizeZ?: number;
  22810. custom?: any;
  22811. faceUV?: Vector4[];
  22812. faceColors?: Color4[];
  22813. flat?: boolean;
  22814. sideOrientation?: number;
  22815. frontUVs?: Vector4;
  22816. backUVs?: Vector4;
  22817. }): VertexData;
  22818. /**
  22819. * Creates the VertexData for a TorusKnot
  22820. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22821. * * radius the radius of the torus knot, optional, default 2
  22822. * * tube the thickness of the tube, optional, default 0.5
  22823. * * radialSegments the number of sides on each tube segments, optional, default 32
  22824. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22825. * * p the number of windings around the z axis, optional, default 2
  22826. * * q the number of windings around the x axis, optional, default 3
  22827. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22828. * * 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)
  22829. * * 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)
  22830. * @returns the VertexData of the Torus Knot
  22831. */
  22832. static CreateTorusKnot(options: {
  22833. radius?: number;
  22834. tube?: number;
  22835. radialSegments?: number;
  22836. tubularSegments?: number;
  22837. p?: number;
  22838. q?: number;
  22839. sideOrientation?: number;
  22840. frontUVs?: Vector4;
  22841. backUVs?: Vector4;
  22842. }): VertexData;
  22843. /**
  22844. * Compute normals for given positions and indices
  22845. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22846. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22847. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22848. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22849. * * facetNormals : optional array of facet normals (vector3)
  22850. * * facetPositions : optional array of facet positions (vector3)
  22851. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22852. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22853. * * bInfo : optional bounding info, required for facetPartitioning computation
  22854. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22855. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22856. * * useRightHandedSystem: optional boolean to for right handed system computation
  22857. * * depthSort : optional boolean to enable the facet depth sort computation
  22858. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22859. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22860. */
  22861. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22862. facetNormals?: any;
  22863. facetPositions?: any;
  22864. facetPartitioning?: any;
  22865. ratio?: number;
  22866. bInfo?: any;
  22867. bbSize?: Vector3;
  22868. subDiv?: any;
  22869. useRightHandedSystem?: boolean;
  22870. depthSort?: boolean;
  22871. distanceTo?: Vector3;
  22872. depthSortedFacets?: any;
  22873. }): void;
  22874. /** @hidden */
  22875. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22876. /**
  22877. * Applies VertexData created from the imported parameters to the geometry
  22878. * @param parsedVertexData the parsed data from an imported file
  22879. * @param geometry the geometry to apply the VertexData to
  22880. */
  22881. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22882. }
  22883. }
  22884. declare module BABYLON {
  22885. /**
  22886. * Defines a target to use with MorphTargetManager
  22887. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22888. */
  22889. export class MorphTarget implements IAnimatable {
  22890. /** defines the name of the target */
  22891. name: string;
  22892. /**
  22893. * Gets or sets the list of animations
  22894. */
  22895. animations: Animation[];
  22896. private _scene;
  22897. private _positions;
  22898. private _normals;
  22899. private _tangents;
  22900. private _uvs;
  22901. private _influence;
  22902. private _uniqueId;
  22903. /**
  22904. * Observable raised when the influence changes
  22905. */
  22906. onInfluenceChanged: Observable<boolean>;
  22907. /** @hidden */
  22908. _onDataLayoutChanged: Observable<void>;
  22909. /**
  22910. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22911. */
  22912. get influence(): number;
  22913. set influence(influence: number);
  22914. /**
  22915. * Gets or sets the id of the morph Target
  22916. */
  22917. id: string;
  22918. private _animationPropertiesOverride;
  22919. /**
  22920. * Gets or sets the animation properties override
  22921. */
  22922. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22923. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22924. /**
  22925. * Creates a new MorphTarget
  22926. * @param name defines the name of the target
  22927. * @param influence defines the influence to use
  22928. * @param scene defines the scene the morphtarget belongs to
  22929. */
  22930. constructor(
  22931. /** defines the name of the target */
  22932. name: string, influence?: number, scene?: Nullable<Scene>);
  22933. /**
  22934. * Gets the unique ID of this manager
  22935. */
  22936. get uniqueId(): number;
  22937. /**
  22938. * Gets a boolean defining if the target contains position data
  22939. */
  22940. get hasPositions(): boolean;
  22941. /**
  22942. * Gets a boolean defining if the target contains normal data
  22943. */
  22944. get hasNormals(): boolean;
  22945. /**
  22946. * Gets a boolean defining if the target contains tangent data
  22947. */
  22948. get hasTangents(): boolean;
  22949. /**
  22950. * Gets a boolean defining if the target contains texture coordinates data
  22951. */
  22952. get hasUVs(): boolean;
  22953. /**
  22954. * Affects position data to this target
  22955. * @param data defines the position data to use
  22956. */
  22957. setPositions(data: Nullable<FloatArray>): void;
  22958. /**
  22959. * Gets the position data stored in this target
  22960. * @returns a FloatArray containing the position data (or null if not present)
  22961. */
  22962. getPositions(): Nullable<FloatArray>;
  22963. /**
  22964. * Affects normal data to this target
  22965. * @param data defines the normal data to use
  22966. */
  22967. setNormals(data: Nullable<FloatArray>): void;
  22968. /**
  22969. * Gets the normal data stored in this target
  22970. * @returns a FloatArray containing the normal data (or null if not present)
  22971. */
  22972. getNormals(): Nullable<FloatArray>;
  22973. /**
  22974. * Affects tangent data to this target
  22975. * @param data defines the tangent data to use
  22976. */
  22977. setTangents(data: Nullable<FloatArray>): void;
  22978. /**
  22979. * Gets the tangent data stored in this target
  22980. * @returns a FloatArray containing the tangent data (or null if not present)
  22981. */
  22982. getTangents(): Nullable<FloatArray>;
  22983. /**
  22984. * Affects texture coordinates data to this target
  22985. * @param data defines the texture coordinates data to use
  22986. */
  22987. setUVs(data: Nullable<FloatArray>): void;
  22988. /**
  22989. * Gets the texture coordinates data stored in this target
  22990. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22991. */
  22992. getUVs(): Nullable<FloatArray>;
  22993. /**
  22994. * Clone the current target
  22995. * @returns a new MorphTarget
  22996. */
  22997. clone(): MorphTarget;
  22998. /**
  22999. * Serializes the current target into a Serialization object
  23000. * @returns the serialized object
  23001. */
  23002. serialize(): any;
  23003. /**
  23004. * Returns the string "MorphTarget"
  23005. * @returns "MorphTarget"
  23006. */
  23007. getClassName(): string;
  23008. /**
  23009. * Creates a new target from serialized data
  23010. * @param serializationObject defines the serialized data to use
  23011. * @returns a new MorphTarget
  23012. */
  23013. static Parse(serializationObject: any): MorphTarget;
  23014. /**
  23015. * Creates a MorphTarget from mesh data
  23016. * @param mesh defines the source mesh
  23017. * @param name defines the name to use for the new target
  23018. * @param influence defines the influence to attach to the target
  23019. * @returns a new MorphTarget
  23020. */
  23021. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23022. }
  23023. }
  23024. declare module BABYLON {
  23025. /**
  23026. * This class is used to deform meshes using morphing between different targets
  23027. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23028. */
  23029. export class MorphTargetManager {
  23030. private _targets;
  23031. private _targetInfluenceChangedObservers;
  23032. private _targetDataLayoutChangedObservers;
  23033. private _activeTargets;
  23034. private _scene;
  23035. private _influences;
  23036. private _supportsNormals;
  23037. private _supportsTangents;
  23038. private _supportsUVs;
  23039. private _vertexCount;
  23040. private _uniqueId;
  23041. private _tempInfluences;
  23042. /**
  23043. * Gets or sets a boolean indicating if normals must be morphed
  23044. */
  23045. enableNormalMorphing: boolean;
  23046. /**
  23047. * Gets or sets a boolean indicating if tangents must be morphed
  23048. */
  23049. enableTangentMorphing: boolean;
  23050. /**
  23051. * Gets or sets a boolean indicating if UV must be morphed
  23052. */
  23053. enableUVMorphing: boolean;
  23054. /**
  23055. * Creates a new MorphTargetManager
  23056. * @param scene defines the current scene
  23057. */
  23058. constructor(scene?: Nullable<Scene>);
  23059. /**
  23060. * Gets the unique ID of this manager
  23061. */
  23062. get uniqueId(): number;
  23063. /**
  23064. * Gets the number of vertices handled by this manager
  23065. */
  23066. get vertexCount(): number;
  23067. /**
  23068. * Gets a boolean indicating if this manager supports morphing of normals
  23069. */
  23070. get supportsNormals(): boolean;
  23071. /**
  23072. * Gets a boolean indicating if this manager supports morphing of tangents
  23073. */
  23074. get supportsTangents(): boolean;
  23075. /**
  23076. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23077. */
  23078. get supportsUVs(): boolean;
  23079. /**
  23080. * Gets the number of targets stored in this manager
  23081. */
  23082. get numTargets(): number;
  23083. /**
  23084. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23085. */
  23086. get numInfluencers(): number;
  23087. /**
  23088. * Gets the list of influences (one per target)
  23089. */
  23090. get influences(): Float32Array;
  23091. /**
  23092. * Gets the active target at specified index. An active target is a target with an influence > 0
  23093. * @param index defines the index to check
  23094. * @returns the requested target
  23095. */
  23096. getActiveTarget(index: number): MorphTarget;
  23097. /**
  23098. * Gets the target at specified index
  23099. * @param index defines the index to check
  23100. * @returns the requested target
  23101. */
  23102. getTarget(index: number): MorphTarget;
  23103. /**
  23104. * Add a new target to this manager
  23105. * @param target defines the target to add
  23106. */
  23107. addTarget(target: MorphTarget): void;
  23108. /**
  23109. * Removes a target from the manager
  23110. * @param target defines the target to remove
  23111. */
  23112. removeTarget(target: MorphTarget): void;
  23113. /**
  23114. * Clone the current manager
  23115. * @returns a new MorphTargetManager
  23116. */
  23117. clone(): MorphTargetManager;
  23118. /**
  23119. * Serializes the current manager into a Serialization object
  23120. * @returns the serialized object
  23121. */
  23122. serialize(): any;
  23123. private _syncActiveTargets;
  23124. /**
  23125. * Syncrhonize the targets with all the meshes using this morph target manager
  23126. */
  23127. synchronize(): void;
  23128. /**
  23129. * Creates a new MorphTargetManager from serialized data
  23130. * @param serializationObject defines the serialized data
  23131. * @param scene defines the hosting scene
  23132. * @returns the new MorphTargetManager
  23133. */
  23134. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23135. }
  23136. }
  23137. declare module BABYLON {
  23138. /**
  23139. * Class used to represent a specific level of detail of a mesh
  23140. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23141. */
  23142. export class MeshLODLevel {
  23143. /** Defines the distance where this level should start being displayed */
  23144. distance: number;
  23145. /** Defines the mesh to use to render this level */
  23146. mesh: Nullable<Mesh>;
  23147. /**
  23148. * Creates a new LOD level
  23149. * @param distance defines the distance where this level should star being displayed
  23150. * @param mesh defines the mesh to use to render this level
  23151. */
  23152. constructor(
  23153. /** Defines the distance where this level should start being displayed */
  23154. distance: number,
  23155. /** Defines the mesh to use to render this level */
  23156. mesh: Nullable<Mesh>);
  23157. }
  23158. }
  23159. declare module BABYLON {
  23160. /**
  23161. * Mesh representing the gorund
  23162. */
  23163. export class GroundMesh extends Mesh {
  23164. /** If octree should be generated */
  23165. generateOctree: boolean;
  23166. private _heightQuads;
  23167. /** @hidden */
  23168. _subdivisionsX: number;
  23169. /** @hidden */
  23170. _subdivisionsY: number;
  23171. /** @hidden */
  23172. _width: number;
  23173. /** @hidden */
  23174. _height: number;
  23175. /** @hidden */
  23176. _minX: number;
  23177. /** @hidden */
  23178. _maxX: number;
  23179. /** @hidden */
  23180. _minZ: number;
  23181. /** @hidden */
  23182. _maxZ: number;
  23183. constructor(name: string, scene: Scene);
  23184. /**
  23185. * "GroundMesh"
  23186. * @returns "GroundMesh"
  23187. */
  23188. getClassName(): string;
  23189. /**
  23190. * The minimum of x and y subdivisions
  23191. */
  23192. get subdivisions(): number;
  23193. /**
  23194. * X subdivisions
  23195. */
  23196. get subdivisionsX(): number;
  23197. /**
  23198. * Y subdivisions
  23199. */
  23200. get subdivisionsY(): number;
  23201. /**
  23202. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23203. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23204. * @param chunksCount the number of subdivisions for x and y
  23205. * @param octreeBlocksSize (Default: 32)
  23206. */
  23207. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23208. /**
  23209. * Returns a height (y) value in the Worl system :
  23210. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23211. * @param x x coordinate
  23212. * @param z z coordinate
  23213. * @returns the ground y position if (x, z) are outside the ground surface.
  23214. */
  23215. getHeightAtCoordinates(x: number, z: number): number;
  23216. /**
  23217. * Returns a normalized vector (Vector3) orthogonal to the ground
  23218. * at the ground coordinates (x, z) expressed in the World system.
  23219. * @param x x coordinate
  23220. * @param z z coordinate
  23221. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23222. */
  23223. getNormalAtCoordinates(x: number, z: number): Vector3;
  23224. /**
  23225. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23226. * at the ground coordinates (x, z) expressed in the World system.
  23227. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23228. * @param x x coordinate
  23229. * @param z z coordinate
  23230. * @param ref vector to store the result
  23231. * @returns the GroundMesh.
  23232. */
  23233. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23234. /**
  23235. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23236. * if the ground has been updated.
  23237. * This can be used in the render loop.
  23238. * @returns the GroundMesh.
  23239. */
  23240. updateCoordinateHeights(): GroundMesh;
  23241. private _getFacetAt;
  23242. private _initHeightQuads;
  23243. private _computeHeightQuads;
  23244. /**
  23245. * Serializes this ground mesh
  23246. * @param serializationObject object to write serialization to
  23247. */
  23248. serialize(serializationObject: any): void;
  23249. /**
  23250. * Parses a serialized ground mesh
  23251. * @param parsedMesh the serialized mesh
  23252. * @param scene the scene to create the ground mesh in
  23253. * @returns the created ground mesh
  23254. */
  23255. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23256. }
  23257. }
  23258. declare module BABYLON {
  23259. /**
  23260. * Interface for Physics-Joint data
  23261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23262. */
  23263. export interface PhysicsJointData {
  23264. /**
  23265. * The main pivot of the joint
  23266. */
  23267. mainPivot?: Vector3;
  23268. /**
  23269. * The connected pivot of the joint
  23270. */
  23271. connectedPivot?: Vector3;
  23272. /**
  23273. * The main axis of the joint
  23274. */
  23275. mainAxis?: Vector3;
  23276. /**
  23277. * The connected axis of the joint
  23278. */
  23279. connectedAxis?: Vector3;
  23280. /**
  23281. * The collision of the joint
  23282. */
  23283. collision?: boolean;
  23284. /**
  23285. * Native Oimo/Cannon/Energy data
  23286. */
  23287. nativeParams?: any;
  23288. }
  23289. /**
  23290. * This is a holder class for the physics joint created by the physics plugin
  23291. * It holds a set of functions to control the underlying joint
  23292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23293. */
  23294. export class PhysicsJoint {
  23295. /**
  23296. * The type of the physics joint
  23297. */
  23298. type: number;
  23299. /**
  23300. * The data for the physics joint
  23301. */
  23302. jointData: PhysicsJointData;
  23303. private _physicsJoint;
  23304. protected _physicsPlugin: IPhysicsEnginePlugin;
  23305. /**
  23306. * Initializes the physics joint
  23307. * @param type The type of the physics joint
  23308. * @param jointData The data for the physics joint
  23309. */
  23310. constructor(
  23311. /**
  23312. * The type of the physics joint
  23313. */
  23314. type: number,
  23315. /**
  23316. * The data for the physics joint
  23317. */
  23318. jointData: PhysicsJointData);
  23319. /**
  23320. * Gets the physics joint
  23321. */
  23322. get physicsJoint(): any;
  23323. /**
  23324. * Sets the physics joint
  23325. */
  23326. set physicsJoint(newJoint: any);
  23327. /**
  23328. * Sets the physics plugin
  23329. */
  23330. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23331. /**
  23332. * Execute a function that is physics-plugin specific.
  23333. * @param {Function} func the function that will be executed.
  23334. * It accepts two parameters: the physics world and the physics joint
  23335. */
  23336. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23337. /**
  23338. * Distance-Joint type
  23339. */
  23340. static DistanceJoint: number;
  23341. /**
  23342. * Hinge-Joint type
  23343. */
  23344. static HingeJoint: number;
  23345. /**
  23346. * Ball-and-Socket joint type
  23347. */
  23348. static BallAndSocketJoint: number;
  23349. /**
  23350. * Wheel-Joint type
  23351. */
  23352. static WheelJoint: number;
  23353. /**
  23354. * Slider-Joint type
  23355. */
  23356. static SliderJoint: number;
  23357. /**
  23358. * Prismatic-Joint type
  23359. */
  23360. static PrismaticJoint: number;
  23361. /**
  23362. * Universal-Joint type
  23363. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23364. */
  23365. static UniversalJoint: number;
  23366. /**
  23367. * Hinge-Joint 2 type
  23368. */
  23369. static Hinge2Joint: number;
  23370. /**
  23371. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23372. */
  23373. static PointToPointJoint: number;
  23374. /**
  23375. * Spring-Joint type
  23376. */
  23377. static SpringJoint: number;
  23378. /**
  23379. * Lock-Joint type
  23380. */
  23381. static LockJoint: number;
  23382. }
  23383. /**
  23384. * A class representing a physics distance joint
  23385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23386. */
  23387. export class DistanceJoint extends PhysicsJoint {
  23388. /**
  23389. *
  23390. * @param jointData The data for the Distance-Joint
  23391. */
  23392. constructor(jointData: DistanceJointData);
  23393. /**
  23394. * Update the predefined distance.
  23395. * @param maxDistance The maximum preferred distance
  23396. * @param minDistance The minimum preferred distance
  23397. */
  23398. updateDistance(maxDistance: number, minDistance?: number): void;
  23399. }
  23400. /**
  23401. * Represents a Motor-Enabled Joint
  23402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23403. */
  23404. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23405. /**
  23406. * Initializes the Motor-Enabled Joint
  23407. * @param type The type of the joint
  23408. * @param jointData The physica joint data for the joint
  23409. */
  23410. constructor(type: number, jointData: PhysicsJointData);
  23411. /**
  23412. * Set the motor values.
  23413. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23414. * @param force the force to apply
  23415. * @param maxForce max force for this motor.
  23416. */
  23417. setMotor(force?: number, maxForce?: number): void;
  23418. /**
  23419. * Set the motor's limits.
  23420. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23421. * @param upperLimit The upper limit of the motor
  23422. * @param lowerLimit The lower limit of the motor
  23423. */
  23424. setLimit(upperLimit: number, lowerLimit?: number): void;
  23425. }
  23426. /**
  23427. * This class represents a single physics Hinge-Joint
  23428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23429. */
  23430. export class HingeJoint extends MotorEnabledJoint {
  23431. /**
  23432. * Initializes the Hinge-Joint
  23433. * @param jointData The joint data for the Hinge-Joint
  23434. */
  23435. constructor(jointData: PhysicsJointData);
  23436. /**
  23437. * Set the motor values.
  23438. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23439. * @param {number} force the force to apply
  23440. * @param {number} maxForce max force for this motor.
  23441. */
  23442. setMotor(force?: number, maxForce?: number): void;
  23443. /**
  23444. * Set the motor's limits.
  23445. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23446. * @param upperLimit The upper limit of the motor
  23447. * @param lowerLimit The lower limit of the motor
  23448. */
  23449. setLimit(upperLimit: number, lowerLimit?: number): void;
  23450. }
  23451. /**
  23452. * This class represents a dual hinge physics joint (same as wheel joint)
  23453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23454. */
  23455. export class Hinge2Joint extends MotorEnabledJoint {
  23456. /**
  23457. * Initializes the Hinge2-Joint
  23458. * @param jointData The joint data for the Hinge2-Joint
  23459. */
  23460. constructor(jointData: PhysicsJointData);
  23461. /**
  23462. * Set the motor values.
  23463. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23464. * @param {number} targetSpeed the speed the motor is to reach
  23465. * @param {number} maxForce max force for this motor.
  23466. * @param {motorIndex} the motor's index, 0 or 1.
  23467. */
  23468. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23469. /**
  23470. * Set the motor limits.
  23471. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23472. * @param {number} upperLimit the upper limit
  23473. * @param {number} lowerLimit lower limit
  23474. * @param {motorIndex} the motor's index, 0 or 1.
  23475. */
  23476. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23477. }
  23478. /**
  23479. * Interface for a motor enabled joint
  23480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23481. */
  23482. export interface IMotorEnabledJoint {
  23483. /**
  23484. * Physics joint
  23485. */
  23486. physicsJoint: any;
  23487. /**
  23488. * Sets the motor of the motor-enabled joint
  23489. * @param force The force of the motor
  23490. * @param maxForce The maximum force of the motor
  23491. * @param motorIndex The index of the motor
  23492. */
  23493. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23494. /**
  23495. * Sets the limit of the motor
  23496. * @param upperLimit The upper limit of the motor
  23497. * @param lowerLimit The lower limit of the motor
  23498. * @param motorIndex The index of the motor
  23499. */
  23500. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23501. }
  23502. /**
  23503. * Joint data for a Distance-Joint
  23504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23505. */
  23506. export interface DistanceJointData extends PhysicsJointData {
  23507. /**
  23508. * Max distance the 2 joint objects can be apart
  23509. */
  23510. maxDistance: number;
  23511. }
  23512. /**
  23513. * Joint data from a spring joint
  23514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23515. */
  23516. export interface SpringJointData extends PhysicsJointData {
  23517. /**
  23518. * Length of the spring
  23519. */
  23520. length: number;
  23521. /**
  23522. * Stiffness of the spring
  23523. */
  23524. stiffness: number;
  23525. /**
  23526. * Damping of the spring
  23527. */
  23528. damping: number;
  23529. /** this callback will be called when applying the force to the impostors. */
  23530. forceApplicationCallback: () => void;
  23531. }
  23532. }
  23533. declare module BABYLON {
  23534. /**
  23535. * Holds the data for the raycast result
  23536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23537. */
  23538. export class PhysicsRaycastResult {
  23539. private _hasHit;
  23540. private _hitDistance;
  23541. private _hitNormalWorld;
  23542. private _hitPointWorld;
  23543. private _rayFromWorld;
  23544. private _rayToWorld;
  23545. /**
  23546. * Gets if there was a hit
  23547. */
  23548. get hasHit(): boolean;
  23549. /**
  23550. * Gets the distance from the hit
  23551. */
  23552. get hitDistance(): number;
  23553. /**
  23554. * Gets the hit normal/direction in the world
  23555. */
  23556. get hitNormalWorld(): Vector3;
  23557. /**
  23558. * Gets the hit point in the world
  23559. */
  23560. get hitPointWorld(): Vector3;
  23561. /**
  23562. * Gets the ray "start point" of the ray in the world
  23563. */
  23564. get rayFromWorld(): Vector3;
  23565. /**
  23566. * Gets the ray "end point" of the ray in the world
  23567. */
  23568. get rayToWorld(): Vector3;
  23569. /**
  23570. * Sets the hit data (normal & point in world space)
  23571. * @param hitNormalWorld defines the normal in world space
  23572. * @param hitPointWorld defines the point in world space
  23573. */
  23574. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23575. /**
  23576. * Sets the distance from the start point to the hit point
  23577. * @param distance
  23578. */
  23579. setHitDistance(distance: number): void;
  23580. /**
  23581. * Calculates the distance manually
  23582. */
  23583. calculateHitDistance(): void;
  23584. /**
  23585. * Resets all the values to default
  23586. * @param from The from point on world space
  23587. * @param to The to point on world space
  23588. */
  23589. reset(from?: Vector3, to?: Vector3): void;
  23590. }
  23591. /**
  23592. * Interface for the size containing width and height
  23593. */
  23594. interface IXYZ {
  23595. /**
  23596. * X
  23597. */
  23598. x: number;
  23599. /**
  23600. * Y
  23601. */
  23602. y: number;
  23603. /**
  23604. * Z
  23605. */
  23606. z: number;
  23607. }
  23608. }
  23609. declare module BABYLON {
  23610. /**
  23611. * Interface used to describe a physics joint
  23612. */
  23613. export interface PhysicsImpostorJoint {
  23614. /** Defines the main impostor to which the joint is linked */
  23615. mainImpostor: PhysicsImpostor;
  23616. /** Defines the impostor that is connected to the main impostor using this joint */
  23617. connectedImpostor: PhysicsImpostor;
  23618. /** Defines the joint itself */
  23619. joint: PhysicsJoint;
  23620. }
  23621. /** @hidden */
  23622. export interface IPhysicsEnginePlugin {
  23623. world: any;
  23624. name: string;
  23625. setGravity(gravity: Vector3): void;
  23626. setTimeStep(timeStep: number): void;
  23627. getTimeStep(): number;
  23628. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23629. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23630. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23631. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23632. removePhysicsBody(impostor: PhysicsImpostor): void;
  23633. generateJoint(joint: PhysicsImpostorJoint): void;
  23634. removeJoint(joint: PhysicsImpostorJoint): void;
  23635. isSupported(): boolean;
  23636. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23637. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23638. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23639. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23640. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23641. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23642. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23643. getBodyMass(impostor: PhysicsImpostor): number;
  23644. getBodyFriction(impostor: PhysicsImpostor): number;
  23645. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23646. getBodyRestitution(impostor: PhysicsImpostor): number;
  23647. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23648. getBodyPressure?(impostor: PhysicsImpostor): number;
  23649. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23650. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23651. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23652. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23653. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23654. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23655. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23656. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23657. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23658. sleepBody(impostor: PhysicsImpostor): void;
  23659. wakeUpBody(impostor: PhysicsImpostor): void;
  23660. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23661. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23662. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23663. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23664. getRadius(impostor: PhysicsImpostor): number;
  23665. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23666. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23667. dispose(): void;
  23668. }
  23669. /**
  23670. * Interface used to define a physics engine
  23671. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23672. */
  23673. export interface IPhysicsEngine {
  23674. /**
  23675. * Gets the gravity vector used by the simulation
  23676. */
  23677. gravity: Vector3;
  23678. /**
  23679. * Sets the gravity vector used by the simulation
  23680. * @param gravity defines the gravity vector to use
  23681. */
  23682. setGravity(gravity: Vector3): void;
  23683. /**
  23684. * Set the time step of the physics engine.
  23685. * Default is 1/60.
  23686. * To slow it down, enter 1/600 for example.
  23687. * To speed it up, 1/30
  23688. * @param newTimeStep the new timestep to apply to this world.
  23689. */
  23690. setTimeStep(newTimeStep: number): void;
  23691. /**
  23692. * Get the time step of the physics engine.
  23693. * @returns the current time step
  23694. */
  23695. getTimeStep(): number;
  23696. /**
  23697. * Set the sub time step of the physics engine.
  23698. * Default is 0 meaning there is no sub steps
  23699. * To increase physics resolution precision, set a small value (like 1 ms)
  23700. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23701. */
  23702. setSubTimeStep(subTimeStep: number): void;
  23703. /**
  23704. * Get the sub time step of the physics engine.
  23705. * @returns the current sub time step
  23706. */
  23707. getSubTimeStep(): number;
  23708. /**
  23709. * Release all resources
  23710. */
  23711. dispose(): void;
  23712. /**
  23713. * Gets the name of the current physics plugin
  23714. * @returns the name of the plugin
  23715. */
  23716. getPhysicsPluginName(): string;
  23717. /**
  23718. * Adding a new impostor for the impostor tracking.
  23719. * This will be done by the impostor itself.
  23720. * @param impostor the impostor to add
  23721. */
  23722. addImpostor(impostor: PhysicsImpostor): void;
  23723. /**
  23724. * Remove an impostor from the engine.
  23725. * This impostor and its mesh will not longer be updated by the physics engine.
  23726. * @param impostor the impostor to remove
  23727. */
  23728. removeImpostor(impostor: PhysicsImpostor): void;
  23729. /**
  23730. * Add a joint to the physics engine
  23731. * @param mainImpostor defines the main impostor to which the joint is added.
  23732. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23733. * @param joint defines the joint that will connect both impostors.
  23734. */
  23735. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23736. /**
  23737. * Removes a joint from the simulation
  23738. * @param mainImpostor defines the impostor used with the joint
  23739. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23740. * @param joint defines the joint to remove
  23741. */
  23742. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23743. /**
  23744. * Gets the current plugin used to run the simulation
  23745. * @returns current plugin
  23746. */
  23747. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23748. /**
  23749. * Gets the list of physic impostors
  23750. * @returns an array of PhysicsImpostor
  23751. */
  23752. getImpostors(): Array<PhysicsImpostor>;
  23753. /**
  23754. * Gets the impostor for a physics enabled object
  23755. * @param object defines the object impersonated by the impostor
  23756. * @returns the PhysicsImpostor or null if not found
  23757. */
  23758. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23759. /**
  23760. * Gets the impostor for a physics body object
  23761. * @param body defines physics body used by the impostor
  23762. * @returns the PhysicsImpostor or null if not found
  23763. */
  23764. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23765. /**
  23766. * Does a raycast in the physics world
  23767. * @param from when should the ray start?
  23768. * @param to when should the ray end?
  23769. * @returns PhysicsRaycastResult
  23770. */
  23771. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23772. /**
  23773. * Called by the scene. No need to call it.
  23774. * @param delta defines the timespam between frames
  23775. */
  23776. _step(delta: number): void;
  23777. }
  23778. }
  23779. declare module BABYLON {
  23780. /**
  23781. * The interface for the physics imposter parameters
  23782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23783. */
  23784. export interface PhysicsImpostorParameters {
  23785. /**
  23786. * The mass of the physics imposter
  23787. */
  23788. mass: number;
  23789. /**
  23790. * The friction of the physics imposter
  23791. */
  23792. friction?: number;
  23793. /**
  23794. * The coefficient of restitution of the physics imposter
  23795. */
  23796. restitution?: number;
  23797. /**
  23798. * The native options of the physics imposter
  23799. */
  23800. nativeOptions?: any;
  23801. /**
  23802. * Specifies if the parent should be ignored
  23803. */
  23804. ignoreParent?: boolean;
  23805. /**
  23806. * Specifies if bi-directional transformations should be disabled
  23807. */
  23808. disableBidirectionalTransformation?: boolean;
  23809. /**
  23810. * The pressure inside the physics imposter, soft object only
  23811. */
  23812. pressure?: number;
  23813. /**
  23814. * The stiffness the physics imposter, soft object only
  23815. */
  23816. stiffness?: number;
  23817. /**
  23818. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23819. */
  23820. velocityIterations?: number;
  23821. /**
  23822. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23823. */
  23824. positionIterations?: number;
  23825. /**
  23826. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23827. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23828. * Add to fix multiple points
  23829. */
  23830. fixedPoints?: number;
  23831. /**
  23832. * The collision margin around a soft object
  23833. */
  23834. margin?: number;
  23835. /**
  23836. * The collision margin around a soft object
  23837. */
  23838. damping?: number;
  23839. /**
  23840. * The path for a rope based on an extrusion
  23841. */
  23842. path?: any;
  23843. /**
  23844. * The shape of an extrusion used for a rope based on an extrusion
  23845. */
  23846. shape?: any;
  23847. }
  23848. /**
  23849. * Interface for a physics-enabled object
  23850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23851. */
  23852. export interface IPhysicsEnabledObject {
  23853. /**
  23854. * The position of the physics-enabled object
  23855. */
  23856. position: Vector3;
  23857. /**
  23858. * The rotation of the physics-enabled object
  23859. */
  23860. rotationQuaternion: Nullable<Quaternion>;
  23861. /**
  23862. * The scale of the physics-enabled object
  23863. */
  23864. scaling: Vector3;
  23865. /**
  23866. * The rotation of the physics-enabled object
  23867. */
  23868. rotation?: Vector3;
  23869. /**
  23870. * The parent of the physics-enabled object
  23871. */
  23872. parent?: any;
  23873. /**
  23874. * The bounding info of the physics-enabled object
  23875. * @returns The bounding info of the physics-enabled object
  23876. */
  23877. getBoundingInfo(): BoundingInfo;
  23878. /**
  23879. * Computes the world matrix
  23880. * @param force Specifies if the world matrix should be computed by force
  23881. * @returns A world matrix
  23882. */
  23883. computeWorldMatrix(force: boolean): Matrix;
  23884. /**
  23885. * Gets the world matrix
  23886. * @returns A world matrix
  23887. */
  23888. getWorldMatrix?(): Matrix;
  23889. /**
  23890. * Gets the child meshes
  23891. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23892. * @returns An array of abstract meshes
  23893. */
  23894. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23895. /**
  23896. * Gets the vertex data
  23897. * @param kind The type of vertex data
  23898. * @returns A nullable array of numbers, or a float32 array
  23899. */
  23900. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23901. /**
  23902. * Gets the indices from the mesh
  23903. * @returns A nullable array of index arrays
  23904. */
  23905. getIndices?(): Nullable<IndicesArray>;
  23906. /**
  23907. * Gets the scene from the mesh
  23908. * @returns the indices array or null
  23909. */
  23910. getScene?(): Scene;
  23911. /**
  23912. * Gets the absolute position from the mesh
  23913. * @returns the absolute position
  23914. */
  23915. getAbsolutePosition(): Vector3;
  23916. /**
  23917. * Gets the absolute pivot point from the mesh
  23918. * @returns the absolute pivot point
  23919. */
  23920. getAbsolutePivotPoint(): Vector3;
  23921. /**
  23922. * Rotates the mesh
  23923. * @param axis The axis of rotation
  23924. * @param amount The amount of rotation
  23925. * @param space The space of the rotation
  23926. * @returns The rotation transform node
  23927. */
  23928. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23929. /**
  23930. * Translates the mesh
  23931. * @param axis The axis of translation
  23932. * @param distance The distance of translation
  23933. * @param space The space of the translation
  23934. * @returns The transform node
  23935. */
  23936. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23937. /**
  23938. * Sets the absolute position of the mesh
  23939. * @param absolutePosition The absolute position of the mesh
  23940. * @returns The transform node
  23941. */
  23942. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23943. /**
  23944. * Gets the class name of the mesh
  23945. * @returns The class name
  23946. */
  23947. getClassName(): string;
  23948. }
  23949. /**
  23950. * Represents a physics imposter
  23951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23952. */
  23953. export class PhysicsImpostor {
  23954. /**
  23955. * The physics-enabled object used as the physics imposter
  23956. */
  23957. object: IPhysicsEnabledObject;
  23958. /**
  23959. * The type of the physics imposter
  23960. */
  23961. type: number;
  23962. private _options;
  23963. private _scene?;
  23964. /**
  23965. * The default object size of the imposter
  23966. */
  23967. static DEFAULT_OBJECT_SIZE: Vector3;
  23968. /**
  23969. * The identity quaternion of the imposter
  23970. */
  23971. static IDENTITY_QUATERNION: Quaternion;
  23972. /** @hidden */
  23973. _pluginData: any;
  23974. private _physicsEngine;
  23975. private _physicsBody;
  23976. private _bodyUpdateRequired;
  23977. private _onBeforePhysicsStepCallbacks;
  23978. private _onAfterPhysicsStepCallbacks;
  23979. /** @hidden */
  23980. _onPhysicsCollideCallbacks: Array<{
  23981. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23982. otherImpostors: Array<PhysicsImpostor>;
  23983. }>;
  23984. private _deltaPosition;
  23985. private _deltaRotation;
  23986. private _deltaRotationConjugated;
  23987. /** @hidden */
  23988. _isFromLine: boolean;
  23989. private _parent;
  23990. private _isDisposed;
  23991. private static _tmpVecs;
  23992. private static _tmpQuat;
  23993. /**
  23994. * Specifies if the physics imposter is disposed
  23995. */
  23996. get isDisposed(): boolean;
  23997. /**
  23998. * Gets the mass of the physics imposter
  23999. */
  24000. get mass(): number;
  24001. set mass(value: number);
  24002. /**
  24003. * Gets the coefficient of friction
  24004. */
  24005. get friction(): number;
  24006. /**
  24007. * Sets the coefficient of friction
  24008. */
  24009. set friction(value: number);
  24010. /**
  24011. * Gets the coefficient of restitution
  24012. */
  24013. get restitution(): number;
  24014. /**
  24015. * Sets the coefficient of restitution
  24016. */
  24017. set restitution(value: number);
  24018. /**
  24019. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24020. */
  24021. get pressure(): number;
  24022. /**
  24023. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24024. */
  24025. set pressure(value: number);
  24026. /**
  24027. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24028. */
  24029. get stiffness(): number;
  24030. /**
  24031. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24032. */
  24033. set stiffness(value: number);
  24034. /**
  24035. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24036. */
  24037. get velocityIterations(): number;
  24038. /**
  24039. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24040. */
  24041. set velocityIterations(value: number);
  24042. /**
  24043. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24044. */
  24045. get positionIterations(): number;
  24046. /**
  24047. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24048. */
  24049. set positionIterations(value: number);
  24050. /**
  24051. * The unique id of the physics imposter
  24052. * set by the physics engine when adding this impostor to the array
  24053. */
  24054. uniqueId: number;
  24055. /**
  24056. * @hidden
  24057. */
  24058. soft: boolean;
  24059. /**
  24060. * @hidden
  24061. */
  24062. segments: number;
  24063. private _joints;
  24064. /**
  24065. * Initializes the physics imposter
  24066. * @param object The physics-enabled object used as the physics imposter
  24067. * @param type The type of the physics imposter
  24068. * @param _options The options for the physics imposter
  24069. * @param _scene The Babylon scene
  24070. */
  24071. constructor(
  24072. /**
  24073. * The physics-enabled object used as the physics imposter
  24074. */
  24075. object: IPhysicsEnabledObject,
  24076. /**
  24077. * The type of the physics imposter
  24078. */
  24079. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24080. /**
  24081. * This function will completly initialize this impostor.
  24082. * It will create a new body - but only if this mesh has no parent.
  24083. * If it has, this impostor will not be used other than to define the impostor
  24084. * of the child mesh.
  24085. * @hidden
  24086. */
  24087. _init(): void;
  24088. private _getPhysicsParent;
  24089. /**
  24090. * Should a new body be generated.
  24091. * @returns boolean specifying if body initialization is required
  24092. */
  24093. isBodyInitRequired(): boolean;
  24094. /**
  24095. * Sets the updated scaling
  24096. * @param updated Specifies if the scaling is updated
  24097. */
  24098. setScalingUpdated(): void;
  24099. /**
  24100. * Force a regeneration of this or the parent's impostor's body.
  24101. * Use under cautious - This will remove all joints already implemented.
  24102. */
  24103. forceUpdate(): void;
  24104. /**
  24105. * Gets the body that holds this impostor. Either its own, or its parent.
  24106. */
  24107. get physicsBody(): any;
  24108. /**
  24109. * Get the parent of the physics imposter
  24110. * @returns Physics imposter or null
  24111. */
  24112. get parent(): Nullable<PhysicsImpostor>;
  24113. /**
  24114. * Sets the parent of the physics imposter
  24115. */
  24116. set parent(value: Nullable<PhysicsImpostor>);
  24117. /**
  24118. * Set the physics body. Used mainly by the physics engine/plugin
  24119. */
  24120. set physicsBody(physicsBody: any);
  24121. /**
  24122. * Resets the update flags
  24123. */
  24124. resetUpdateFlags(): void;
  24125. /**
  24126. * Gets the object extend size
  24127. * @returns the object extend size
  24128. */
  24129. getObjectExtendSize(): Vector3;
  24130. /**
  24131. * Gets the object center
  24132. * @returns The object center
  24133. */
  24134. getObjectCenter(): Vector3;
  24135. /**
  24136. * Get a specific parameter from the options parameters
  24137. * @param paramName The object parameter name
  24138. * @returns The object parameter
  24139. */
  24140. getParam(paramName: string): any;
  24141. /**
  24142. * Sets a specific parameter in the options given to the physics plugin
  24143. * @param paramName The parameter name
  24144. * @param value The value of the parameter
  24145. */
  24146. setParam(paramName: string, value: number): void;
  24147. /**
  24148. * Specifically change the body's mass option. Won't recreate the physics body object
  24149. * @param mass The mass of the physics imposter
  24150. */
  24151. setMass(mass: number): void;
  24152. /**
  24153. * Gets the linear velocity
  24154. * @returns linear velocity or null
  24155. */
  24156. getLinearVelocity(): Nullable<Vector3>;
  24157. /**
  24158. * Sets the linear velocity
  24159. * @param velocity linear velocity or null
  24160. */
  24161. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24162. /**
  24163. * Gets the angular velocity
  24164. * @returns angular velocity or null
  24165. */
  24166. getAngularVelocity(): Nullable<Vector3>;
  24167. /**
  24168. * Sets the angular velocity
  24169. * @param velocity The velocity or null
  24170. */
  24171. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24172. /**
  24173. * Execute a function with the physics plugin native code
  24174. * Provide a function the will have two variables - the world object and the physics body object
  24175. * @param func The function to execute with the physics plugin native code
  24176. */
  24177. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24178. /**
  24179. * Register a function that will be executed before the physics world is stepping forward
  24180. * @param func The function to execute before the physics world is stepped forward
  24181. */
  24182. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24183. /**
  24184. * Unregister a function that will be executed before the physics world is stepping forward
  24185. * @param func The function to execute before the physics world is stepped forward
  24186. */
  24187. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24188. /**
  24189. * Register a function that will be executed after the physics step
  24190. * @param func The function to execute after physics step
  24191. */
  24192. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24193. /**
  24194. * Unregisters a function that will be executed after the physics step
  24195. * @param func The function to execute after physics step
  24196. */
  24197. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24198. /**
  24199. * register a function that will be executed when this impostor collides against a different body
  24200. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24201. * @param func Callback that is executed on collision
  24202. */
  24203. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24204. /**
  24205. * Unregisters the physics imposter on contact
  24206. * @param collideAgainst The physics object to collide against
  24207. * @param func Callback to execute on collision
  24208. */
  24209. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24210. private _tmpQuat;
  24211. private _tmpQuat2;
  24212. /**
  24213. * Get the parent rotation
  24214. * @returns The parent rotation
  24215. */
  24216. getParentsRotation(): Quaternion;
  24217. /**
  24218. * this function is executed by the physics engine.
  24219. */
  24220. beforeStep: () => void;
  24221. /**
  24222. * this function is executed by the physics engine
  24223. */
  24224. afterStep: () => void;
  24225. /**
  24226. * Legacy collision detection event support
  24227. */
  24228. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24229. /**
  24230. * event and body object due to cannon's event-based architecture.
  24231. */
  24232. onCollide: (e: {
  24233. body: any;
  24234. }) => void;
  24235. /**
  24236. * Apply a force
  24237. * @param force The force to apply
  24238. * @param contactPoint The contact point for the force
  24239. * @returns The physics imposter
  24240. */
  24241. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24242. /**
  24243. * Apply an impulse
  24244. * @param force The impulse force
  24245. * @param contactPoint The contact point for the impulse force
  24246. * @returns The physics imposter
  24247. */
  24248. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24249. /**
  24250. * A help function to create a joint
  24251. * @param otherImpostor A physics imposter used to create a joint
  24252. * @param jointType The type of joint
  24253. * @param jointData The data for the joint
  24254. * @returns The physics imposter
  24255. */
  24256. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24257. /**
  24258. * Add a joint to this impostor with a different impostor
  24259. * @param otherImpostor A physics imposter used to add a joint
  24260. * @param joint The joint to add
  24261. * @returns The physics imposter
  24262. */
  24263. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24264. /**
  24265. * Add an anchor to a cloth impostor
  24266. * @param otherImpostor rigid impostor to anchor to
  24267. * @param width ratio across width from 0 to 1
  24268. * @param height ratio up height from 0 to 1
  24269. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24270. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24271. * @returns impostor the soft imposter
  24272. */
  24273. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24274. /**
  24275. * Add a hook to a rope impostor
  24276. * @param otherImpostor rigid impostor to anchor to
  24277. * @param length ratio across rope from 0 to 1
  24278. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24279. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24280. * @returns impostor the rope imposter
  24281. */
  24282. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24283. /**
  24284. * Will keep this body still, in a sleep mode.
  24285. * @returns the physics imposter
  24286. */
  24287. sleep(): PhysicsImpostor;
  24288. /**
  24289. * Wake the body up.
  24290. * @returns The physics imposter
  24291. */
  24292. wakeUp(): PhysicsImpostor;
  24293. /**
  24294. * Clones the physics imposter
  24295. * @param newObject The physics imposter clones to this physics-enabled object
  24296. * @returns A nullable physics imposter
  24297. */
  24298. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24299. /**
  24300. * Disposes the physics imposter
  24301. */
  24302. dispose(): void;
  24303. /**
  24304. * Sets the delta position
  24305. * @param position The delta position amount
  24306. */
  24307. setDeltaPosition(position: Vector3): void;
  24308. /**
  24309. * Sets the delta rotation
  24310. * @param rotation The delta rotation amount
  24311. */
  24312. setDeltaRotation(rotation: Quaternion): void;
  24313. /**
  24314. * Gets the box size of the physics imposter and stores the result in the input parameter
  24315. * @param result Stores the box size
  24316. * @returns The physics imposter
  24317. */
  24318. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24319. /**
  24320. * Gets the radius of the physics imposter
  24321. * @returns Radius of the physics imposter
  24322. */
  24323. getRadius(): number;
  24324. /**
  24325. * Sync a bone with this impostor
  24326. * @param bone The bone to sync to the impostor.
  24327. * @param boneMesh The mesh that the bone is influencing.
  24328. * @param jointPivot The pivot of the joint / bone in local space.
  24329. * @param distToJoint Optional distance from the impostor to the joint.
  24330. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24331. */
  24332. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24333. /**
  24334. * Sync impostor to a bone
  24335. * @param bone The bone that the impostor will be synced to.
  24336. * @param boneMesh The mesh that the bone is influencing.
  24337. * @param jointPivot The pivot of the joint / bone in local space.
  24338. * @param distToJoint Optional distance from the impostor to the joint.
  24339. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24340. * @param boneAxis Optional vector3 axis the bone is aligned with
  24341. */
  24342. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24343. /**
  24344. * No-Imposter type
  24345. */
  24346. static NoImpostor: number;
  24347. /**
  24348. * Sphere-Imposter type
  24349. */
  24350. static SphereImpostor: number;
  24351. /**
  24352. * Box-Imposter type
  24353. */
  24354. static BoxImpostor: number;
  24355. /**
  24356. * Plane-Imposter type
  24357. */
  24358. static PlaneImpostor: number;
  24359. /**
  24360. * Mesh-imposter type
  24361. */
  24362. static MeshImpostor: number;
  24363. /**
  24364. * Capsule-Impostor type (Ammo.js plugin only)
  24365. */
  24366. static CapsuleImpostor: number;
  24367. /**
  24368. * Cylinder-Imposter type
  24369. */
  24370. static CylinderImpostor: number;
  24371. /**
  24372. * Particle-Imposter type
  24373. */
  24374. static ParticleImpostor: number;
  24375. /**
  24376. * Heightmap-Imposter type
  24377. */
  24378. static HeightmapImpostor: number;
  24379. /**
  24380. * ConvexHull-Impostor type (Ammo.js plugin only)
  24381. */
  24382. static ConvexHullImpostor: number;
  24383. /**
  24384. * Custom-Imposter type (Ammo.js plugin only)
  24385. */
  24386. static CustomImpostor: number;
  24387. /**
  24388. * Rope-Imposter type
  24389. */
  24390. static RopeImpostor: number;
  24391. /**
  24392. * Cloth-Imposter type
  24393. */
  24394. static ClothImpostor: number;
  24395. /**
  24396. * Softbody-Imposter type
  24397. */
  24398. static SoftbodyImpostor: number;
  24399. }
  24400. }
  24401. declare module BABYLON {
  24402. /**
  24403. * @hidden
  24404. **/
  24405. export class _CreationDataStorage {
  24406. closePath?: boolean;
  24407. closeArray?: boolean;
  24408. idx: number[];
  24409. dashSize: number;
  24410. gapSize: number;
  24411. path3D: Path3D;
  24412. pathArray: Vector3[][];
  24413. arc: number;
  24414. radius: number;
  24415. cap: number;
  24416. tessellation: number;
  24417. }
  24418. /**
  24419. * @hidden
  24420. **/
  24421. class _InstanceDataStorage {
  24422. visibleInstances: any;
  24423. batchCache: _InstancesBatch;
  24424. instancesBufferSize: number;
  24425. instancesBuffer: Nullable<Buffer>;
  24426. instancesData: Float32Array;
  24427. overridenInstanceCount: number;
  24428. isFrozen: boolean;
  24429. previousBatch: Nullable<_InstancesBatch>;
  24430. hardwareInstancedRendering: boolean;
  24431. sideOrientation: number;
  24432. manualUpdate: boolean;
  24433. }
  24434. /**
  24435. * @hidden
  24436. **/
  24437. export class _InstancesBatch {
  24438. mustReturn: boolean;
  24439. visibleInstances: Nullable<InstancedMesh[]>[];
  24440. renderSelf: boolean[];
  24441. hardwareInstancedRendering: boolean[];
  24442. }
  24443. /**
  24444. * Class used to represent renderable models
  24445. */
  24446. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24447. /**
  24448. * Mesh side orientation : usually the external or front surface
  24449. */
  24450. static readonly FRONTSIDE: number;
  24451. /**
  24452. * Mesh side orientation : usually the internal or back surface
  24453. */
  24454. static readonly BACKSIDE: number;
  24455. /**
  24456. * Mesh side orientation : both internal and external or front and back surfaces
  24457. */
  24458. static readonly DOUBLESIDE: number;
  24459. /**
  24460. * Mesh side orientation : by default, `FRONTSIDE`
  24461. */
  24462. static readonly DEFAULTSIDE: number;
  24463. /**
  24464. * Mesh cap setting : no cap
  24465. */
  24466. static readonly NO_CAP: number;
  24467. /**
  24468. * Mesh cap setting : one cap at the beginning of the mesh
  24469. */
  24470. static readonly CAP_START: number;
  24471. /**
  24472. * Mesh cap setting : one cap at the end of the mesh
  24473. */
  24474. static readonly CAP_END: number;
  24475. /**
  24476. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24477. */
  24478. static readonly CAP_ALL: number;
  24479. /**
  24480. * Mesh pattern setting : no flip or rotate
  24481. */
  24482. static readonly NO_FLIP: number;
  24483. /**
  24484. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24485. */
  24486. static readonly FLIP_TILE: number;
  24487. /**
  24488. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24489. */
  24490. static readonly ROTATE_TILE: number;
  24491. /**
  24492. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24493. */
  24494. static readonly FLIP_ROW: number;
  24495. /**
  24496. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24497. */
  24498. static readonly ROTATE_ROW: number;
  24499. /**
  24500. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24501. */
  24502. static readonly FLIP_N_ROTATE_TILE: number;
  24503. /**
  24504. * Mesh pattern setting : rotate pattern and rotate
  24505. */
  24506. static readonly FLIP_N_ROTATE_ROW: number;
  24507. /**
  24508. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24509. */
  24510. static readonly CENTER: number;
  24511. /**
  24512. * Mesh tile positioning : part tiles on left
  24513. */
  24514. static readonly LEFT: number;
  24515. /**
  24516. * Mesh tile positioning : part tiles on right
  24517. */
  24518. static readonly RIGHT: number;
  24519. /**
  24520. * Mesh tile positioning : part tiles on top
  24521. */
  24522. static readonly TOP: number;
  24523. /**
  24524. * Mesh tile positioning : part tiles on bottom
  24525. */
  24526. static readonly BOTTOM: number;
  24527. /**
  24528. * Gets the default side orientation.
  24529. * @param orientation the orientation to value to attempt to get
  24530. * @returns the default orientation
  24531. * @hidden
  24532. */
  24533. static _GetDefaultSideOrientation(orientation?: number): number;
  24534. private _internalMeshDataInfo;
  24535. /**
  24536. * An event triggered before rendering the mesh
  24537. */
  24538. get onBeforeRenderObservable(): Observable<Mesh>;
  24539. /**
  24540. * An event triggered before binding the mesh
  24541. */
  24542. get onBeforeBindObservable(): Observable<Mesh>;
  24543. /**
  24544. * An event triggered after rendering the mesh
  24545. */
  24546. get onAfterRenderObservable(): Observable<Mesh>;
  24547. /**
  24548. * An event triggered before drawing the mesh
  24549. */
  24550. get onBeforeDrawObservable(): Observable<Mesh>;
  24551. private _onBeforeDrawObserver;
  24552. /**
  24553. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24554. */
  24555. set onBeforeDraw(callback: () => void);
  24556. get hasInstances(): boolean;
  24557. /**
  24558. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24559. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24560. */
  24561. delayLoadState: number;
  24562. /**
  24563. * Gets the list of instances created from this mesh
  24564. * it is not supposed to be modified manually.
  24565. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24566. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24567. */
  24568. instances: InstancedMesh[];
  24569. /**
  24570. * Gets the file containing delay loading data for this mesh
  24571. */
  24572. delayLoadingFile: string;
  24573. /** @hidden */
  24574. _binaryInfo: any;
  24575. /**
  24576. * User defined function used to change how LOD level selection is done
  24577. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24578. */
  24579. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24580. /**
  24581. * Gets or sets the morph target manager
  24582. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24583. */
  24584. get morphTargetManager(): Nullable<MorphTargetManager>;
  24585. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24586. /** @hidden */
  24587. _creationDataStorage: Nullable<_CreationDataStorage>;
  24588. /** @hidden */
  24589. _geometry: Nullable<Geometry>;
  24590. /** @hidden */
  24591. _delayInfo: Array<string>;
  24592. /** @hidden */
  24593. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24594. /** @hidden */
  24595. _instanceDataStorage: _InstanceDataStorage;
  24596. private _effectiveMaterial;
  24597. /** @hidden */
  24598. _shouldGenerateFlatShading: boolean;
  24599. /** @hidden */
  24600. _originalBuilderSideOrientation: number;
  24601. /**
  24602. * Use this property to change the original side orientation defined at construction time
  24603. */
  24604. overrideMaterialSideOrientation: Nullable<number>;
  24605. /**
  24606. * Gets the source mesh (the one used to clone this one from)
  24607. */
  24608. get source(): Nullable<Mesh>;
  24609. /**
  24610. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24611. */
  24612. get isUnIndexed(): boolean;
  24613. set isUnIndexed(value: boolean);
  24614. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24615. get worldMatrixInstancedBuffer(): Float32Array;
  24616. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24617. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24618. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24619. /**
  24620. * @constructor
  24621. * @param name The value used by scene.getMeshByName() to do a lookup.
  24622. * @param scene The scene to add this mesh to.
  24623. * @param parent The parent of this mesh, if it has one
  24624. * @param source An optional Mesh from which geometry is shared, cloned.
  24625. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24626. * When false, achieved by calling a clone(), also passing False.
  24627. * This will make creation of children, recursive.
  24628. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24629. */
  24630. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24631. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24632. doNotInstantiate: boolean;
  24633. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24634. /**
  24635. * Gets the class name
  24636. * @returns the string "Mesh".
  24637. */
  24638. getClassName(): string;
  24639. /** @hidden */
  24640. get _isMesh(): boolean;
  24641. /**
  24642. * Returns a description of this mesh
  24643. * @param fullDetails define if full details about this mesh must be used
  24644. * @returns a descriptive string representing this mesh
  24645. */
  24646. toString(fullDetails?: boolean): string;
  24647. /** @hidden */
  24648. _unBindEffect(): void;
  24649. /**
  24650. * Gets a boolean indicating if this mesh has LOD
  24651. */
  24652. get hasLODLevels(): boolean;
  24653. /**
  24654. * Gets the list of MeshLODLevel associated with the current mesh
  24655. * @returns an array of MeshLODLevel
  24656. */
  24657. getLODLevels(): MeshLODLevel[];
  24658. private _sortLODLevels;
  24659. /**
  24660. * Add a mesh as LOD level triggered at the given distance.
  24661. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24662. * @param distance The distance from the center of the object to show this level
  24663. * @param mesh The mesh to be added as LOD level (can be null)
  24664. * @return This mesh (for chaining)
  24665. */
  24666. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24667. /**
  24668. * Returns the LOD level mesh at the passed distance or null if not found.
  24669. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24670. * @param distance The distance from the center of the object to show this level
  24671. * @returns a Mesh or `null`
  24672. */
  24673. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24674. /**
  24675. * Remove a mesh from the LOD array
  24676. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24677. * @param mesh defines the mesh to be removed
  24678. * @return This mesh (for chaining)
  24679. */
  24680. removeLODLevel(mesh: Mesh): Mesh;
  24681. /**
  24682. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24683. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24684. * @param camera defines the camera to use to compute distance
  24685. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24686. * @return This mesh (for chaining)
  24687. */
  24688. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24689. /**
  24690. * Gets the mesh internal Geometry object
  24691. */
  24692. get geometry(): Nullable<Geometry>;
  24693. /**
  24694. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24695. * @returns the total number of vertices
  24696. */
  24697. getTotalVertices(): number;
  24698. /**
  24699. * Returns the content of an associated vertex buffer
  24700. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24701. * - VertexBuffer.PositionKind
  24702. * - VertexBuffer.UVKind
  24703. * - VertexBuffer.UV2Kind
  24704. * - VertexBuffer.UV3Kind
  24705. * - VertexBuffer.UV4Kind
  24706. * - VertexBuffer.UV5Kind
  24707. * - VertexBuffer.UV6Kind
  24708. * - VertexBuffer.ColorKind
  24709. * - VertexBuffer.MatricesIndicesKind
  24710. * - VertexBuffer.MatricesIndicesExtraKind
  24711. * - VertexBuffer.MatricesWeightsKind
  24712. * - VertexBuffer.MatricesWeightsExtraKind
  24713. * @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
  24714. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24715. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24716. */
  24717. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24718. /**
  24719. * Returns the mesh VertexBuffer object from the requested `kind`
  24720. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24721. * - VertexBuffer.PositionKind
  24722. * - VertexBuffer.NormalKind
  24723. * - VertexBuffer.UVKind
  24724. * - VertexBuffer.UV2Kind
  24725. * - VertexBuffer.UV3Kind
  24726. * - VertexBuffer.UV4Kind
  24727. * - VertexBuffer.UV5Kind
  24728. * - VertexBuffer.UV6Kind
  24729. * - VertexBuffer.ColorKind
  24730. * - VertexBuffer.MatricesIndicesKind
  24731. * - VertexBuffer.MatricesIndicesExtraKind
  24732. * - VertexBuffer.MatricesWeightsKind
  24733. * - VertexBuffer.MatricesWeightsExtraKind
  24734. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24735. */
  24736. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24737. /**
  24738. * Tests if a specific vertex buffer is associated with this mesh
  24739. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24740. * - VertexBuffer.PositionKind
  24741. * - VertexBuffer.NormalKind
  24742. * - VertexBuffer.UVKind
  24743. * - VertexBuffer.UV2Kind
  24744. * - VertexBuffer.UV3Kind
  24745. * - VertexBuffer.UV4Kind
  24746. * - VertexBuffer.UV5Kind
  24747. * - VertexBuffer.UV6Kind
  24748. * - VertexBuffer.ColorKind
  24749. * - VertexBuffer.MatricesIndicesKind
  24750. * - VertexBuffer.MatricesIndicesExtraKind
  24751. * - VertexBuffer.MatricesWeightsKind
  24752. * - VertexBuffer.MatricesWeightsExtraKind
  24753. * @returns a boolean
  24754. */
  24755. isVerticesDataPresent(kind: string): boolean;
  24756. /**
  24757. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24758. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24759. * - VertexBuffer.PositionKind
  24760. * - VertexBuffer.UVKind
  24761. * - VertexBuffer.UV2Kind
  24762. * - VertexBuffer.UV3Kind
  24763. * - VertexBuffer.UV4Kind
  24764. * - VertexBuffer.UV5Kind
  24765. * - VertexBuffer.UV6Kind
  24766. * - VertexBuffer.ColorKind
  24767. * - VertexBuffer.MatricesIndicesKind
  24768. * - VertexBuffer.MatricesIndicesExtraKind
  24769. * - VertexBuffer.MatricesWeightsKind
  24770. * - VertexBuffer.MatricesWeightsExtraKind
  24771. * @returns a boolean
  24772. */
  24773. isVertexBufferUpdatable(kind: string): boolean;
  24774. /**
  24775. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24776. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24777. * - VertexBuffer.PositionKind
  24778. * - VertexBuffer.NormalKind
  24779. * - VertexBuffer.UVKind
  24780. * - VertexBuffer.UV2Kind
  24781. * - VertexBuffer.UV3Kind
  24782. * - VertexBuffer.UV4Kind
  24783. * - VertexBuffer.UV5Kind
  24784. * - VertexBuffer.UV6Kind
  24785. * - VertexBuffer.ColorKind
  24786. * - VertexBuffer.MatricesIndicesKind
  24787. * - VertexBuffer.MatricesIndicesExtraKind
  24788. * - VertexBuffer.MatricesWeightsKind
  24789. * - VertexBuffer.MatricesWeightsExtraKind
  24790. * @returns an array of strings
  24791. */
  24792. getVerticesDataKinds(): string[];
  24793. /**
  24794. * Returns a positive integer : the total number of indices in this mesh geometry.
  24795. * @returns the numner of indices or zero if the mesh has no geometry.
  24796. */
  24797. getTotalIndices(): number;
  24798. /**
  24799. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24800. * @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.
  24801. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24802. * @returns the indices array or an empty array if the mesh has no geometry
  24803. */
  24804. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24805. get isBlocked(): boolean;
  24806. /**
  24807. * Determine if the current mesh is ready to be rendered
  24808. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24809. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24810. * @returns true if all associated assets are ready (material, textures, shaders)
  24811. */
  24812. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24813. /**
  24814. * 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.
  24815. */
  24816. get areNormalsFrozen(): boolean;
  24817. /**
  24818. * 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.
  24819. * @returns the current mesh
  24820. */
  24821. freezeNormals(): Mesh;
  24822. /**
  24823. * 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
  24824. * @returns the current mesh
  24825. */
  24826. unfreezeNormals(): Mesh;
  24827. /**
  24828. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24829. */
  24830. set overridenInstanceCount(count: number);
  24831. /** @hidden */
  24832. _preActivate(): Mesh;
  24833. /** @hidden */
  24834. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24835. /** @hidden */
  24836. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24837. /**
  24838. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24839. * This means the mesh underlying bounding box and sphere are recomputed.
  24840. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24841. * @returns the current mesh
  24842. */
  24843. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24844. /** @hidden */
  24845. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24846. /**
  24847. * This function will subdivide the mesh into multiple submeshes
  24848. * @param count defines the expected number of submeshes
  24849. */
  24850. subdivide(count: number): void;
  24851. /**
  24852. * Copy a FloatArray into a specific associated vertex buffer
  24853. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24854. * - VertexBuffer.PositionKind
  24855. * - VertexBuffer.UVKind
  24856. * - VertexBuffer.UV2Kind
  24857. * - VertexBuffer.UV3Kind
  24858. * - VertexBuffer.UV4Kind
  24859. * - VertexBuffer.UV5Kind
  24860. * - VertexBuffer.UV6Kind
  24861. * - VertexBuffer.ColorKind
  24862. * - VertexBuffer.MatricesIndicesKind
  24863. * - VertexBuffer.MatricesIndicesExtraKind
  24864. * - VertexBuffer.MatricesWeightsKind
  24865. * - VertexBuffer.MatricesWeightsExtraKind
  24866. * @param data defines the data source
  24867. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24868. * @param stride defines the data stride size (can be null)
  24869. * @returns the current mesh
  24870. */
  24871. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24872. /**
  24873. * Delete a vertex buffer associated with this mesh
  24874. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24875. * - VertexBuffer.PositionKind
  24876. * - VertexBuffer.UVKind
  24877. * - VertexBuffer.UV2Kind
  24878. * - VertexBuffer.UV3Kind
  24879. * - VertexBuffer.UV4Kind
  24880. * - VertexBuffer.UV5Kind
  24881. * - VertexBuffer.UV6Kind
  24882. * - VertexBuffer.ColorKind
  24883. * - VertexBuffer.MatricesIndicesKind
  24884. * - VertexBuffer.MatricesIndicesExtraKind
  24885. * - VertexBuffer.MatricesWeightsKind
  24886. * - VertexBuffer.MatricesWeightsExtraKind
  24887. */
  24888. removeVerticesData(kind: string): void;
  24889. /**
  24890. * Flags an associated vertex buffer as updatable
  24891. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24892. * - VertexBuffer.PositionKind
  24893. * - VertexBuffer.UVKind
  24894. * - VertexBuffer.UV2Kind
  24895. * - VertexBuffer.UV3Kind
  24896. * - VertexBuffer.UV4Kind
  24897. * - VertexBuffer.UV5Kind
  24898. * - VertexBuffer.UV6Kind
  24899. * - VertexBuffer.ColorKind
  24900. * - VertexBuffer.MatricesIndicesKind
  24901. * - VertexBuffer.MatricesIndicesExtraKind
  24902. * - VertexBuffer.MatricesWeightsKind
  24903. * - VertexBuffer.MatricesWeightsExtraKind
  24904. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24905. */
  24906. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24907. /**
  24908. * Sets the mesh global Vertex Buffer
  24909. * @param buffer defines the buffer to use
  24910. * @returns the current mesh
  24911. */
  24912. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24913. /**
  24914. * Update a specific associated vertex buffer
  24915. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24916. * - VertexBuffer.PositionKind
  24917. * - VertexBuffer.UVKind
  24918. * - VertexBuffer.UV2Kind
  24919. * - VertexBuffer.UV3Kind
  24920. * - VertexBuffer.UV4Kind
  24921. * - VertexBuffer.UV5Kind
  24922. * - VertexBuffer.UV6Kind
  24923. * - VertexBuffer.ColorKind
  24924. * - VertexBuffer.MatricesIndicesKind
  24925. * - VertexBuffer.MatricesIndicesExtraKind
  24926. * - VertexBuffer.MatricesWeightsKind
  24927. * - VertexBuffer.MatricesWeightsExtraKind
  24928. * @param data defines the data source
  24929. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24930. * @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)
  24931. * @returns the current mesh
  24932. */
  24933. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24934. /**
  24935. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24936. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24937. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24938. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24939. * @returns the current mesh
  24940. */
  24941. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24942. /**
  24943. * Creates a un-shared specific occurence of the geometry for the mesh.
  24944. * @returns the current mesh
  24945. */
  24946. makeGeometryUnique(): Mesh;
  24947. /**
  24948. * Set the index buffer of this mesh
  24949. * @param indices defines the source data
  24950. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24951. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24952. * @returns the current mesh
  24953. */
  24954. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24955. /**
  24956. * Update the current index buffer
  24957. * @param indices defines the source data
  24958. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24959. * @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)
  24960. * @returns the current mesh
  24961. */
  24962. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24963. /**
  24964. * Invert the geometry to move from a right handed system to a left handed one.
  24965. * @returns the current mesh
  24966. */
  24967. toLeftHanded(): Mesh;
  24968. /** @hidden */
  24969. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24970. /** @hidden */
  24971. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24972. /**
  24973. * Registers for this mesh a javascript function called just before the rendering process
  24974. * @param func defines the function to call before rendering this mesh
  24975. * @returns the current mesh
  24976. */
  24977. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24978. /**
  24979. * Disposes a previously registered javascript function called before the rendering
  24980. * @param func defines the function to remove
  24981. * @returns the current mesh
  24982. */
  24983. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24984. /**
  24985. * Registers for this mesh a javascript function called just after the rendering is complete
  24986. * @param func defines the function to call after rendering this mesh
  24987. * @returns the current mesh
  24988. */
  24989. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24990. /**
  24991. * Disposes a previously registered javascript function called after the rendering.
  24992. * @param func defines the function to remove
  24993. * @returns the current mesh
  24994. */
  24995. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24996. /** @hidden */
  24997. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24998. /** @hidden */
  24999. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25000. /** @hidden */
  25001. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25002. /** @hidden */
  25003. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25004. /** @hidden */
  25005. _rebuild(): void;
  25006. /** @hidden */
  25007. _freeze(): void;
  25008. /** @hidden */
  25009. _unFreeze(): void;
  25010. /**
  25011. * 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
  25012. * @param subMesh defines the subMesh to render
  25013. * @param enableAlphaMode defines if alpha mode can be changed
  25014. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25015. * @returns the current mesh
  25016. */
  25017. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25018. private _onBeforeDraw;
  25019. /**
  25020. * Renormalize the mesh and patch it up if there are no weights
  25021. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25022. * However in the case of zero weights then we set just a single influence to 1.
  25023. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25024. */
  25025. cleanMatrixWeights(): void;
  25026. private normalizeSkinFourWeights;
  25027. private normalizeSkinWeightsAndExtra;
  25028. /**
  25029. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25030. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25031. * the user know there was an issue with importing the mesh
  25032. * @returns a validation object with skinned, valid and report string
  25033. */
  25034. validateSkinning(): {
  25035. skinned: boolean;
  25036. valid: boolean;
  25037. report: string;
  25038. };
  25039. /** @hidden */
  25040. _checkDelayState(): Mesh;
  25041. private _queueLoad;
  25042. /**
  25043. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25044. * A mesh is in the frustum if its bounding box intersects the frustum
  25045. * @param frustumPlanes defines the frustum to test
  25046. * @returns true if the mesh is in the frustum planes
  25047. */
  25048. isInFrustum(frustumPlanes: Plane[]): boolean;
  25049. /**
  25050. * Sets the mesh material by the material or multiMaterial `id` property
  25051. * @param id is a string identifying the material or the multiMaterial
  25052. * @returns the current mesh
  25053. */
  25054. setMaterialByID(id: string): Mesh;
  25055. /**
  25056. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25057. * @returns an array of IAnimatable
  25058. */
  25059. getAnimatables(): IAnimatable[];
  25060. /**
  25061. * Modifies the mesh geometry according to the passed transformation matrix.
  25062. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25063. * The mesh normals are modified using the same transformation.
  25064. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25065. * @param transform defines the transform matrix to use
  25066. * @see http://doc.babylonjs.com/resources/baking_transformations
  25067. * @returns the current mesh
  25068. */
  25069. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25070. /**
  25071. * Modifies the mesh geometry according to its own current World Matrix.
  25072. * The mesh World Matrix is then reset.
  25073. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25074. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25075. * @see http://doc.babylonjs.com/resources/baking_transformations
  25076. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25077. * @returns the current mesh
  25078. */
  25079. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25080. /** @hidden */
  25081. get _positions(): Nullable<Vector3[]>;
  25082. /** @hidden */
  25083. _resetPointsArrayCache(): Mesh;
  25084. /** @hidden */
  25085. _generatePointsArray(): boolean;
  25086. /**
  25087. * Returns a new Mesh object generated from the current mesh properties.
  25088. * This method must not get confused with createInstance()
  25089. * @param name is a string, the name given to the new mesh
  25090. * @param newParent can be any Node object (default `null`)
  25091. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25092. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25093. * @returns a new mesh
  25094. */
  25095. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25096. /**
  25097. * Releases resources associated with this mesh.
  25098. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25099. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25100. */
  25101. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25102. /** @hidden */
  25103. _disposeInstanceSpecificData(): void;
  25104. /**
  25105. * Modifies the mesh geometry according to a displacement map.
  25106. * 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.
  25107. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25108. * @param url is a string, the URL from the image file is to be downloaded.
  25109. * @param minHeight is the lower limit of the displacement.
  25110. * @param maxHeight is the upper limit of the displacement.
  25111. * @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.
  25112. * @param uvOffset is an optional vector2 used to offset UV.
  25113. * @param uvScale is an optional vector2 used to scale UV.
  25114. * @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.
  25115. * @returns the Mesh.
  25116. */
  25117. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25118. /**
  25119. * Modifies the mesh geometry according to a displacementMap buffer.
  25120. * 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.
  25121. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25122. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25123. * @param heightMapWidth is the width of the buffer image.
  25124. * @param heightMapHeight is the height of the buffer image.
  25125. * @param minHeight is the lower limit of the displacement.
  25126. * @param maxHeight is the upper limit of the displacement.
  25127. * @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.
  25128. * @param uvOffset is an optional vector2 used to offset UV.
  25129. * @param uvScale is an optional vector2 used to scale UV.
  25130. * @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.
  25131. * @returns the Mesh.
  25132. */
  25133. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25134. /**
  25135. * Modify the mesh to get a flat shading rendering.
  25136. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25137. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25138. * @returns current mesh
  25139. */
  25140. convertToFlatShadedMesh(): Mesh;
  25141. /**
  25142. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25143. * In other words, more vertices, no more indices and a single bigger VBO.
  25144. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25145. * @returns current mesh
  25146. */
  25147. convertToUnIndexedMesh(): Mesh;
  25148. /**
  25149. * Inverses facet orientations.
  25150. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25151. * @param flipNormals will also inverts the normals
  25152. * @returns current mesh
  25153. */
  25154. flipFaces(flipNormals?: boolean): Mesh;
  25155. /**
  25156. * Increase the number of facets and hence vertices in a mesh
  25157. * Vertex normals are interpolated from existing vertex normals
  25158. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25159. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25160. */
  25161. increaseVertices(numberPerEdge: number): void;
  25162. /**
  25163. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25164. * This will undo any application of covertToFlatShadedMesh
  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. */
  25167. forceSharedVertices(): void;
  25168. /** @hidden */
  25169. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25170. /** @hidden */
  25171. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25172. /**
  25173. * Creates a new InstancedMesh object from the mesh model.
  25174. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25175. * @param name defines the name of the new instance
  25176. * @returns a new InstancedMesh
  25177. */
  25178. createInstance(name: string): InstancedMesh;
  25179. /**
  25180. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25181. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25182. * @returns the current mesh
  25183. */
  25184. synchronizeInstances(): Mesh;
  25185. /**
  25186. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25187. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25188. * This should be used together with the simplification to avoid disappearing triangles.
  25189. * @param successCallback an optional success callback to be called after the optimization finished.
  25190. * @returns the current mesh
  25191. */
  25192. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25193. /**
  25194. * Serialize current mesh
  25195. * @param serializationObject defines the object which will receive the serialization data
  25196. */
  25197. serialize(serializationObject: any): void;
  25198. /** @hidden */
  25199. _syncGeometryWithMorphTargetManager(): void;
  25200. /** @hidden */
  25201. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25202. /**
  25203. * Returns a new Mesh object parsed from the source provided.
  25204. * @param parsedMesh is the source
  25205. * @param scene defines the hosting scene
  25206. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25207. * @returns a new Mesh
  25208. */
  25209. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25210. /**
  25211. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25212. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25213. * @param name defines the name of the mesh to create
  25214. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25215. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25216. * @param closePath creates a seam between the first and the last points of each path of the path array
  25217. * @param offset is taken in account only if the `pathArray` is containing a single path
  25218. * @param scene defines the hosting scene
  25219. * @param updatable defines if the mesh must be flagged as updatable
  25220. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25221. * @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)
  25222. * @returns a new Mesh
  25223. */
  25224. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25225. /**
  25226. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25227. * @param name defines the name of the mesh to create
  25228. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25229. * @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
  25230. * @param scene defines the hosting scene
  25231. * @param updatable defines if the mesh must be flagged as updatable
  25232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25233. * @returns a new Mesh
  25234. */
  25235. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25236. /**
  25237. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25238. * @param name defines the name of the mesh to create
  25239. * @param size sets the size (float) of each box side (default 1)
  25240. * @param scene defines the hosting scene
  25241. * @param updatable defines if the mesh must be flagged as updatable
  25242. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25243. * @returns a new Mesh
  25244. */
  25245. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25246. /**
  25247. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25248. * @param name defines the name of the mesh to create
  25249. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25250. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25251. * @param scene defines the hosting scene
  25252. * @param updatable defines if the mesh must be flagged as updatable
  25253. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25254. * @returns a new Mesh
  25255. */
  25256. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25257. /**
  25258. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25259. * @param name defines the name of the mesh to create
  25260. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25261. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25262. * @param scene defines the hosting scene
  25263. * @returns a new Mesh
  25264. */
  25265. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25266. /**
  25267. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25268. * @param name defines the name of the mesh to create
  25269. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25270. * @param diameterTop set the top cap diameter (floats, default 1)
  25271. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25272. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25273. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25274. * @param scene defines the hosting scene
  25275. * @param updatable defines if the mesh must be flagged as updatable
  25276. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25277. * @returns a new Mesh
  25278. */
  25279. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25280. /**
  25281. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25282. * @param name defines the name of the mesh to create
  25283. * @param diameter sets the diameter size (float) of the torus (default 1)
  25284. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25285. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25286. * @param scene defines the hosting scene
  25287. * @param updatable defines if the mesh must be flagged as updatable
  25288. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25289. * @returns a new Mesh
  25290. */
  25291. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25292. /**
  25293. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25294. * @param name defines the name of the mesh to create
  25295. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25296. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25297. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25298. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25299. * @param p the number of windings on X axis (positive integers, default 2)
  25300. * @param q the number of windings on Y axis (positive integers, default 3)
  25301. * @param scene defines the hosting scene
  25302. * @param updatable defines if the mesh must be flagged as updatable
  25303. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25304. * @returns a new Mesh
  25305. */
  25306. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25307. /**
  25308. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25309. * @param name defines the name of the mesh to create
  25310. * @param points is an array successive Vector3
  25311. * @param scene defines the hosting scene
  25312. * @param updatable defines if the mesh must be flagged as updatable
  25313. * @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).
  25314. * @returns a new Mesh
  25315. */
  25316. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25317. /**
  25318. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25319. * @param name defines the name of the mesh to create
  25320. * @param points is an array successive Vector3
  25321. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25322. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25323. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25324. * @param scene defines the hosting scene
  25325. * @param updatable defines if the mesh must be flagged as updatable
  25326. * @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)
  25327. * @returns a new Mesh
  25328. */
  25329. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25330. /**
  25331. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25332. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25333. * 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.
  25334. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25335. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25336. * Remember you can only change the shape positions, not their number when updating a polygon.
  25337. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25338. * @param name defines the name of the mesh to create
  25339. * @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
  25340. * @param scene defines the hosting scene
  25341. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25342. * @param updatable defines if the mesh must be flagged as updatable
  25343. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25344. * @param earcutInjection can be used to inject your own earcut reference
  25345. * @returns a new Mesh
  25346. */
  25347. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25348. /**
  25349. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25350. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25351. * @param name defines the name of the mesh to create
  25352. * @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
  25353. * @param depth defines the height of extrusion
  25354. * @param scene defines the hosting scene
  25355. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25356. * @param updatable defines if the mesh must be flagged as updatable
  25357. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25358. * @param earcutInjection can be used to inject your own earcut reference
  25359. * @returns a new Mesh
  25360. */
  25361. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25362. /**
  25363. * Creates an extruded shape mesh.
  25364. * 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
  25365. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25366. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25367. * @param name defines the name of the mesh to create
  25368. * @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
  25369. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25370. * @param scale is the value to scale the shape
  25371. * @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
  25372. * @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
  25373. * @param scene defines the hosting scene
  25374. * @param updatable defines if the mesh must be flagged as updatable
  25375. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25376. * @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)
  25377. * @returns a new Mesh
  25378. */
  25379. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25380. /**
  25381. * Creates an custom extruded shape mesh.
  25382. * The custom extrusion is a parametric shape.
  25383. * It has no predefined shape. Its final shape will depend on the input parameters.
  25384. * Please consider using the same method from the MeshBuilder class instead
  25385. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25386. * @param name defines the name of the mesh to create
  25387. * @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
  25388. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25389. * @param scaleFunction is a custom Javascript function called on each path point
  25390. * @param rotationFunction is a custom Javascript function called on each path point
  25391. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25392. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25393. * @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
  25394. * @param scene defines the hosting scene
  25395. * @param updatable defines if the mesh must be flagged as updatable
  25396. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25397. * @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)
  25398. * @returns a new Mesh
  25399. */
  25400. 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;
  25401. /**
  25402. * Creates lathe mesh.
  25403. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25404. * Please consider using the same method from the MeshBuilder class instead
  25405. * @param name defines the name of the mesh to create
  25406. * @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
  25407. * @param radius is the radius value of the lathe
  25408. * @param tessellation is the side number of the lathe.
  25409. * @param scene defines the hosting scene
  25410. * @param updatable defines if the mesh must be flagged as updatable
  25411. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25412. * @returns a new Mesh
  25413. */
  25414. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25415. /**
  25416. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25417. * @param name defines the name of the mesh to create
  25418. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25419. * @param scene defines the hosting scene
  25420. * @param updatable defines if the mesh must be flagged as updatable
  25421. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25422. * @returns a new Mesh
  25423. */
  25424. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25425. /**
  25426. * Creates a ground mesh.
  25427. * Please consider using the same method from the MeshBuilder class instead
  25428. * @param name defines the name of the mesh to create
  25429. * @param width set the width of the ground
  25430. * @param height set the height of the ground
  25431. * @param subdivisions sets the number of subdivisions per side
  25432. * @param scene defines the hosting scene
  25433. * @param updatable defines if the mesh must be flagged as updatable
  25434. * @returns a new Mesh
  25435. */
  25436. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25437. /**
  25438. * Creates a tiled ground mesh.
  25439. * Please consider using the same method from the MeshBuilder class instead
  25440. * @param name defines the name of the mesh to create
  25441. * @param xmin set the ground minimum X coordinate
  25442. * @param zmin set the ground minimum Y coordinate
  25443. * @param xmax set the ground maximum X coordinate
  25444. * @param zmax set the ground maximum Z coordinate
  25445. * @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
  25446. * @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
  25447. * @param scene defines the hosting scene
  25448. * @param updatable defines if the mesh must be flagged as updatable
  25449. * @returns a new Mesh
  25450. */
  25451. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25452. w: number;
  25453. h: number;
  25454. }, precision: {
  25455. w: number;
  25456. h: number;
  25457. }, scene: Scene, updatable?: boolean): Mesh;
  25458. /**
  25459. * Creates a ground mesh from a height map.
  25460. * Please consider using the same method from the MeshBuilder class instead
  25461. * @see http://doc.babylonjs.com/babylon101/height_map
  25462. * @param name defines the name of the mesh to create
  25463. * @param url sets the URL of the height map image resource
  25464. * @param width set the ground width size
  25465. * @param height set the ground height size
  25466. * @param subdivisions sets the number of subdivision per side
  25467. * @param minHeight is the minimum altitude on the ground
  25468. * @param maxHeight is the maximum altitude on the ground
  25469. * @param scene defines the hosting scene
  25470. * @param updatable defines if the mesh must be flagged as updatable
  25471. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25472. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25473. * @returns a new Mesh
  25474. */
  25475. 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;
  25476. /**
  25477. * Creates a tube mesh.
  25478. * The tube is a parametric shape.
  25479. * It has no predefined shape. Its final shape will depend on the input parameters.
  25480. * Please consider using the same method from the MeshBuilder class instead
  25481. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25482. * @param name defines the name of the mesh to create
  25483. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25484. * @param radius sets the tube radius size
  25485. * @param tessellation is the number of sides on the tubular surface
  25486. * @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
  25487. * @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
  25488. * @param scene defines the hosting scene
  25489. * @param updatable defines if the mesh must be flagged as updatable
  25490. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25491. * @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)
  25492. * @returns a new Mesh
  25493. */
  25494. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25495. (i: number, distance: number): number;
  25496. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25497. /**
  25498. * Creates a polyhedron mesh.
  25499. * Please consider using the same method from the MeshBuilder class instead.
  25500. * * 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
  25501. * * The parameter `size` (positive float, default 1) sets the polygon size
  25502. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25503. * * 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`
  25504. * * 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
  25505. * * 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)`)
  25506. * * 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
  25507. * * 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
  25508. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25509. * * 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
  25510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25511. * @param name defines the name of the mesh to create
  25512. * @param options defines the options used to create the mesh
  25513. * @param scene defines the hosting scene
  25514. * @returns a new Mesh
  25515. */
  25516. static CreatePolyhedron(name: string, options: {
  25517. type?: number;
  25518. size?: number;
  25519. sizeX?: number;
  25520. sizeY?: number;
  25521. sizeZ?: number;
  25522. custom?: any;
  25523. faceUV?: Vector4[];
  25524. faceColors?: Color4[];
  25525. updatable?: boolean;
  25526. sideOrientation?: number;
  25527. }, scene: Scene): Mesh;
  25528. /**
  25529. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25530. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25531. * * 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`)
  25532. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25533. * * 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
  25534. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25535. * * 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
  25536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25537. * @param name defines the name of the mesh
  25538. * @param options defines the options used to create the mesh
  25539. * @param scene defines the hosting scene
  25540. * @returns a new Mesh
  25541. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25542. */
  25543. static CreateIcoSphere(name: string, options: {
  25544. radius?: number;
  25545. flat?: boolean;
  25546. subdivisions?: number;
  25547. sideOrientation?: number;
  25548. updatable?: boolean;
  25549. }, scene: Scene): Mesh;
  25550. /**
  25551. * Creates a decal mesh.
  25552. * Please consider using the same method from the MeshBuilder class instead.
  25553. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25554. * @param name defines the name of the mesh
  25555. * @param sourceMesh defines the mesh receiving the decal
  25556. * @param position sets the position of the decal in world coordinates
  25557. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25558. * @param size sets the decal scaling
  25559. * @param angle sets the angle to rotate the decal
  25560. * @returns a new Mesh
  25561. */
  25562. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25563. /**
  25564. * Prepare internal position array for software CPU skinning
  25565. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25566. */
  25567. setPositionsForCPUSkinning(): Float32Array;
  25568. /**
  25569. * Prepare internal normal array for software CPU skinning
  25570. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25571. */
  25572. setNormalsForCPUSkinning(): Float32Array;
  25573. /**
  25574. * Updates the vertex buffer by applying transformation from the bones
  25575. * @param skeleton defines the skeleton to apply to current mesh
  25576. * @returns the current mesh
  25577. */
  25578. applySkeleton(skeleton: Skeleton): Mesh;
  25579. /**
  25580. * 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
  25581. * @param meshes defines the list of meshes to scan
  25582. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25583. */
  25584. static MinMax(meshes: AbstractMesh[]): {
  25585. min: Vector3;
  25586. max: Vector3;
  25587. };
  25588. /**
  25589. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25590. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25591. * @returns a vector3
  25592. */
  25593. static Center(meshesOrMinMaxVector: {
  25594. min: Vector3;
  25595. max: Vector3;
  25596. } | AbstractMesh[]): Vector3;
  25597. /**
  25598. * Merge the array of meshes into a single mesh for performance reasons.
  25599. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25600. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25601. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25602. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25603. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25604. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25605. * @returns a new mesh
  25606. */
  25607. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25608. /** @hidden */
  25609. addInstance(instance: InstancedMesh): void;
  25610. /** @hidden */
  25611. removeInstance(instance: InstancedMesh): void;
  25612. }
  25613. }
  25614. declare module BABYLON {
  25615. /**
  25616. * This is the base class of all the camera used in the application.
  25617. * @see http://doc.babylonjs.com/features/cameras
  25618. */
  25619. export class Camera extends Node {
  25620. /** @hidden */
  25621. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25622. /**
  25623. * This is the default projection mode used by the cameras.
  25624. * It helps recreating a feeling of perspective and better appreciate depth.
  25625. * This is the best way to simulate real life cameras.
  25626. */
  25627. static readonly PERSPECTIVE_CAMERA: number;
  25628. /**
  25629. * This helps creating camera with an orthographic mode.
  25630. * 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.
  25631. */
  25632. static readonly ORTHOGRAPHIC_CAMERA: number;
  25633. /**
  25634. * This is the default FOV mode for perspective cameras.
  25635. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25636. */
  25637. static readonly FOVMODE_VERTICAL_FIXED: number;
  25638. /**
  25639. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25640. */
  25641. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25642. /**
  25643. * This specifies ther is no need for a camera rig.
  25644. * Basically only one eye is rendered corresponding to the camera.
  25645. */
  25646. static readonly RIG_MODE_NONE: number;
  25647. /**
  25648. * Simulates a camera Rig with one blue eye and one red eye.
  25649. * This can be use with 3d blue and red glasses.
  25650. */
  25651. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25652. /**
  25653. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25654. */
  25655. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25656. /**
  25657. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25658. */
  25659. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25660. /**
  25661. * Defines that both eyes of the camera will be rendered over under each other.
  25662. */
  25663. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25664. /**
  25665. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25666. */
  25667. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25668. /**
  25669. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25670. */
  25671. static readonly RIG_MODE_VR: number;
  25672. /**
  25673. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25674. */
  25675. static readonly RIG_MODE_WEBVR: number;
  25676. /**
  25677. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25678. */
  25679. static readonly RIG_MODE_CUSTOM: number;
  25680. /**
  25681. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25682. */
  25683. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25684. /**
  25685. * Define the input manager associated with the camera.
  25686. */
  25687. inputs: CameraInputsManager<Camera>;
  25688. /** @hidden */
  25689. _position: Vector3;
  25690. /**
  25691. * Define the current local position of the camera in the scene
  25692. */
  25693. get position(): Vector3;
  25694. set position(newPosition: Vector3);
  25695. /**
  25696. * The vector the camera should consider as up.
  25697. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25698. */
  25699. upVector: Vector3;
  25700. /**
  25701. * Define the current limit on the left side for an orthographic camera
  25702. * In scene unit
  25703. */
  25704. orthoLeft: Nullable<number>;
  25705. /**
  25706. * Define the current limit on the right side for an orthographic camera
  25707. * In scene unit
  25708. */
  25709. orthoRight: Nullable<number>;
  25710. /**
  25711. * Define the current limit on the bottom side for an orthographic camera
  25712. * In scene unit
  25713. */
  25714. orthoBottom: Nullable<number>;
  25715. /**
  25716. * Define the current limit on the top side for an orthographic camera
  25717. * In scene unit
  25718. */
  25719. orthoTop: Nullable<number>;
  25720. /**
  25721. * Field Of View is set in Radians. (default is 0.8)
  25722. */
  25723. fov: number;
  25724. /**
  25725. * Define the minimum distance the camera can see from.
  25726. * This is important to note that the depth buffer are not infinite and the closer it starts
  25727. * the more your scene might encounter depth fighting issue.
  25728. */
  25729. minZ: number;
  25730. /**
  25731. * Define the maximum distance the camera can see to.
  25732. * This is important to note that the depth buffer are not infinite and the further it end
  25733. * the more your scene might encounter depth fighting issue.
  25734. */
  25735. maxZ: number;
  25736. /**
  25737. * Define the default inertia of the camera.
  25738. * This helps giving a smooth feeling to the camera movement.
  25739. */
  25740. inertia: number;
  25741. /**
  25742. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25743. */
  25744. mode: number;
  25745. /**
  25746. * Define whether the camera is intermediate.
  25747. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25748. */
  25749. isIntermediate: boolean;
  25750. /**
  25751. * Define the viewport of the camera.
  25752. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25753. */
  25754. viewport: Viewport;
  25755. /**
  25756. * Restricts the camera to viewing objects with the same layerMask.
  25757. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25758. */
  25759. layerMask: number;
  25760. /**
  25761. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25762. */
  25763. fovMode: number;
  25764. /**
  25765. * Rig mode of the camera.
  25766. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25767. * This is normally controlled byt the camera themselves as internal use.
  25768. */
  25769. cameraRigMode: number;
  25770. /**
  25771. * Defines the distance between both "eyes" in case of a RIG
  25772. */
  25773. interaxialDistance: number;
  25774. /**
  25775. * Defines if stereoscopic rendering is done side by side or over under.
  25776. */
  25777. isStereoscopicSideBySide: boolean;
  25778. /**
  25779. * 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
  25780. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25781. * else in the scene. (Eg. security camera)
  25782. *
  25783. * 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)
  25784. */
  25785. customRenderTargets: RenderTargetTexture[];
  25786. /**
  25787. * When set, the camera will render to this render target instead of the default canvas
  25788. *
  25789. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25790. */
  25791. outputRenderTarget: Nullable<RenderTargetTexture>;
  25792. /**
  25793. * Observable triggered when the camera view matrix has changed.
  25794. */
  25795. onViewMatrixChangedObservable: Observable<Camera>;
  25796. /**
  25797. * Observable triggered when the camera Projection matrix has changed.
  25798. */
  25799. onProjectionMatrixChangedObservable: Observable<Camera>;
  25800. /**
  25801. * Observable triggered when the inputs have been processed.
  25802. */
  25803. onAfterCheckInputsObservable: Observable<Camera>;
  25804. /**
  25805. * Observable triggered when reset has been called and applied to the camera.
  25806. */
  25807. onRestoreStateObservable: Observable<Camera>;
  25808. /**
  25809. * Is this camera a part of a rig system?
  25810. */
  25811. isRigCamera: boolean;
  25812. /**
  25813. * If isRigCamera set to true this will be set with the parent camera.
  25814. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25815. */
  25816. rigParent?: Camera;
  25817. /** @hidden */
  25818. _cameraRigParams: any;
  25819. /** @hidden */
  25820. _rigCameras: Camera[];
  25821. /** @hidden */
  25822. _rigPostProcess: Nullable<PostProcess>;
  25823. protected _webvrViewMatrix: Matrix;
  25824. /** @hidden */
  25825. _skipRendering: boolean;
  25826. /** @hidden */
  25827. _projectionMatrix: Matrix;
  25828. /** @hidden */
  25829. _postProcesses: Nullable<PostProcess>[];
  25830. /** @hidden */
  25831. _activeMeshes: SmartArray<AbstractMesh>;
  25832. protected _globalPosition: Vector3;
  25833. /** @hidden */
  25834. _computedViewMatrix: Matrix;
  25835. private _doNotComputeProjectionMatrix;
  25836. private _transformMatrix;
  25837. private _frustumPlanes;
  25838. private _refreshFrustumPlanes;
  25839. private _storedFov;
  25840. private _stateStored;
  25841. /**
  25842. * Instantiates a new camera object.
  25843. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25844. * @see http://doc.babylonjs.com/features/cameras
  25845. * @param name Defines the name of the camera in the scene
  25846. * @param position Defines the position of the camera
  25847. * @param scene Defines the scene the camera belongs too
  25848. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25849. */
  25850. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25851. /**
  25852. * Store current camera state (fov, position, etc..)
  25853. * @returns the camera
  25854. */
  25855. storeState(): Camera;
  25856. /**
  25857. * Restores the camera state values if it has been stored. You must call storeState() first
  25858. */
  25859. protected _restoreStateValues(): boolean;
  25860. /**
  25861. * Restored camera state. You must call storeState() first.
  25862. * @returns true if restored and false otherwise
  25863. */
  25864. restoreState(): boolean;
  25865. /**
  25866. * Gets the class name of the camera.
  25867. * @returns the class name
  25868. */
  25869. getClassName(): string;
  25870. /** @hidden */
  25871. readonly _isCamera: boolean;
  25872. /**
  25873. * Gets a string representation of the camera useful for debug purpose.
  25874. * @param fullDetails Defines that a more verboe level of logging is required
  25875. * @returns the string representation
  25876. */
  25877. toString(fullDetails?: boolean): string;
  25878. /**
  25879. * Gets the current world space position of the camera.
  25880. */
  25881. get globalPosition(): Vector3;
  25882. /**
  25883. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25884. * @returns the active meshe list
  25885. */
  25886. getActiveMeshes(): SmartArray<AbstractMesh>;
  25887. /**
  25888. * Check whether a mesh is part of the current active mesh list of the camera
  25889. * @param mesh Defines the mesh to check
  25890. * @returns true if active, false otherwise
  25891. */
  25892. isActiveMesh(mesh: Mesh): boolean;
  25893. /**
  25894. * Is this camera ready to be used/rendered
  25895. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25896. * @return true if the camera is ready
  25897. */
  25898. isReady(completeCheck?: boolean): boolean;
  25899. /** @hidden */
  25900. _initCache(): void;
  25901. /** @hidden */
  25902. _updateCache(ignoreParentClass?: boolean): void;
  25903. /** @hidden */
  25904. _isSynchronized(): boolean;
  25905. /** @hidden */
  25906. _isSynchronizedViewMatrix(): boolean;
  25907. /** @hidden */
  25908. _isSynchronizedProjectionMatrix(): boolean;
  25909. /**
  25910. * Attach the input controls to a specific dom element to get the input from.
  25911. * @param element Defines the element the controls should be listened from
  25912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25913. */
  25914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25915. /**
  25916. * Detach the current controls from the specified dom element.
  25917. * @param element Defines the element to stop listening the inputs from
  25918. */
  25919. detachControl(element: HTMLElement): void;
  25920. /**
  25921. * Update the camera state according to the different inputs gathered during the frame.
  25922. */
  25923. update(): void;
  25924. /** @hidden */
  25925. _checkInputs(): void;
  25926. /** @hidden */
  25927. get rigCameras(): Camera[];
  25928. /**
  25929. * Gets the post process used by the rig cameras
  25930. */
  25931. get rigPostProcess(): Nullable<PostProcess>;
  25932. /**
  25933. * Internal, gets the first post proces.
  25934. * @returns the first post process to be run on this camera.
  25935. */
  25936. _getFirstPostProcess(): Nullable<PostProcess>;
  25937. private _cascadePostProcessesToRigCams;
  25938. /**
  25939. * Attach a post process to the camera.
  25940. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25941. * @param postProcess The post process to attach to the camera
  25942. * @param insertAt The position of the post process in case several of them are in use in the scene
  25943. * @returns the position the post process has been inserted at
  25944. */
  25945. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25946. /**
  25947. * Detach a post process to the camera.
  25948. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25949. * @param postProcess The post process to detach from the camera
  25950. */
  25951. detachPostProcess(postProcess: PostProcess): void;
  25952. /**
  25953. * Gets the current world matrix of the camera
  25954. */
  25955. getWorldMatrix(): Matrix;
  25956. /** @hidden */
  25957. _getViewMatrix(): Matrix;
  25958. /**
  25959. * Gets the current view matrix of the camera.
  25960. * @param force forces the camera to recompute the matrix without looking at the cached state
  25961. * @returns the view matrix
  25962. */
  25963. getViewMatrix(force?: boolean): Matrix;
  25964. /**
  25965. * Freeze the projection matrix.
  25966. * It will prevent the cache check of the camera projection compute and can speed up perf
  25967. * if no parameter of the camera are meant to change
  25968. * @param projection Defines manually a projection if necessary
  25969. */
  25970. freezeProjectionMatrix(projection?: Matrix): void;
  25971. /**
  25972. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25973. */
  25974. unfreezeProjectionMatrix(): void;
  25975. /**
  25976. * Gets the current projection matrix of the camera.
  25977. * @param force forces the camera to recompute the matrix without looking at the cached state
  25978. * @returns the projection matrix
  25979. */
  25980. getProjectionMatrix(force?: boolean): Matrix;
  25981. /**
  25982. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25983. * @returns a Matrix
  25984. */
  25985. getTransformationMatrix(): Matrix;
  25986. private _updateFrustumPlanes;
  25987. /**
  25988. * Checks if a cullable object (mesh...) is in the camera frustum
  25989. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25990. * @param target The object to check
  25991. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25992. * @returns true if the object is in frustum otherwise false
  25993. */
  25994. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25995. /**
  25996. * Checks if a cullable object (mesh...) is in the camera frustum
  25997. * Unlike isInFrustum this cheks the full bounding box
  25998. * @param target The object to check
  25999. * @returns true if the object is in frustum otherwise false
  26000. */
  26001. isCompletelyInFrustum(target: ICullable): boolean;
  26002. /**
  26003. * Gets a ray in the forward direction from the camera.
  26004. * @param length Defines the length of the ray to create
  26005. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26006. * @param origin Defines the start point of the ray which defaults to the camera position
  26007. * @returns the forward ray
  26008. */
  26009. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26010. /**
  26011. * Releases resources associated with this node.
  26012. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26013. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26014. */
  26015. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26016. /** @hidden */
  26017. _isLeftCamera: boolean;
  26018. /**
  26019. * Gets the left camera of a rig setup in case of Rigged Camera
  26020. */
  26021. get isLeftCamera(): boolean;
  26022. /** @hidden */
  26023. _isRightCamera: boolean;
  26024. /**
  26025. * Gets the right camera of a rig setup in case of Rigged Camera
  26026. */
  26027. get isRightCamera(): boolean;
  26028. /**
  26029. * Gets the left camera of a rig setup in case of Rigged Camera
  26030. */
  26031. get leftCamera(): Nullable<FreeCamera>;
  26032. /**
  26033. * Gets the right camera of a rig setup in case of Rigged Camera
  26034. */
  26035. get rightCamera(): Nullable<FreeCamera>;
  26036. /**
  26037. * Gets the left camera target of a rig setup in case of Rigged Camera
  26038. * @returns the target position
  26039. */
  26040. getLeftTarget(): Nullable<Vector3>;
  26041. /**
  26042. * Gets the right camera target of a rig setup in case of Rigged Camera
  26043. * @returns the target position
  26044. */
  26045. getRightTarget(): Nullable<Vector3>;
  26046. /**
  26047. * @hidden
  26048. */
  26049. setCameraRigMode(mode: number, rigParams: any): void;
  26050. /** @hidden */
  26051. static _setStereoscopicRigMode(camera: Camera): void;
  26052. /** @hidden */
  26053. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26054. /** @hidden */
  26055. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26056. /** @hidden */
  26057. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26058. /** @hidden */
  26059. _getVRProjectionMatrix(): Matrix;
  26060. protected _updateCameraRotationMatrix(): void;
  26061. protected _updateWebVRCameraRotationMatrix(): void;
  26062. /**
  26063. * This function MUST be overwritten by the different WebVR cameras available.
  26064. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26065. * @hidden
  26066. */
  26067. _getWebVRProjectionMatrix(): Matrix;
  26068. /**
  26069. * This function MUST be overwritten by the different WebVR cameras available.
  26070. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26071. * @hidden
  26072. */
  26073. _getWebVRViewMatrix(): Matrix;
  26074. /** @hidden */
  26075. setCameraRigParameter(name: string, value: any): void;
  26076. /**
  26077. * needs to be overridden by children so sub has required properties to be copied
  26078. * @hidden
  26079. */
  26080. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26081. /**
  26082. * May need to be overridden by children
  26083. * @hidden
  26084. */
  26085. _updateRigCameras(): void;
  26086. /** @hidden */
  26087. _setupInputs(): void;
  26088. /**
  26089. * Serialiaze the camera setup to a json represention
  26090. * @returns the JSON representation
  26091. */
  26092. serialize(): any;
  26093. /**
  26094. * Clones the current camera.
  26095. * @param name The cloned camera name
  26096. * @returns the cloned camera
  26097. */
  26098. clone(name: string): Camera;
  26099. /**
  26100. * Gets the direction of the camera relative to a given local axis.
  26101. * @param localAxis Defines the reference axis to provide a relative direction.
  26102. * @return the direction
  26103. */
  26104. getDirection(localAxis: Vector3): Vector3;
  26105. /**
  26106. * Returns the current camera absolute rotation
  26107. */
  26108. get absoluteRotation(): Quaternion;
  26109. /**
  26110. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26111. * @param localAxis Defines the reference axis to provide a relative direction.
  26112. * @param result Defines the vector to store the result in
  26113. */
  26114. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26115. /**
  26116. * Gets a camera constructor for a given camera type
  26117. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26118. * @param name The name of the camera the result will be able to instantiate
  26119. * @param scene The scene the result will construct the camera in
  26120. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26121. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26122. * @returns a factory method to construc the camera
  26123. */
  26124. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26125. /**
  26126. * Compute the world matrix of the camera.
  26127. * @returns the camera world matrix
  26128. */
  26129. computeWorldMatrix(): Matrix;
  26130. /**
  26131. * Parse a JSON and creates the camera from the parsed information
  26132. * @param parsedCamera The JSON to parse
  26133. * @param scene The scene to instantiate the camera in
  26134. * @returns the newly constructed camera
  26135. */
  26136. static Parse(parsedCamera: any, scene: Scene): Camera;
  26137. }
  26138. }
  26139. declare module BABYLON {
  26140. /**
  26141. * Class containing static functions to help procedurally build meshes
  26142. */
  26143. export class DiscBuilder {
  26144. /**
  26145. * Creates a plane polygonal mesh. By default, this is a disc
  26146. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26147. * * 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
  26148. * * 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
  26149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26150. * * 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
  26151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26152. * @param name defines the name of the mesh
  26153. * @param options defines the options used to create the mesh
  26154. * @param scene defines the hosting scene
  26155. * @returns the plane polygonal mesh
  26156. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26157. */
  26158. static CreateDisc(name: string, options: {
  26159. radius?: number;
  26160. tessellation?: number;
  26161. arc?: number;
  26162. updatable?: boolean;
  26163. sideOrientation?: number;
  26164. frontUVs?: Vector4;
  26165. backUVs?: Vector4;
  26166. }, scene?: Nullable<Scene>): Mesh;
  26167. }
  26168. }
  26169. declare module BABYLON {
  26170. /**
  26171. * Options to be used when creating a FresnelParameters.
  26172. */
  26173. export type IFresnelParametersCreationOptions = {
  26174. /**
  26175. * Define the color used on edges (grazing angle)
  26176. */
  26177. leftColor?: Color3;
  26178. /**
  26179. * Define the color used on center
  26180. */
  26181. rightColor?: Color3;
  26182. /**
  26183. * Define bias applied to computed fresnel term
  26184. */
  26185. bias?: number;
  26186. /**
  26187. * Defined the power exponent applied to fresnel term
  26188. */
  26189. power?: number;
  26190. /**
  26191. * Define if the fresnel effect is enable or not.
  26192. */
  26193. isEnabled?: boolean;
  26194. };
  26195. /**
  26196. * Serialized format for FresnelParameters.
  26197. */
  26198. export type IFresnelParametersSerialized = {
  26199. /**
  26200. * Define the color used on edges (grazing angle) [as an array]
  26201. */
  26202. leftColor: number[];
  26203. /**
  26204. * Define the color used on center [as an array]
  26205. */
  26206. rightColor: number[];
  26207. /**
  26208. * Define bias applied to computed fresnel term
  26209. */
  26210. bias: number;
  26211. /**
  26212. * Defined the power exponent applied to fresnel term
  26213. */
  26214. power?: number;
  26215. /**
  26216. * Define if the fresnel effect is enable or not.
  26217. */
  26218. isEnabled: boolean;
  26219. };
  26220. /**
  26221. * This represents all the required information to add a fresnel effect on a material:
  26222. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26223. */
  26224. export class FresnelParameters {
  26225. private _isEnabled;
  26226. /**
  26227. * Define if the fresnel effect is enable or not.
  26228. */
  26229. get isEnabled(): boolean;
  26230. set isEnabled(value: boolean);
  26231. /**
  26232. * Define the color used on edges (grazing angle)
  26233. */
  26234. leftColor: Color3;
  26235. /**
  26236. * Define the color used on center
  26237. */
  26238. rightColor: Color3;
  26239. /**
  26240. * Define bias applied to computed fresnel term
  26241. */
  26242. bias: number;
  26243. /**
  26244. * Defined the power exponent applied to fresnel term
  26245. */
  26246. power: number;
  26247. /**
  26248. * Creates a new FresnelParameters object.
  26249. *
  26250. * @param options provide your own settings to optionally to override defaults
  26251. */
  26252. constructor(options?: IFresnelParametersCreationOptions);
  26253. /**
  26254. * Clones the current fresnel and its valuues
  26255. * @returns a clone fresnel configuration
  26256. */
  26257. clone(): FresnelParameters;
  26258. /**
  26259. * Determines equality between FresnelParameters objects
  26260. * @param otherFresnelParameters defines the second operand
  26261. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26262. */
  26263. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26264. /**
  26265. * Serializes the current fresnel parameters to a JSON representation.
  26266. * @return the JSON serialization
  26267. */
  26268. serialize(): IFresnelParametersSerialized;
  26269. /**
  26270. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26271. * @param parsedFresnelParameters Define the JSON representation
  26272. * @returns the parsed parameters
  26273. */
  26274. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26275. }
  26276. }
  26277. declare module BABYLON {
  26278. /**
  26279. * Base class of materials working in push mode in babylon JS
  26280. * @hidden
  26281. */
  26282. export class PushMaterial extends Material {
  26283. protected _activeEffect: Effect;
  26284. protected _normalMatrix: Matrix;
  26285. /**
  26286. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26287. * This means that the material can keep using a previous shader while a new one is being compiled.
  26288. * This is mostly used when shader parallel compilation is supported (true by default)
  26289. */
  26290. allowShaderHotSwapping: boolean;
  26291. constructor(name: string, scene: Scene);
  26292. getEffect(): Effect;
  26293. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26294. /**
  26295. * Binds the given world matrix to the active effect
  26296. *
  26297. * @param world the matrix to bind
  26298. */
  26299. bindOnlyWorldMatrix(world: Matrix): void;
  26300. /**
  26301. * Binds the given normal matrix to the active effect
  26302. *
  26303. * @param normalMatrix the matrix to bind
  26304. */
  26305. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26306. bind(world: Matrix, mesh?: Mesh): void;
  26307. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26308. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26309. }
  26310. }
  26311. declare module BABYLON {
  26312. /**
  26313. * This groups all the flags used to control the materials channel.
  26314. */
  26315. export class MaterialFlags {
  26316. private static _DiffuseTextureEnabled;
  26317. /**
  26318. * Are diffuse textures enabled in the application.
  26319. */
  26320. static get DiffuseTextureEnabled(): boolean;
  26321. static set DiffuseTextureEnabled(value: boolean);
  26322. private static _AmbientTextureEnabled;
  26323. /**
  26324. * Are ambient textures enabled in the application.
  26325. */
  26326. static get AmbientTextureEnabled(): boolean;
  26327. static set AmbientTextureEnabled(value: boolean);
  26328. private static _OpacityTextureEnabled;
  26329. /**
  26330. * Are opacity textures enabled in the application.
  26331. */
  26332. static get OpacityTextureEnabled(): boolean;
  26333. static set OpacityTextureEnabled(value: boolean);
  26334. private static _ReflectionTextureEnabled;
  26335. /**
  26336. * Are reflection textures enabled in the application.
  26337. */
  26338. static get ReflectionTextureEnabled(): boolean;
  26339. static set ReflectionTextureEnabled(value: boolean);
  26340. private static _EmissiveTextureEnabled;
  26341. /**
  26342. * Are emissive textures enabled in the application.
  26343. */
  26344. static get EmissiveTextureEnabled(): boolean;
  26345. static set EmissiveTextureEnabled(value: boolean);
  26346. private static _SpecularTextureEnabled;
  26347. /**
  26348. * Are specular textures enabled in the application.
  26349. */
  26350. static get SpecularTextureEnabled(): boolean;
  26351. static set SpecularTextureEnabled(value: boolean);
  26352. private static _BumpTextureEnabled;
  26353. /**
  26354. * Are bump textures enabled in the application.
  26355. */
  26356. static get BumpTextureEnabled(): boolean;
  26357. static set BumpTextureEnabled(value: boolean);
  26358. private static _LightmapTextureEnabled;
  26359. /**
  26360. * Are lightmap textures enabled in the application.
  26361. */
  26362. static get LightmapTextureEnabled(): boolean;
  26363. static set LightmapTextureEnabled(value: boolean);
  26364. private static _RefractionTextureEnabled;
  26365. /**
  26366. * Are refraction textures enabled in the application.
  26367. */
  26368. static get RefractionTextureEnabled(): boolean;
  26369. static set RefractionTextureEnabled(value: boolean);
  26370. private static _ColorGradingTextureEnabled;
  26371. /**
  26372. * Are color grading textures enabled in the application.
  26373. */
  26374. static get ColorGradingTextureEnabled(): boolean;
  26375. static set ColorGradingTextureEnabled(value: boolean);
  26376. private static _FresnelEnabled;
  26377. /**
  26378. * Are fresnels enabled in the application.
  26379. */
  26380. static get FresnelEnabled(): boolean;
  26381. static set FresnelEnabled(value: boolean);
  26382. private static _ClearCoatTextureEnabled;
  26383. /**
  26384. * Are clear coat textures enabled in the application.
  26385. */
  26386. static get ClearCoatTextureEnabled(): boolean;
  26387. static set ClearCoatTextureEnabled(value: boolean);
  26388. private static _ClearCoatBumpTextureEnabled;
  26389. /**
  26390. * Are clear coat bump textures enabled in the application.
  26391. */
  26392. static get ClearCoatBumpTextureEnabled(): boolean;
  26393. static set ClearCoatBumpTextureEnabled(value: boolean);
  26394. private static _ClearCoatTintTextureEnabled;
  26395. /**
  26396. * Are clear coat tint textures enabled in the application.
  26397. */
  26398. static get ClearCoatTintTextureEnabled(): boolean;
  26399. static set ClearCoatTintTextureEnabled(value: boolean);
  26400. private static _SheenTextureEnabled;
  26401. /**
  26402. * Are sheen textures enabled in the application.
  26403. */
  26404. static get SheenTextureEnabled(): boolean;
  26405. static set SheenTextureEnabled(value: boolean);
  26406. private static _AnisotropicTextureEnabled;
  26407. /**
  26408. * Are anisotropic textures enabled in the application.
  26409. */
  26410. static get AnisotropicTextureEnabled(): boolean;
  26411. static set AnisotropicTextureEnabled(value: boolean);
  26412. private static _ThicknessTextureEnabled;
  26413. /**
  26414. * Are thickness textures enabled in the application.
  26415. */
  26416. static get ThicknessTextureEnabled(): boolean;
  26417. static set ThicknessTextureEnabled(value: boolean);
  26418. }
  26419. }
  26420. declare module BABYLON {
  26421. /** @hidden */
  26422. export var defaultFragmentDeclaration: {
  26423. name: string;
  26424. shader: string;
  26425. };
  26426. }
  26427. declare module BABYLON {
  26428. /** @hidden */
  26429. export var defaultUboDeclaration: {
  26430. name: string;
  26431. shader: string;
  26432. };
  26433. }
  26434. declare module BABYLON {
  26435. /** @hidden */
  26436. export var lightFragmentDeclaration: {
  26437. name: string;
  26438. shader: string;
  26439. };
  26440. }
  26441. declare module BABYLON {
  26442. /** @hidden */
  26443. export var lightUboDeclaration: {
  26444. name: string;
  26445. shader: string;
  26446. };
  26447. }
  26448. declare module BABYLON {
  26449. /** @hidden */
  26450. export var lightsFragmentFunctions: {
  26451. name: string;
  26452. shader: string;
  26453. };
  26454. }
  26455. declare module BABYLON {
  26456. /** @hidden */
  26457. export var shadowsFragmentFunctions: {
  26458. name: string;
  26459. shader: string;
  26460. };
  26461. }
  26462. declare module BABYLON {
  26463. /** @hidden */
  26464. export var fresnelFunction: {
  26465. name: string;
  26466. shader: string;
  26467. };
  26468. }
  26469. declare module BABYLON {
  26470. /** @hidden */
  26471. export var reflectionFunction: {
  26472. name: string;
  26473. shader: string;
  26474. };
  26475. }
  26476. declare module BABYLON {
  26477. /** @hidden */
  26478. export var bumpFragmentFunctions: {
  26479. name: string;
  26480. shader: string;
  26481. };
  26482. }
  26483. declare module BABYLON {
  26484. /** @hidden */
  26485. export var logDepthDeclaration: {
  26486. name: string;
  26487. shader: string;
  26488. };
  26489. }
  26490. declare module BABYLON {
  26491. /** @hidden */
  26492. export var bumpFragment: {
  26493. name: string;
  26494. shader: string;
  26495. };
  26496. }
  26497. declare module BABYLON {
  26498. /** @hidden */
  26499. export var depthPrePass: {
  26500. name: string;
  26501. shader: string;
  26502. };
  26503. }
  26504. declare module BABYLON {
  26505. /** @hidden */
  26506. export var lightFragment: {
  26507. name: string;
  26508. shader: string;
  26509. };
  26510. }
  26511. declare module BABYLON {
  26512. /** @hidden */
  26513. export var logDepthFragment: {
  26514. name: string;
  26515. shader: string;
  26516. };
  26517. }
  26518. declare module BABYLON {
  26519. /** @hidden */
  26520. export var defaultPixelShader: {
  26521. name: string;
  26522. shader: string;
  26523. };
  26524. }
  26525. declare module BABYLON {
  26526. /** @hidden */
  26527. export var defaultVertexDeclaration: {
  26528. name: string;
  26529. shader: string;
  26530. };
  26531. }
  26532. declare module BABYLON {
  26533. /** @hidden */
  26534. export var bumpVertexDeclaration: {
  26535. name: string;
  26536. shader: string;
  26537. };
  26538. }
  26539. declare module BABYLON {
  26540. /** @hidden */
  26541. export var bumpVertex: {
  26542. name: string;
  26543. shader: string;
  26544. };
  26545. }
  26546. declare module BABYLON {
  26547. /** @hidden */
  26548. export var fogVertex: {
  26549. name: string;
  26550. shader: string;
  26551. };
  26552. }
  26553. declare module BABYLON {
  26554. /** @hidden */
  26555. export var shadowsVertex: {
  26556. name: string;
  26557. shader: string;
  26558. };
  26559. }
  26560. declare module BABYLON {
  26561. /** @hidden */
  26562. export var pointCloudVertex: {
  26563. name: string;
  26564. shader: string;
  26565. };
  26566. }
  26567. declare module BABYLON {
  26568. /** @hidden */
  26569. export var logDepthVertex: {
  26570. name: string;
  26571. shader: string;
  26572. };
  26573. }
  26574. declare module BABYLON {
  26575. /** @hidden */
  26576. export var defaultVertexShader: {
  26577. name: string;
  26578. shader: string;
  26579. };
  26580. }
  26581. declare module BABYLON {
  26582. /** @hidden */
  26583. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26584. MAINUV1: boolean;
  26585. MAINUV2: boolean;
  26586. DIFFUSE: boolean;
  26587. DIFFUSEDIRECTUV: number;
  26588. AMBIENT: boolean;
  26589. AMBIENTDIRECTUV: number;
  26590. OPACITY: boolean;
  26591. OPACITYDIRECTUV: number;
  26592. OPACITYRGB: boolean;
  26593. REFLECTION: boolean;
  26594. EMISSIVE: boolean;
  26595. EMISSIVEDIRECTUV: number;
  26596. SPECULAR: boolean;
  26597. SPECULARDIRECTUV: number;
  26598. BUMP: boolean;
  26599. BUMPDIRECTUV: number;
  26600. PARALLAX: boolean;
  26601. PARALLAXOCCLUSION: boolean;
  26602. SPECULAROVERALPHA: boolean;
  26603. CLIPPLANE: boolean;
  26604. CLIPPLANE2: boolean;
  26605. CLIPPLANE3: boolean;
  26606. CLIPPLANE4: boolean;
  26607. CLIPPLANE5: boolean;
  26608. CLIPPLANE6: boolean;
  26609. ALPHATEST: boolean;
  26610. DEPTHPREPASS: boolean;
  26611. ALPHAFROMDIFFUSE: boolean;
  26612. POINTSIZE: boolean;
  26613. FOG: boolean;
  26614. SPECULARTERM: boolean;
  26615. DIFFUSEFRESNEL: boolean;
  26616. OPACITYFRESNEL: boolean;
  26617. REFLECTIONFRESNEL: boolean;
  26618. REFRACTIONFRESNEL: boolean;
  26619. EMISSIVEFRESNEL: boolean;
  26620. FRESNEL: boolean;
  26621. NORMAL: boolean;
  26622. UV1: boolean;
  26623. UV2: boolean;
  26624. VERTEXCOLOR: boolean;
  26625. VERTEXALPHA: boolean;
  26626. NUM_BONE_INFLUENCERS: number;
  26627. BonesPerMesh: number;
  26628. BONETEXTURE: boolean;
  26629. INSTANCES: boolean;
  26630. GLOSSINESS: boolean;
  26631. ROUGHNESS: boolean;
  26632. EMISSIVEASILLUMINATION: boolean;
  26633. LINKEMISSIVEWITHDIFFUSE: boolean;
  26634. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26635. LIGHTMAP: boolean;
  26636. LIGHTMAPDIRECTUV: number;
  26637. OBJECTSPACE_NORMALMAP: boolean;
  26638. USELIGHTMAPASSHADOWMAP: boolean;
  26639. REFLECTIONMAP_3D: boolean;
  26640. REFLECTIONMAP_SPHERICAL: boolean;
  26641. REFLECTIONMAP_PLANAR: boolean;
  26642. REFLECTIONMAP_CUBIC: boolean;
  26643. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26644. REFLECTIONMAP_PROJECTION: boolean;
  26645. REFLECTIONMAP_SKYBOX: boolean;
  26646. REFLECTIONMAP_EXPLICIT: boolean;
  26647. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26648. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26649. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26650. INVERTCUBICMAP: boolean;
  26651. LOGARITHMICDEPTH: boolean;
  26652. REFRACTION: boolean;
  26653. REFRACTIONMAP_3D: boolean;
  26654. REFLECTIONOVERALPHA: boolean;
  26655. TWOSIDEDLIGHTING: boolean;
  26656. SHADOWFLOAT: boolean;
  26657. MORPHTARGETS: boolean;
  26658. MORPHTARGETS_NORMAL: boolean;
  26659. MORPHTARGETS_TANGENT: boolean;
  26660. MORPHTARGETS_UV: boolean;
  26661. NUM_MORPH_INFLUENCERS: number;
  26662. NONUNIFORMSCALING: boolean;
  26663. PREMULTIPLYALPHA: boolean;
  26664. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26665. ALPHABLEND: boolean;
  26666. IMAGEPROCESSING: boolean;
  26667. VIGNETTE: boolean;
  26668. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26669. VIGNETTEBLENDMODEOPAQUE: boolean;
  26670. TONEMAPPING: boolean;
  26671. TONEMAPPING_ACES: boolean;
  26672. CONTRAST: boolean;
  26673. COLORCURVES: boolean;
  26674. COLORGRADING: boolean;
  26675. COLORGRADING3D: boolean;
  26676. SAMPLER3DGREENDEPTH: boolean;
  26677. SAMPLER3DBGRMAP: boolean;
  26678. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26679. MULTIVIEW: boolean;
  26680. /**
  26681. * If the reflection texture on this material is in linear color space
  26682. * @hidden
  26683. */
  26684. IS_REFLECTION_LINEAR: boolean;
  26685. /**
  26686. * If the refraction texture on this material is in linear color space
  26687. * @hidden
  26688. */
  26689. IS_REFRACTION_LINEAR: boolean;
  26690. EXPOSURE: boolean;
  26691. constructor();
  26692. setReflectionMode(modeToEnable: string): void;
  26693. }
  26694. /**
  26695. * This is the default material used in Babylon. It is the best trade off between quality
  26696. * and performances.
  26697. * @see http://doc.babylonjs.com/babylon101/materials
  26698. */
  26699. export class StandardMaterial extends PushMaterial {
  26700. private _diffuseTexture;
  26701. /**
  26702. * The basic texture of the material as viewed under a light.
  26703. */
  26704. diffuseTexture: Nullable<BaseTexture>;
  26705. private _ambientTexture;
  26706. /**
  26707. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26708. */
  26709. ambientTexture: Nullable<BaseTexture>;
  26710. private _opacityTexture;
  26711. /**
  26712. * Define the transparency of the material from a texture.
  26713. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26714. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26715. */
  26716. opacityTexture: Nullable<BaseTexture>;
  26717. private _reflectionTexture;
  26718. /**
  26719. * Define the texture used to display the reflection.
  26720. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26721. */
  26722. reflectionTexture: Nullable<BaseTexture>;
  26723. private _emissiveTexture;
  26724. /**
  26725. * Define texture of the material as if self lit.
  26726. * This will be mixed in the final result even in the absence of light.
  26727. */
  26728. emissiveTexture: Nullable<BaseTexture>;
  26729. private _specularTexture;
  26730. /**
  26731. * Define how the color and intensity of the highlight given by the light in the material.
  26732. */
  26733. specularTexture: Nullable<BaseTexture>;
  26734. private _bumpTexture;
  26735. /**
  26736. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26737. * 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.
  26738. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26739. */
  26740. bumpTexture: Nullable<BaseTexture>;
  26741. private _lightmapTexture;
  26742. /**
  26743. * Complex lighting can be computationally expensive to compute at runtime.
  26744. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26745. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26746. */
  26747. lightmapTexture: Nullable<BaseTexture>;
  26748. private _refractionTexture;
  26749. /**
  26750. * Define the texture used to display the refraction.
  26751. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26752. */
  26753. refractionTexture: Nullable<BaseTexture>;
  26754. /**
  26755. * The color of the material lit by the environmental background lighting.
  26756. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26757. */
  26758. ambientColor: Color3;
  26759. /**
  26760. * The basic color of the material as viewed under a light.
  26761. */
  26762. diffuseColor: Color3;
  26763. /**
  26764. * Define how the color and intensity of the highlight given by the light in the material.
  26765. */
  26766. specularColor: Color3;
  26767. /**
  26768. * Define the color of the material as if self lit.
  26769. * This will be mixed in the final result even in the absence of light.
  26770. */
  26771. emissiveColor: Color3;
  26772. /**
  26773. * Defines how sharp are the highlights in the material.
  26774. * The bigger the value the sharper giving a more glossy feeling to the result.
  26775. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26776. */
  26777. specularPower: number;
  26778. private _useAlphaFromDiffuseTexture;
  26779. /**
  26780. * Does the transparency come from the diffuse texture alpha channel.
  26781. */
  26782. useAlphaFromDiffuseTexture: boolean;
  26783. private _useEmissiveAsIllumination;
  26784. /**
  26785. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26786. */
  26787. useEmissiveAsIllumination: boolean;
  26788. private _linkEmissiveWithDiffuse;
  26789. /**
  26790. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26791. * the emissive level when the final color is close to one.
  26792. */
  26793. linkEmissiveWithDiffuse: boolean;
  26794. private _useSpecularOverAlpha;
  26795. /**
  26796. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26797. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26798. */
  26799. useSpecularOverAlpha: boolean;
  26800. private _useReflectionOverAlpha;
  26801. /**
  26802. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26803. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26804. */
  26805. useReflectionOverAlpha: boolean;
  26806. private _disableLighting;
  26807. /**
  26808. * Does lights from the scene impacts this material.
  26809. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26810. */
  26811. disableLighting: boolean;
  26812. private _useObjectSpaceNormalMap;
  26813. /**
  26814. * Allows using an object space normal map (instead of tangent space).
  26815. */
  26816. useObjectSpaceNormalMap: boolean;
  26817. private _useParallax;
  26818. /**
  26819. * Is parallax enabled or not.
  26820. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26821. */
  26822. useParallax: boolean;
  26823. private _useParallaxOcclusion;
  26824. /**
  26825. * Is parallax occlusion enabled or not.
  26826. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26827. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26828. */
  26829. useParallaxOcclusion: boolean;
  26830. /**
  26831. * 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.
  26832. */
  26833. parallaxScaleBias: number;
  26834. private _roughness;
  26835. /**
  26836. * Helps to define how blurry the reflections should appears in the material.
  26837. */
  26838. roughness: number;
  26839. /**
  26840. * In case of refraction, define the value of the index of refraction.
  26841. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26842. */
  26843. indexOfRefraction: number;
  26844. /**
  26845. * Invert the refraction texture alongside the y axis.
  26846. * It can be useful with procedural textures or probe for instance.
  26847. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26848. */
  26849. invertRefractionY: boolean;
  26850. /**
  26851. * Defines the alpha limits in alpha test mode.
  26852. */
  26853. alphaCutOff: number;
  26854. private _useLightmapAsShadowmap;
  26855. /**
  26856. * In case of light mapping, define whether the map contains light or shadow informations.
  26857. */
  26858. useLightmapAsShadowmap: boolean;
  26859. private _diffuseFresnelParameters;
  26860. /**
  26861. * Define the diffuse fresnel parameters of the material.
  26862. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26863. */
  26864. diffuseFresnelParameters: FresnelParameters;
  26865. private _opacityFresnelParameters;
  26866. /**
  26867. * Define the opacity fresnel parameters of the material.
  26868. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26869. */
  26870. opacityFresnelParameters: FresnelParameters;
  26871. private _reflectionFresnelParameters;
  26872. /**
  26873. * Define the reflection fresnel parameters of the material.
  26874. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26875. */
  26876. reflectionFresnelParameters: FresnelParameters;
  26877. private _refractionFresnelParameters;
  26878. /**
  26879. * Define the refraction fresnel parameters of the material.
  26880. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26881. */
  26882. refractionFresnelParameters: FresnelParameters;
  26883. private _emissiveFresnelParameters;
  26884. /**
  26885. * Define the emissive fresnel parameters of the material.
  26886. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26887. */
  26888. emissiveFresnelParameters: FresnelParameters;
  26889. private _useReflectionFresnelFromSpecular;
  26890. /**
  26891. * If true automatically deducts the fresnels values from the material specularity.
  26892. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26893. */
  26894. useReflectionFresnelFromSpecular: boolean;
  26895. private _useGlossinessFromSpecularMapAlpha;
  26896. /**
  26897. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26898. */
  26899. useGlossinessFromSpecularMapAlpha: boolean;
  26900. private _maxSimultaneousLights;
  26901. /**
  26902. * Defines the maximum number of lights that can be used in the material
  26903. */
  26904. maxSimultaneousLights: number;
  26905. private _invertNormalMapX;
  26906. /**
  26907. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26908. */
  26909. invertNormalMapX: boolean;
  26910. private _invertNormalMapY;
  26911. /**
  26912. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26913. */
  26914. invertNormalMapY: boolean;
  26915. private _twoSidedLighting;
  26916. /**
  26917. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26918. */
  26919. twoSidedLighting: boolean;
  26920. /**
  26921. * Default configuration related to image processing available in the standard Material.
  26922. */
  26923. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26924. /**
  26925. * Gets the image processing configuration used either in this material.
  26926. */
  26927. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26928. /**
  26929. * Sets the Default image processing configuration used either in the this material.
  26930. *
  26931. * If sets to null, the scene one is in use.
  26932. */
  26933. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26934. /**
  26935. * Keep track of the image processing observer to allow dispose and replace.
  26936. */
  26937. private _imageProcessingObserver;
  26938. /**
  26939. * Attaches a new image processing configuration to the Standard Material.
  26940. * @param configuration
  26941. */
  26942. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26943. /**
  26944. * Gets wether the color curves effect is enabled.
  26945. */
  26946. get cameraColorCurvesEnabled(): boolean;
  26947. /**
  26948. * Sets wether the color curves effect is enabled.
  26949. */
  26950. set cameraColorCurvesEnabled(value: boolean);
  26951. /**
  26952. * Gets wether the color grading effect is enabled.
  26953. */
  26954. get cameraColorGradingEnabled(): boolean;
  26955. /**
  26956. * Gets wether the color grading effect is enabled.
  26957. */
  26958. set cameraColorGradingEnabled(value: boolean);
  26959. /**
  26960. * Gets wether tonemapping is enabled or not.
  26961. */
  26962. get cameraToneMappingEnabled(): boolean;
  26963. /**
  26964. * Sets wether tonemapping is enabled or not
  26965. */
  26966. set cameraToneMappingEnabled(value: boolean);
  26967. /**
  26968. * The camera exposure used on this material.
  26969. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26970. * This corresponds to a photographic exposure.
  26971. */
  26972. get cameraExposure(): number;
  26973. /**
  26974. * The camera exposure used on this material.
  26975. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26976. * This corresponds to a photographic exposure.
  26977. */
  26978. set cameraExposure(value: number);
  26979. /**
  26980. * Gets The camera contrast used on this material.
  26981. */
  26982. get cameraContrast(): number;
  26983. /**
  26984. * Sets The camera contrast used on this material.
  26985. */
  26986. set cameraContrast(value: number);
  26987. /**
  26988. * Gets the Color Grading 2D Lookup Texture.
  26989. */
  26990. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26991. /**
  26992. * Sets the Color Grading 2D Lookup Texture.
  26993. */
  26994. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26995. /**
  26996. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26997. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26998. * 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;
  26999. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27000. */
  27001. get cameraColorCurves(): Nullable<ColorCurves>;
  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. set cameraColorCurves(value: Nullable<ColorCurves>);
  27009. /**
  27010. * Custom callback helping to override the default shader used in the material.
  27011. */
  27012. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27013. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27014. protected _worldViewProjectionMatrix: Matrix;
  27015. protected _globalAmbientColor: Color3;
  27016. protected _useLogarithmicDepth: boolean;
  27017. protected _rebuildInParallel: boolean;
  27018. /**
  27019. * Instantiates a new standard material.
  27020. * This is the default material used in Babylon. It is the best trade off between quality
  27021. * and performances.
  27022. * @see http://doc.babylonjs.com/babylon101/materials
  27023. * @param name Define the name of the material in the scene
  27024. * @param scene Define the scene the material belong to
  27025. */
  27026. constructor(name: string, scene: Scene);
  27027. /**
  27028. * Gets a boolean indicating that current material needs to register RTT
  27029. */
  27030. get hasRenderTargetTextures(): boolean;
  27031. /**
  27032. * Gets the current class name of the material e.g. "StandardMaterial"
  27033. * Mainly use in serialization.
  27034. * @returns the class name
  27035. */
  27036. getClassName(): string;
  27037. /**
  27038. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27039. * You can try switching to logarithmic depth.
  27040. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27041. */
  27042. get useLogarithmicDepth(): boolean;
  27043. set useLogarithmicDepth(value: boolean);
  27044. /**
  27045. * Specifies if the material will require alpha blending
  27046. * @returns a boolean specifying if alpha blending is needed
  27047. */
  27048. needAlphaBlending(): boolean;
  27049. /**
  27050. * Specifies if this material should be rendered in alpha test mode
  27051. * @returns a boolean specifying if an alpha test is needed.
  27052. */
  27053. needAlphaTesting(): boolean;
  27054. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27055. /**
  27056. * Get the texture used for alpha test purpose.
  27057. * @returns the diffuse texture in case of the standard material.
  27058. */
  27059. getAlphaTestTexture(): Nullable<BaseTexture>;
  27060. /**
  27061. * Get if the submesh is ready to be used and all its information available.
  27062. * Child classes can use it to update shaders
  27063. * @param mesh defines the mesh to check
  27064. * @param subMesh defines which submesh to check
  27065. * @param useInstances specifies that instances should be used
  27066. * @returns a boolean indicating that the submesh is ready or not
  27067. */
  27068. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27069. /**
  27070. * Builds the material UBO layouts.
  27071. * Used internally during the effect preparation.
  27072. */
  27073. buildUniformLayout(): void;
  27074. /**
  27075. * Unbinds the material from the mesh
  27076. */
  27077. unbind(): void;
  27078. /**
  27079. * Binds the submesh to this material by preparing the effect and shader to draw
  27080. * @param world defines the world transformation matrix
  27081. * @param mesh defines the mesh containing the submesh
  27082. * @param subMesh defines the submesh to bind the material to
  27083. */
  27084. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27085. /**
  27086. * Get the list of animatables in the material.
  27087. * @returns the list of animatables object used in the material
  27088. */
  27089. getAnimatables(): IAnimatable[];
  27090. /**
  27091. * Gets the active textures from the material
  27092. * @returns an array of textures
  27093. */
  27094. getActiveTextures(): BaseTexture[];
  27095. /**
  27096. * Specifies if the material uses a texture
  27097. * @param texture defines the texture to check against the material
  27098. * @returns a boolean specifying if the material uses the texture
  27099. */
  27100. hasTexture(texture: BaseTexture): boolean;
  27101. /**
  27102. * Disposes the material
  27103. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27104. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27105. */
  27106. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27107. /**
  27108. * Makes a duplicate of the material, and gives it a new name
  27109. * @param name defines the new name for the duplicated material
  27110. * @returns the cloned material
  27111. */
  27112. clone(name: string): StandardMaterial;
  27113. /**
  27114. * Serializes this material in a JSON representation
  27115. * @returns the serialized material object
  27116. */
  27117. serialize(): any;
  27118. /**
  27119. * Creates a standard material from parsed material data
  27120. * @param source defines the JSON representation of the material
  27121. * @param scene defines the hosting scene
  27122. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27123. * @returns a new standard material
  27124. */
  27125. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27126. /**
  27127. * Are diffuse textures enabled in the application.
  27128. */
  27129. static get DiffuseTextureEnabled(): boolean;
  27130. static set DiffuseTextureEnabled(value: boolean);
  27131. /**
  27132. * Are ambient textures enabled in the application.
  27133. */
  27134. static get AmbientTextureEnabled(): boolean;
  27135. static set AmbientTextureEnabled(value: boolean);
  27136. /**
  27137. * Are opacity textures enabled in the application.
  27138. */
  27139. static get OpacityTextureEnabled(): boolean;
  27140. static set OpacityTextureEnabled(value: boolean);
  27141. /**
  27142. * Are reflection textures enabled in the application.
  27143. */
  27144. static get ReflectionTextureEnabled(): boolean;
  27145. static set ReflectionTextureEnabled(value: boolean);
  27146. /**
  27147. * Are emissive textures enabled in the application.
  27148. */
  27149. static get EmissiveTextureEnabled(): boolean;
  27150. static set EmissiveTextureEnabled(value: boolean);
  27151. /**
  27152. * Are specular textures enabled in the application.
  27153. */
  27154. static get SpecularTextureEnabled(): boolean;
  27155. static set SpecularTextureEnabled(value: boolean);
  27156. /**
  27157. * Are bump textures enabled in the application.
  27158. */
  27159. static get BumpTextureEnabled(): boolean;
  27160. static set BumpTextureEnabled(value: boolean);
  27161. /**
  27162. * Are lightmap textures enabled in the application.
  27163. */
  27164. static get LightmapTextureEnabled(): boolean;
  27165. static set LightmapTextureEnabled(value: boolean);
  27166. /**
  27167. * Are refraction textures enabled in the application.
  27168. */
  27169. static get RefractionTextureEnabled(): boolean;
  27170. static set RefractionTextureEnabled(value: boolean);
  27171. /**
  27172. * Are color grading textures enabled in the application.
  27173. */
  27174. static get ColorGradingTextureEnabled(): boolean;
  27175. static set ColorGradingTextureEnabled(value: boolean);
  27176. /**
  27177. * Are fresnels enabled in the application.
  27178. */
  27179. static get FresnelEnabled(): boolean;
  27180. static set FresnelEnabled(value: boolean);
  27181. }
  27182. }
  27183. declare module BABYLON {
  27184. /**
  27185. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27186. *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.
  27187. * The SPS is also a particle system. It provides some methods to manage the particles.
  27188. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27189. *
  27190. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27191. */
  27192. export class SolidParticleSystem implements IDisposable {
  27193. /**
  27194. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27195. * Example : var p = SPS.particles[i];
  27196. */
  27197. particles: SolidParticle[];
  27198. /**
  27199. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27200. */
  27201. nbParticles: number;
  27202. /**
  27203. * If the particles must ever face the camera (default false). Useful for planar particles.
  27204. */
  27205. billboard: boolean;
  27206. /**
  27207. * Recompute normals when adding a shape
  27208. */
  27209. recomputeNormals: boolean;
  27210. /**
  27211. * This a counter ofr your own usage. It's not set by any SPS functions.
  27212. */
  27213. counter: number;
  27214. /**
  27215. * The SPS name. This name is also given to the underlying mesh.
  27216. */
  27217. name: string;
  27218. /**
  27219. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27220. */
  27221. mesh: Mesh;
  27222. /**
  27223. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27224. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27225. */
  27226. vars: any;
  27227. /**
  27228. * This array is populated when the SPS is set as 'pickable'.
  27229. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27230. * Each element of this array is an object `{idx: int, faceId: int}`.
  27231. * `idx` is the picked particle index in the `SPS.particles` array
  27232. * `faceId` is the picked face index counted within this particle.
  27233. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27234. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27235. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27236. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27237. */
  27238. pickedParticles: {
  27239. idx: number;
  27240. faceId: number;
  27241. }[];
  27242. /**
  27243. * This array is populated when the SPS is set as 'pickable'
  27244. * Each key of this array is a submesh index.
  27245. * Each element of this array is a second array defined like this :
  27246. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27247. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27248. * `idx` is the picked particle index in the `SPS.particles` array
  27249. * `faceId` is the picked face index counted within this particle.
  27250. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27251. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27252. */
  27253. pickedBySubMesh: {
  27254. idx: number;
  27255. faceId: number;
  27256. }[][];
  27257. /**
  27258. * This array is populated when `enableDepthSort` is set to true.
  27259. * Each element of this array is an instance of the class DepthSortedParticle.
  27260. */
  27261. depthSortedParticles: DepthSortedParticle[];
  27262. /**
  27263. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27264. * @hidden
  27265. */
  27266. _bSphereOnly: boolean;
  27267. /**
  27268. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27269. * @hidden
  27270. */
  27271. _bSphereRadiusFactor: number;
  27272. private _scene;
  27273. private _positions;
  27274. private _indices;
  27275. private _normals;
  27276. private _colors;
  27277. private _uvs;
  27278. private _indices32;
  27279. private _positions32;
  27280. private _normals32;
  27281. private _fixedNormal32;
  27282. private _colors32;
  27283. private _uvs32;
  27284. private _index;
  27285. private _updatable;
  27286. private _pickable;
  27287. private _isVisibilityBoxLocked;
  27288. private _alwaysVisible;
  27289. private _depthSort;
  27290. private _expandable;
  27291. private _shapeCounter;
  27292. private _copy;
  27293. private _color;
  27294. private _computeParticleColor;
  27295. private _computeParticleTexture;
  27296. private _computeParticleRotation;
  27297. private _computeParticleVertex;
  27298. private _computeBoundingBox;
  27299. private _depthSortParticles;
  27300. private _camera;
  27301. private _mustUnrotateFixedNormals;
  27302. private _particlesIntersect;
  27303. private _needs32Bits;
  27304. private _isNotBuilt;
  27305. private _lastParticleId;
  27306. private _idxOfId;
  27307. private _multimaterialEnabled;
  27308. private _useModelMaterial;
  27309. private _indicesByMaterial;
  27310. private _materialIndexes;
  27311. private _depthSortFunction;
  27312. private _materialSortFunction;
  27313. private _materials;
  27314. private _multimaterial;
  27315. private _materialIndexesById;
  27316. private _defaultMaterial;
  27317. private _autoUpdateSubMeshes;
  27318. /**
  27319. * Creates a SPS (Solid Particle System) object.
  27320. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27321. * @param scene (Scene) is the scene in which the SPS is added.
  27322. * @param options defines the options of the sps e.g.
  27323. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27324. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27325. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27326. * * 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.
  27327. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27328. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27329. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27330. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27331. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27332. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27333. */
  27334. constructor(name: string, scene: Scene, options?: {
  27335. updatable?: boolean;
  27336. isPickable?: boolean;
  27337. enableDepthSort?: boolean;
  27338. particleIntersection?: boolean;
  27339. boundingSphereOnly?: boolean;
  27340. bSphereRadiusFactor?: number;
  27341. expandable?: boolean;
  27342. useModelMaterial?: boolean;
  27343. enableMultiMaterial?: boolean;
  27344. });
  27345. /**
  27346. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27347. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27348. * @returns the created mesh
  27349. */
  27350. buildMesh(): Mesh;
  27351. /**
  27352. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27353. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27354. * Thus the particles generated from `digest()` have their property `position` set yet.
  27355. * @param mesh ( Mesh ) is the mesh to be digested
  27356. * @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
  27357. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27358. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27359. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27360. * @returns the current SPS
  27361. */
  27362. digest(mesh: Mesh, options?: {
  27363. facetNb?: number;
  27364. number?: number;
  27365. delta?: number;
  27366. storage?: [];
  27367. }): SolidParticleSystem;
  27368. /**
  27369. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27370. * @hidden
  27371. */
  27372. private _unrotateFixedNormals;
  27373. /**
  27374. * Resets the temporary working copy particle
  27375. * @hidden
  27376. */
  27377. private _resetCopy;
  27378. /**
  27379. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27380. * @param p the current index in the positions array to be updated
  27381. * @param ind the current index in the indices array
  27382. * @param shape a Vector3 array, the shape geometry
  27383. * @param positions the positions array to be updated
  27384. * @param meshInd the shape indices array
  27385. * @param indices the indices array to be updated
  27386. * @param meshUV the shape uv array
  27387. * @param uvs the uv array to be updated
  27388. * @param meshCol the shape color array
  27389. * @param colors the color array to be updated
  27390. * @param meshNor the shape normals array
  27391. * @param normals the normals array to be updated
  27392. * @param idx the particle index
  27393. * @param idxInShape the particle index in its shape
  27394. * @param options the addShape() method passed options
  27395. * @model the particle model
  27396. * @hidden
  27397. */
  27398. private _meshBuilder;
  27399. /**
  27400. * Returns a shape Vector3 array from positions float array
  27401. * @param positions float array
  27402. * @returns a vector3 array
  27403. * @hidden
  27404. */
  27405. private _posToShape;
  27406. /**
  27407. * Returns a shapeUV array from a float uvs (array deep copy)
  27408. * @param uvs as a float array
  27409. * @returns a shapeUV array
  27410. * @hidden
  27411. */
  27412. private _uvsToShapeUV;
  27413. /**
  27414. * Adds a new particle object in the particles array
  27415. * @param idx particle index in particles array
  27416. * @param id particle id
  27417. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27418. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27419. * @param model particle ModelShape object
  27420. * @param shapeId model shape identifier
  27421. * @param idxInShape index of the particle in the current model
  27422. * @param bInfo model bounding info object
  27423. * @param storage target storage array, if any
  27424. * @hidden
  27425. */
  27426. private _addParticle;
  27427. /**
  27428. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27429. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27430. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27431. * @param nb (positive integer) the number of particles to be created from this model
  27432. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27433. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27434. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27435. * @returns the number of shapes in the system
  27436. */
  27437. addShape(mesh: Mesh, nb: number, options?: {
  27438. positionFunction?: any;
  27439. vertexFunction?: any;
  27440. storage?: [];
  27441. }): number;
  27442. /**
  27443. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27444. * @hidden
  27445. */
  27446. private _rebuildParticle;
  27447. /**
  27448. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27449. * @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.
  27450. * @returns the SPS.
  27451. */
  27452. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27453. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27454. * Returns an array with the removed particles.
  27455. * 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.
  27456. * The SPS can't be empty so at least one particle needs to remain in place.
  27457. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27458. * @param start index of the first particle to remove
  27459. * @param end index of the last particle to remove (included)
  27460. * @returns an array populated with the removed particles
  27461. */
  27462. removeParticles(start: number, end: number): SolidParticle[];
  27463. /**
  27464. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27465. * @param solidParticleArray an array populated with Solid Particles objects
  27466. * @returns the SPS
  27467. */
  27468. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27469. /**
  27470. * Creates a new particle and modifies the SPS mesh geometry :
  27471. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27472. * - calls _addParticle() to populate the particle array
  27473. * factorized code from addShape() and insertParticlesFromArray()
  27474. * @param idx particle index in the particles array
  27475. * @param i particle index in its shape
  27476. * @param modelShape particle ModelShape object
  27477. * @param shape shape vertex array
  27478. * @param meshInd shape indices array
  27479. * @param meshUV shape uv array
  27480. * @param meshCol shape color array
  27481. * @param meshNor shape normals array
  27482. * @param bbInfo shape bounding info
  27483. * @param storage target particle storage
  27484. * @options addShape() passed options
  27485. * @hidden
  27486. */
  27487. private _insertNewParticle;
  27488. /**
  27489. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27490. * This method calls `updateParticle()` for each particle of the SPS.
  27491. * For an animated SPS, it is usually called within the render loop.
  27492. * 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.
  27493. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27494. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27495. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27496. * @returns the SPS.
  27497. */
  27498. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27499. /**
  27500. * Disposes the SPS.
  27501. */
  27502. dispose(): void;
  27503. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27504. * idx is the particle index in the SPS
  27505. * faceId is the picked face index counted within this particle.
  27506. * Returns null if the pickInfo can't identify a picked particle.
  27507. * @param pickingInfo (PickingInfo object)
  27508. * @returns {idx: number, faceId: number} or null
  27509. */
  27510. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27511. idx: number;
  27512. faceId: number;
  27513. }>;
  27514. /**
  27515. * Returns a SolidParticle object from its identifier : particle.id
  27516. * @param id (integer) the particle Id
  27517. * @returns the searched particle or null if not found in the SPS.
  27518. */
  27519. getParticleById(id: number): Nullable<SolidParticle>;
  27520. /**
  27521. * Returns a new array populated with the particles having the passed shapeId.
  27522. * @param shapeId (integer) the shape identifier
  27523. * @returns a new solid particle array
  27524. */
  27525. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27526. /**
  27527. * Populates the passed array "ref" with the particles having the passed shapeId.
  27528. * @param shapeId the shape identifier
  27529. * @returns the SPS
  27530. * @param ref
  27531. */
  27532. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27533. /**
  27534. * Computes the required SubMeshes according the materials assigned to the particles.
  27535. * @returns the solid particle system.
  27536. * Does nothing if called before the SPS mesh is built.
  27537. */
  27538. computeSubMeshes(): SolidParticleSystem;
  27539. /**
  27540. * Sorts the solid particles by material when MultiMaterial is enabled.
  27541. * Updates the indices32 array.
  27542. * Updates the indicesByMaterial array.
  27543. * Updates the mesh indices array.
  27544. * @returns the SPS
  27545. * @hidden
  27546. */
  27547. private _sortParticlesByMaterial;
  27548. /**
  27549. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27550. * @hidden
  27551. */
  27552. private _setMaterialIndexesById;
  27553. /**
  27554. * Returns an array with unique values of Materials from the passed array
  27555. * @param array the material array to be checked and filtered
  27556. * @hidden
  27557. */
  27558. private _filterUniqueMaterialId;
  27559. /**
  27560. * Sets a new Standard Material as _defaultMaterial if not already set.
  27561. * @hidden
  27562. */
  27563. private _setDefaultMaterial;
  27564. /**
  27565. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27566. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27567. * @returns the SPS.
  27568. */
  27569. refreshVisibleSize(): SolidParticleSystem;
  27570. /**
  27571. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27572. * @param size the size (float) of the visibility box
  27573. * note : this doesn't lock the SPS mesh bounding box.
  27574. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27575. */
  27576. setVisibilityBox(size: number): void;
  27577. /**
  27578. * Gets whether the SPS as always visible or not
  27579. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27580. */
  27581. get isAlwaysVisible(): boolean;
  27582. /**
  27583. * Sets the SPS as always visible or not
  27584. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27585. */
  27586. set isAlwaysVisible(val: boolean);
  27587. /**
  27588. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27589. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27590. */
  27591. set isVisibilityBoxLocked(val: boolean);
  27592. /**
  27593. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27594. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27595. */
  27596. get isVisibilityBoxLocked(): boolean;
  27597. /**
  27598. * Tells to `setParticles()` to compute the particle rotations or not.
  27599. * Default value : true. The SPS is faster when it's set to false.
  27600. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27601. */
  27602. set computeParticleRotation(val: boolean);
  27603. /**
  27604. * Tells to `setParticles()` to compute the particle colors or not.
  27605. * Default value : true. The SPS is faster when it's set to false.
  27606. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27607. */
  27608. set computeParticleColor(val: boolean);
  27609. set computeParticleTexture(val: boolean);
  27610. /**
  27611. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27612. * Default value : false. The SPS is faster when it's set to false.
  27613. * Note : the particle custom vertex positions aren't stored values.
  27614. */
  27615. set computeParticleVertex(val: boolean);
  27616. /**
  27617. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27618. */
  27619. set computeBoundingBox(val: boolean);
  27620. /**
  27621. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27622. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27623. * Default : `true`
  27624. */
  27625. set depthSortParticles(val: boolean);
  27626. /**
  27627. * Gets if `setParticles()` computes the particle rotations or not.
  27628. * Default value : true. The SPS is faster when it's set to false.
  27629. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27630. */
  27631. get computeParticleRotation(): boolean;
  27632. /**
  27633. * Gets if `setParticles()` computes the particle colors or not.
  27634. * Default value : true. The SPS is faster when it's set to false.
  27635. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27636. */
  27637. get computeParticleColor(): boolean;
  27638. /**
  27639. * Gets if `setParticles()` computes the particle textures or not.
  27640. * Default value : true. The SPS is faster when it's set to false.
  27641. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27642. */
  27643. get computeParticleTexture(): boolean;
  27644. /**
  27645. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27646. * Default value : false. The SPS is faster when it's set to false.
  27647. * Note : the particle custom vertex positions aren't stored values.
  27648. */
  27649. get computeParticleVertex(): boolean;
  27650. /**
  27651. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27652. */
  27653. get computeBoundingBox(): boolean;
  27654. /**
  27655. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27656. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27657. * Default : `true`
  27658. */
  27659. get depthSortParticles(): boolean;
  27660. /**
  27661. * Gets if the SPS is created as expandable at construction time.
  27662. * Default : `false`
  27663. */
  27664. get expandable(): boolean;
  27665. /**
  27666. * Gets if the SPS supports the Multi Materials
  27667. */
  27668. get multimaterialEnabled(): boolean;
  27669. /**
  27670. * Gets if the SPS uses the model materials for its own multimaterial.
  27671. */
  27672. get useModelMaterial(): boolean;
  27673. /**
  27674. * The SPS used material array.
  27675. */
  27676. get materials(): Material[];
  27677. /**
  27678. * Sets the SPS MultiMaterial from the passed materials.
  27679. * Note : the passed array is internally copied and not used then by reference.
  27680. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27681. */
  27682. setMultiMaterial(materials: Material[]): void;
  27683. /**
  27684. * The SPS computed multimaterial object
  27685. */
  27686. get multimaterial(): MultiMaterial;
  27687. set multimaterial(mm: MultiMaterial);
  27688. /**
  27689. * If the subMeshes must be updated on the next call to setParticles()
  27690. */
  27691. get autoUpdateSubMeshes(): boolean;
  27692. set autoUpdateSubMeshes(val: boolean);
  27693. /**
  27694. * This function does nothing. It may be overwritten to set all the particle first values.
  27695. * The SPS doesn't call this function, you may have to call it by your own.
  27696. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27697. */
  27698. initParticles(): void;
  27699. /**
  27700. * This function does nothing. It may be overwritten to recycle a particle.
  27701. * The SPS doesn't call this function, you may have to call it by your own.
  27702. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27703. * @param particle The particle to recycle
  27704. * @returns the recycled particle
  27705. */
  27706. recycleParticle(particle: SolidParticle): SolidParticle;
  27707. /**
  27708. * Updates a particle : this function should be overwritten by the user.
  27709. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27710. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27711. * @example : just set a particle position or velocity and recycle conditions
  27712. * @param particle The particle to update
  27713. * @returns the updated particle
  27714. */
  27715. updateParticle(particle: SolidParticle): SolidParticle;
  27716. /**
  27717. * Updates a vertex of a particle : it can be overwritten by the user.
  27718. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27719. * @param particle the current particle
  27720. * @param vertex the current index of the current particle
  27721. * @param pt the index of the current vertex in the particle shape
  27722. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27723. * @example : just set a vertex particle position
  27724. * @returns the updated vertex
  27725. */
  27726. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27727. /**
  27728. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27729. * This does nothing and may be overwritten by the user.
  27730. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27731. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27732. * @param update the boolean update value actually passed to setParticles()
  27733. */
  27734. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27735. /**
  27736. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27737. * This will be passed three parameters.
  27738. * This does nothing and may be overwritten by the user.
  27739. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27740. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27741. * @param update the boolean update value actually passed to setParticles()
  27742. */
  27743. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27744. }
  27745. }
  27746. declare module BABYLON {
  27747. /**
  27748. * Represents one particle of a solid particle system.
  27749. */
  27750. export class SolidParticle {
  27751. /**
  27752. * particle global index
  27753. */
  27754. idx: number;
  27755. /**
  27756. * particle identifier
  27757. */
  27758. id: number;
  27759. /**
  27760. * The color of the particle
  27761. */
  27762. color: Nullable<Color4>;
  27763. /**
  27764. * The world space position of the particle.
  27765. */
  27766. position: Vector3;
  27767. /**
  27768. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27769. */
  27770. rotation: Vector3;
  27771. /**
  27772. * The world space rotation quaternion of the particle.
  27773. */
  27774. rotationQuaternion: Nullable<Quaternion>;
  27775. /**
  27776. * The scaling of the particle.
  27777. */
  27778. scaling: Vector3;
  27779. /**
  27780. * The uvs of the particle.
  27781. */
  27782. uvs: Vector4;
  27783. /**
  27784. * The current speed of the particle.
  27785. */
  27786. velocity: Vector3;
  27787. /**
  27788. * The pivot point in the particle local space.
  27789. */
  27790. pivot: Vector3;
  27791. /**
  27792. * Must the particle be translated from its pivot point in its local space ?
  27793. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27794. * Default : false
  27795. */
  27796. translateFromPivot: boolean;
  27797. /**
  27798. * Is the particle active or not ?
  27799. */
  27800. alive: boolean;
  27801. /**
  27802. * Is the particle visible or not ?
  27803. */
  27804. isVisible: boolean;
  27805. /**
  27806. * Index of this particle in the global "positions" array (Internal use)
  27807. * @hidden
  27808. */
  27809. _pos: number;
  27810. /**
  27811. * @hidden Index of this particle in the global "indices" array (Internal use)
  27812. */
  27813. _ind: number;
  27814. /**
  27815. * @hidden ModelShape of this particle (Internal use)
  27816. */
  27817. _model: ModelShape;
  27818. /**
  27819. * ModelShape id of this particle
  27820. */
  27821. shapeId: number;
  27822. /**
  27823. * Index of the particle in its shape id
  27824. */
  27825. idxInShape: number;
  27826. /**
  27827. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27828. */
  27829. _modelBoundingInfo: BoundingInfo;
  27830. /**
  27831. * @hidden Particle BoundingInfo object (Internal use)
  27832. */
  27833. _boundingInfo: BoundingInfo;
  27834. /**
  27835. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27836. */
  27837. _sps: SolidParticleSystem;
  27838. /**
  27839. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27840. */
  27841. _stillInvisible: boolean;
  27842. /**
  27843. * @hidden Last computed particle rotation matrix
  27844. */
  27845. _rotationMatrix: number[];
  27846. /**
  27847. * Parent particle Id, if any.
  27848. * Default null.
  27849. */
  27850. parentId: Nullable<number>;
  27851. /**
  27852. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27853. */
  27854. materialIndex: Nullable<number>;
  27855. /**
  27856. * Custom object or properties.
  27857. */
  27858. props: Nullable<any>;
  27859. /**
  27860. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27861. * The possible values are :
  27862. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27863. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27864. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27865. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27866. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27867. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27868. * */
  27869. cullingStrategy: number;
  27870. /**
  27871. * @hidden Internal global position in the SPS.
  27872. */
  27873. _globalPosition: Vector3;
  27874. /**
  27875. * Creates a Solid Particle object.
  27876. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27877. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27878. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27879. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27880. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27881. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27882. * @param shapeId (integer) is the model shape identifier in the SPS.
  27883. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27884. * @param sps defines the sps it is associated to
  27885. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27886. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27887. */
  27888. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27889. /**
  27890. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27891. * @param target the particle target
  27892. * @returns the current particle
  27893. */
  27894. copyToRef(target: SolidParticle): SolidParticle;
  27895. /**
  27896. * Legacy support, changed scale to scaling
  27897. */
  27898. get scale(): Vector3;
  27899. /**
  27900. * Legacy support, changed scale to scaling
  27901. */
  27902. set scale(scale: Vector3);
  27903. /**
  27904. * Legacy support, changed quaternion to rotationQuaternion
  27905. */
  27906. get quaternion(): Nullable<Quaternion>;
  27907. /**
  27908. * Legacy support, changed quaternion to rotationQuaternion
  27909. */
  27910. set quaternion(q: Nullable<Quaternion>);
  27911. /**
  27912. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27913. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27914. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27915. * @returns true if it intersects
  27916. */
  27917. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27918. /**
  27919. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27920. * A particle is in the frustum if its bounding box intersects the frustum
  27921. * @param frustumPlanes defines the frustum to test
  27922. * @returns true if the particle is in the frustum planes
  27923. */
  27924. isInFrustum(frustumPlanes: Plane[]): boolean;
  27925. /**
  27926. * get the rotation matrix of the particle
  27927. * @hidden
  27928. */
  27929. getRotationMatrix(m: Matrix): void;
  27930. }
  27931. /**
  27932. * Represents the shape of the model used by one particle of a solid particle system.
  27933. * SPS internal tool, don't use it manually.
  27934. */
  27935. export class ModelShape {
  27936. /**
  27937. * The shape id
  27938. * @hidden
  27939. */
  27940. shapeID: number;
  27941. /**
  27942. * flat array of model positions (internal use)
  27943. * @hidden
  27944. */
  27945. _shape: Vector3[];
  27946. /**
  27947. * flat array of model UVs (internal use)
  27948. * @hidden
  27949. */
  27950. _shapeUV: number[];
  27951. /**
  27952. * color array of the model
  27953. * @hidden
  27954. */
  27955. _shapeColors: number[];
  27956. /**
  27957. * indices array of the model
  27958. * @hidden
  27959. */
  27960. _indices: number[];
  27961. /**
  27962. * normals array of the model
  27963. * @hidden
  27964. */
  27965. _normals: number[];
  27966. /**
  27967. * length of the shape in the model indices array (internal use)
  27968. * @hidden
  27969. */
  27970. _indicesLength: number;
  27971. /**
  27972. * Custom position function (internal use)
  27973. * @hidden
  27974. */
  27975. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27976. /**
  27977. * Custom vertex function (internal use)
  27978. * @hidden
  27979. */
  27980. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27981. /**
  27982. * Model material (internal use)
  27983. * @hidden
  27984. */
  27985. _material: Nullable<Material>;
  27986. /**
  27987. * 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.
  27988. * SPS internal tool, don't use it manually.
  27989. * @hidden
  27990. */
  27991. 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>);
  27992. }
  27993. /**
  27994. * Represents a Depth Sorted Particle in the solid particle system.
  27995. * @hidden
  27996. */
  27997. export class DepthSortedParticle {
  27998. /**
  27999. * Particle index
  28000. */
  28001. idx: number;
  28002. /**
  28003. * Index of the particle in the "indices" array
  28004. */
  28005. ind: number;
  28006. /**
  28007. * Length of the particle shape in the "indices" array
  28008. */
  28009. indicesLength: number;
  28010. /**
  28011. * Squared distance from the particle to the camera
  28012. */
  28013. sqDistance: number;
  28014. /**
  28015. * Material index when used with MultiMaterials
  28016. */
  28017. materialIndex: number;
  28018. /**
  28019. * Creates a new sorted particle
  28020. * @param materialIndex
  28021. */
  28022. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28023. }
  28024. }
  28025. declare module BABYLON {
  28026. /**
  28027. * @hidden
  28028. */
  28029. export class _MeshCollisionData {
  28030. _checkCollisions: boolean;
  28031. _collisionMask: number;
  28032. _collisionGroup: number;
  28033. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28034. _collider: Nullable<Collider>;
  28035. _oldPositionForCollisions: Vector3;
  28036. _diffPositionForCollisions: Vector3;
  28037. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28038. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28039. }
  28040. }
  28041. declare module BABYLON {
  28042. /** @hidden */
  28043. class _FacetDataStorage {
  28044. facetPositions: Vector3[];
  28045. facetNormals: Vector3[];
  28046. facetPartitioning: number[][];
  28047. facetNb: number;
  28048. partitioningSubdivisions: number;
  28049. partitioningBBoxRatio: number;
  28050. facetDataEnabled: boolean;
  28051. facetParameters: any;
  28052. bbSize: Vector3;
  28053. subDiv: {
  28054. max: number;
  28055. X: number;
  28056. Y: number;
  28057. Z: number;
  28058. };
  28059. facetDepthSort: boolean;
  28060. facetDepthSortEnabled: boolean;
  28061. depthSortedIndices: IndicesArray;
  28062. depthSortedFacets: {
  28063. ind: number;
  28064. sqDistance: number;
  28065. }[];
  28066. facetDepthSortFunction: (f1: {
  28067. ind: number;
  28068. sqDistance: number;
  28069. }, f2: {
  28070. ind: number;
  28071. sqDistance: number;
  28072. }) => number;
  28073. facetDepthSortFrom: Vector3;
  28074. facetDepthSortOrigin: Vector3;
  28075. invertedMatrix: Matrix;
  28076. }
  28077. /**
  28078. * @hidden
  28079. **/
  28080. class _InternalAbstractMeshDataInfo {
  28081. _hasVertexAlpha: boolean;
  28082. _useVertexColors: boolean;
  28083. _numBoneInfluencers: number;
  28084. _applyFog: boolean;
  28085. _receiveShadows: boolean;
  28086. _facetData: _FacetDataStorage;
  28087. _visibility: number;
  28088. _skeleton: Nullable<Skeleton>;
  28089. _layerMask: number;
  28090. _computeBonesUsingShaders: boolean;
  28091. _isActive: boolean;
  28092. _onlyForInstances: boolean;
  28093. _isActiveIntermediate: boolean;
  28094. _onlyForInstancesIntermediate: boolean;
  28095. _actAsRegularMesh: boolean;
  28096. }
  28097. /**
  28098. * Class used to store all common mesh properties
  28099. */
  28100. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28101. /** No occlusion */
  28102. static OCCLUSION_TYPE_NONE: number;
  28103. /** Occlusion set to optimisitic */
  28104. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28105. /** Occlusion set to strict */
  28106. static OCCLUSION_TYPE_STRICT: number;
  28107. /** Use an accurante occlusion algorithm */
  28108. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28109. /** Use a conservative occlusion algorithm */
  28110. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28111. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28112. * Test order :
  28113. * Is the bounding sphere outside the frustum ?
  28114. * If not, are the bounding box vertices outside the frustum ?
  28115. * It not, then the cullable object is in the frustum.
  28116. */
  28117. static readonly CULLINGSTRATEGY_STANDARD: number;
  28118. /** Culling strategy : Bounding Sphere Only.
  28119. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28120. * It's also less accurate than the standard because some not visible objects can still be selected.
  28121. * Test : is the bounding sphere outside the frustum ?
  28122. * If not, then the cullable object is in the frustum.
  28123. */
  28124. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28125. /** Culling strategy : Optimistic Inclusion.
  28126. * This in an inclusion test first, then the standard exclusion test.
  28127. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28128. * 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.
  28129. * Anyway, it's as accurate as the standard strategy.
  28130. * Test :
  28131. * Is the cullable object bounding sphere center in the frustum ?
  28132. * If not, apply the default culling strategy.
  28133. */
  28134. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28135. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28136. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28137. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28138. * 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.
  28139. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28140. * Test :
  28141. * Is the cullable object bounding sphere center in the frustum ?
  28142. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28143. */
  28144. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28145. /**
  28146. * No billboard
  28147. */
  28148. static get BILLBOARDMODE_NONE(): number;
  28149. /** Billboard on X axis */
  28150. static get BILLBOARDMODE_X(): number;
  28151. /** Billboard on Y axis */
  28152. static get BILLBOARDMODE_Y(): number;
  28153. /** Billboard on Z axis */
  28154. static get BILLBOARDMODE_Z(): number;
  28155. /** Billboard on all axes */
  28156. static get BILLBOARDMODE_ALL(): number;
  28157. /** Billboard on using position instead of orientation */
  28158. static get BILLBOARDMODE_USE_POSITION(): number;
  28159. /** @hidden */
  28160. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28161. /**
  28162. * The culling strategy to use to check whether the mesh must be rendered or not.
  28163. * This value can be changed at any time and will be used on the next render mesh selection.
  28164. * The possible values are :
  28165. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28166. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28167. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28168. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28169. * Please read each static variable documentation to get details about the culling process.
  28170. * */
  28171. cullingStrategy: number;
  28172. /**
  28173. * Gets the number of facets in the mesh
  28174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28175. */
  28176. get facetNb(): number;
  28177. /**
  28178. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28179. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28180. */
  28181. get partitioningSubdivisions(): number;
  28182. set partitioningSubdivisions(nb: number);
  28183. /**
  28184. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28185. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28186. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28187. */
  28188. get partitioningBBoxRatio(): number;
  28189. set partitioningBBoxRatio(ratio: number);
  28190. /**
  28191. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28192. * Works only for updatable meshes.
  28193. * Doesn't work with multi-materials
  28194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28195. */
  28196. get mustDepthSortFacets(): boolean;
  28197. set mustDepthSortFacets(sort: boolean);
  28198. /**
  28199. * The location (Vector3) where the facet depth sort must be computed from.
  28200. * By default, the active camera position.
  28201. * Used only when facet depth sort is enabled
  28202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28203. */
  28204. get facetDepthSortFrom(): Vector3;
  28205. set facetDepthSortFrom(location: Vector3);
  28206. /**
  28207. * gets a boolean indicating if facetData is enabled
  28208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28209. */
  28210. get isFacetDataEnabled(): boolean;
  28211. /** @hidden */
  28212. _updateNonUniformScalingState(value: boolean): boolean;
  28213. /**
  28214. * An event triggered when this mesh collides with another one
  28215. */
  28216. onCollideObservable: Observable<AbstractMesh>;
  28217. /** Set a function to call when this mesh collides with another one */
  28218. set onCollide(callback: () => void);
  28219. /**
  28220. * An event triggered when the collision's position changes
  28221. */
  28222. onCollisionPositionChangeObservable: Observable<Vector3>;
  28223. /** Set a function to call when the collision's position changes */
  28224. set onCollisionPositionChange(callback: () => void);
  28225. /**
  28226. * An event triggered when material is changed
  28227. */
  28228. onMaterialChangedObservable: Observable<AbstractMesh>;
  28229. /**
  28230. * Gets or sets the orientation for POV movement & rotation
  28231. */
  28232. definedFacingForward: boolean;
  28233. /** @hidden */
  28234. _occlusionQuery: Nullable<WebGLQuery>;
  28235. /** @hidden */
  28236. _renderingGroup: Nullable<RenderingGroup>;
  28237. /**
  28238. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28239. */
  28240. get visibility(): number;
  28241. /**
  28242. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28243. */
  28244. set visibility(value: number);
  28245. /** Gets or sets the alpha index used to sort transparent meshes
  28246. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28247. */
  28248. alphaIndex: number;
  28249. /**
  28250. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28251. */
  28252. isVisible: boolean;
  28253. /**
  28254. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28255. */
  28256. isPickable: boolean;
  28257. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28258. showSubMeshesBoundingBox: boolean;
  28259. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28260. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28261. */
  28262. isBlocker: boolean;
  28263. /**
  28264. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28265. */
  28266. enablePointerMoveEvents: boolean;
  28267. /**
  28268. * Specifies the rendering group id for this mesh (0 by default)
  28269. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28270. */
  28271. renderingGroupId: number;
  28272. private _material;
  28273. /** Gets or sets current material */
  28274. get material(): Nullable<Material>;
  28275. set material(value: Nullable<Material>);
  28276. /**
  28277. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28278. * @see http://doc.babylonjs.com/babylon101/shadows
  28279. */
  28280. get receiveShadows(): boolean;
  28281. set receiveShadows(value: boolean);
  28282. /** Defines color to use when rendering outline */
  28283. outlineColor: Color3;
  28284. /** Define width to use when rendering outline */
  28285. outlineWidth: number;
  28286. /** Defines color to use when rendering overlay */
  28287. overlayColor: Color3;
  28288. /** Defines alpha to use when rendering overlay */
  28289. overlayAlpha: number;
  28290. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28291. get hasVertexAlpha(): boolean;
  28292. set hasVertexAlpha(value: boolean);
  28293. /** 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) */
  28294. get useVertexColors(): boolean;
  28295. set useVertexColors(value: boolean);
  28296. /**
  28297. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28298. */
  28299. get computeBonesUsingShaders(): boolean;
  28300. set computeBonesUsingShaders(value: boolean);
  28301. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28302. get numBoneInfluencers(): number;
  28303. set numBoneInfluencers(value: number);
  28304. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28305. get applyFog(): boolean;
  28306. set applyFog(value: boolean);
  28307. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28308. useOctreeForRenderingSelection: boolean;
  28309. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28310. useOctreeForPicking: boolean;
  28311. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28312. useOctreeForCollisions: boolean;
  28313. /**
  28314. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28315. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28316. */
  28317. get layerMask(): number;
  28318. set layerMask(value: number);
  28319. /**
  28320. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28321. */
  28322. alwaysSelectAsActiveMesh: boolean;
  28323. /**
  28324. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28325. */
  28326. doNotSyncBoundingInfo: boolean;
  28327. /**
  28328. * Gets or sets the current action manager
  28329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28330. */
  28331. actionManager: Nullable<AbstractActionManager>;
  28332. private _meshCollisionData;
  28333. /**
  28334. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28335. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28336. */
  28337. ellipsoid: Vector3;
  28338. /**
  28339. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28340. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28341. */
  28342. ellipsoidOffset: Vector3;
  28343. /**
  28344. * Gets or sets a collision mask used to mask collisions (default is -1).
  28345. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28346. */
  28347. get collisionMask(): number;
  28348. set collisionMask(mask: number);
  28349. /**
  28350. * Gets or sets the current collision group mask (-1 by default).
  28351. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28352. */
  28353. get collisionGroup(): number;
  28354. set collisionGroup(mask: number);
  28355. /**
  28356. * Gets or sets current surrounding meshes (null by default).
  28357. *
  28358. * By default collision detection is tested against every mesh in the scene.
  28359. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28360. * meshes will be tested for the collision.
  28361. *
  28362. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28363. */
  28364. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28365. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28366. /**
  28367. * Defines edge width used when edgesRenderer is enabled
  28368. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28369. */
  28370. edgesWidth: number;
  28371. /**
  28372. * Defines edge color used when edgesRenderer is enabled
  28373. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28374. */
  28375. edgesColor: Color4;
  28376. /** @hidden */
  28377. _edgesRenderer: Nullable<IEdgesRenderer>;
  28378. /** @hidden */
  28379. _masterMesh: Nullable<AbstractMesh>;
  28380. /** @hidden */
  28381. _boundingInfo: Nullable<BoundingInfo>;
  28382. /** @hidden */
  28383. _renderId: number;
  28384. /**
  28385. * Gets or sets the list of subMeshes
  28386. * @see http://doc.babylonjs.com/how_to/multi_materials
  28387. */
  28388. subMeshes: SubMesh[];
  28389. /** @hidden */
  28390. _intersectionsInProgress: AbstractMesh[];
  28391. /** @hidden */
  28392. _unIndexed: boolean;
  28393. /** @hidden */
  28394. _lightSources: Light[];
  28395. /** Gets the list of lights affecting that mesh */
  28396. get lightSources(): Light[];
  28397. /** @hidden */
  28398. get _positions(): Nullable<Vector3[]>;
  28399. /** @hidden */
  28400. _waitingData: {
  28401. lods: Nullable<any>;
  28402. actions: Nullable<any>;
  28403. freezeWorldMatrix: Nullable<boolean>;
  28404. };
  28405. /** @hidden */
  28406. _bonesTransformMatrices: Nullable<Float32Array>;
  28407. /** @hidden */
  28408. _transformMatrixTexture: Nullable<RawTexture>;
  28409. /**
  28410. * Gets or sets a skeleton to apply skining transformations
  28411. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28412. */
  28413. set skeleton(value: Nullable<Skeleton>);
  28414. get skeleton(): Nullable<Skeleton>;
  28415. /**
  28416. * An event triggered when the mesh is rebuilt.
  28417. */
  28418. onRebuildObservable: Observable<AbstractMesh>;
  28419. /**
  28420. * Creates a new AbstractMesh
  28421. * @param name defines the name of the mesh
  28422. * @param scene defines the hosting scene
  28423. */
  28424. constructor(name: string, scene?: Nullable<Scene>);
  28425. /**
  28426. * Returns the string "AbstractMesh"
  28427. * @returns "AbstractMesh"
  28428. */
  28429. getClassName(): string;
  28430. /**
  28431. * Gets a string representation of the current mesh
  28432. * @param fullDetails defines a boolean indicating if full details must be included
  28433. * @returns a string representation of the current mesh
  28434. */
  28435. toString(fullDetails?: boolean): string;
  28436. /**
  28437. * @hidden
  28438. */
  28439. protected _getEffectiveParent(): Nullable<Node>;
  28440. /** @hidden */
  28441. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28442. /** @hidden */
  28443. _rebuild(): void;
  28444. /** @hidden */
  28445. _resyncLightSources(): void;
  28446. /** @hidden */
  28447. _resyncLightSource(light: Light): void;
  28448. /** @hidden */
  28449. _unBindEffect(): void;
  28450. /** @hidden */
  28451. _removeLightSource(light: Light, dispose: boolean): void;
  28452. private _markSubMeshesAsDirty;
  28453. /** @hidden */
  28454. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28455. /** @hidden */
  28456. _markSubMeshesAsAttributesDirty(): void;
  28457. /** @hidden */
  28458. _markSubMeshesAsMiscDirty(): void;
  28459. /**
  28460. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28461. */
  28462. get scaling(): Vector3;
  28463. set scaling(newScaling: Vector3);
  28464. /**
  28465. * Returns true if the mesh is blocked. Implemented by child classes
  28466. */
  28467. get isBlocked(): boolean;
  28468. /**
  28469. * Returns the mesh itself by default. Implemented by child classes
  28470. * @param camera defines the camera to use to pick the right LOD level
  28471. * @returns the currentAbstractMesh
  28472. */
  28473. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28474. /**
  28475. * Returns 0 by default. Implemented by child classes
  28476. * @returns an integer
  28477. */
  28478. getTotalVertices(): number;
  28479. /**
  28480. * Returns a positive integer : the total number of indices in this mesh geometry.
  28481. * @returns the numner of indices or zero if the mesh has no geometry.
  28482. */
  28483. getTotalIndices(): number;
  28484. /**
  28485. * Returns null by default. Implemented by child classes
  28486. * @returns null
  28487. */
  28488. getIndices(): Nullable<IndicesArray>;
  28489. /**
  28490. * Returns the array of the requested vertex data kind. Implemented by child classes
  28491. * @param kind defines the vertex data kind to use
  28492. * @returns null
  28493. */
  28494. getVerticesData(kind: string): Nullable<FloatArray>;
  28495. /**
  28496. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28497. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28498. * Note that a new underlying VertexBuffer object is created each call.
  28499. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28500. * @param kind defines vertex data kind:
  28501. * * VertexBuffer.PositionKind
  28502. * * VertexBuffer.UVKind
  28503. * * VertexBuffer.UV2Kind
  28504. * * VertexBuffer.UV3Kind
  28505. * * VertexBuffer.UV4Kind
  28506. * * VertexBuffer.UV5Kind
  28507. * * VertexBuffer.UV6Kind
  28508. * * VertexBuffer.ColorKind
  28509. * * VertexBuffer.MatricesIndicesKind
  28510. * * VertexBuffer.MatricesIndicesExtraKind
  28511. * * VertexBuffer.MatricesWeightsKind
  28512. * * VertexBuffer.MatricesWeightsExtraKind
  28513. * @param data defines the data source
  28514. * @param updatable defines if the data must be flagged as updatable (or static)
  28515. * @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
  28516. * @returns the current mesh
  28517. */
  28518. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28519. /**
  28520. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28521. * If the mesh has no geometry, it is simply returned as it is.
  28522. * @param kind defines vertex data kind:
  28523. * * VertexBuffer.PositionKind
  28524. * * VertexBuffer.UVKind
  28525. * * VertexBuffer.UV2Kind
  28526. * * VertexBuffer.UV3Kind
  28527. * * VertexBuffer.UV4Kind
  28528. * * VertexBuffer.UV5Kind
  28529. * * VertexBuffer.UV6Kind
  28530. * * VertexBuffer.ColorKind
  28531. * * VertexBuffer.MatricesIndicesKind
  28532. * * VertexBuffer.MatricesIndicesExtraKind
  28533. * * VertexBuffer.MatricesWeightsKind
  28534. * * VertexBuffer.MatricesWeightsExtraKind
  28535. * @param data defines the data source
  28536. * @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
  28537. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28538. * @returns the current mesh
  28539. */
  28540. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28541. /**
  28542. * Sets the mesh indices,
  28543. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28544. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28545. * @param totalVertices Defines the total number of vertices
  28546. * @returns the current mesh
  28547. */
  28548. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28549. /**
  28550. * Gets a boolean indicating if specific vertex data is present
  28551. * @param kind defines the vertex data kind to use
  28552. * @returns true is data kind is present
  28553. */
  28554. isVerticesDataPresent(kind: string): boolean;
  28555. /**
  28556. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28557. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28558. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28559. * @returns a BoundingInfo
  28560. */
  28561. getBoundingInfo(): BoundingInfo;
  28562. /**
  28563. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28564. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28565. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28566. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28567. * @returns the current mesh
  28568. */
  28569. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28570. /**
  28571. * Overwrite the current bounding info
  28572. * @param boundingInfo defines the new bounding info
  28573. * @returns the current mesh
  28574. */
  28575. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28576. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28577. get useBones(): boolean;
  28578. /** @hidden */
  28579. _preActivate(): void;
  28580. /** @hidden */
  28581. _preActivateForIntermediateRendering(renderId: number): void;
  28582. /** @hidden */
  28583. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28584. /** @hidden */
  28585. _postActivate(): void;
  28586. /** @hidden */
  28587. _freeze(): void;
  28588. /** @hidden */
  28589. _unFreeze(): void;
  28590. /**
  28591. * Gets the current world matrix
  28592. * @returns a Matrix
  28593. */
  28594. getWorldMatrix(): Matrix;
  28595. /** @hidden */
  28596. _getWorldMatrixDeterminant(): number;
  28597. /**
  28598. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28599. */
  28600. get isAnInstance(): boolean;
  28601. /**
  28602. * Gets a boolean indicating if this mesh has instances
  28603. */
  28604. get hasInstances(): boolean;
  28605. /**
  28606. * Perform relative position change from the point of view of behind the front of the mesh.
  28607. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28608. * Supports definition of mesh facing forward or backward
  28609. * @param amountRight defines the distance on the right axis
  28610. * @param amountUp defines the distance on the up axis
  28611. * @param amountForward defines the distance on the forward axis
  28612. * @returns the current mesh
  28613. */
  28614. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28615. /**
  28616. * Calculate relative position change from the point of view of behind the front of the mesh.
  28617. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28618. * Supports definition of mesh facing forward or backward
  28619. * @param amountRight defines the distance on the right axis
  28620. * @param amountUp defines the distance on the up axis
  28621. * @param amountForward defines the distance on the forward axis
  28622. * @returns the new displacement vector
  28623. */
  28624. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28625. /**
  28626. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28627. * Supports definition of mesh facing forward or backward
  28628. * @param flipBack defines the flip
  28629. * @param twirlClockwise defines the twirl
  28630. * @param tiltRight defines the tilt
  28631. * @returns the current mesh
  28632. */
  28633. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28634. /**
  28635. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28636. * Supports definition of mesh facing forward or backward.
  28637. * @param flipBack defines the flip
  28638. * @param twirlClockwise defines the twirl
  28639. * @param tiltRight defines the tilt
  28640. * @returns the new rotation vector
  28641. */
  28642. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28643. /**
  28644. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28645. * This means the mesh underlying bounding box and sphere are recomputed.
  28646. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28647. * @returns the current mesh
  28648. */
  28649. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28650. /** @hidden */
  28651. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28652. /** @hidden */
  28653. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28654. /** @hidden */
  28655. _updateBoundingInfo(): AbstractMesh;
  28656. /** @hidden */
  28657. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28658. /** @hidden */
  28659. protected _afterComputeWorldMatrix(): void;
  28660. /** @hidden */
  28661. get _effectiveMesh(): AbstractMesh;
  28662. /**
  28663. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28664. * A mesh is in the frustum if its bounding box intersects the frustum
  28665. * @param frustumPlanes defines the frustum to test
  28666. * @returns true if the mesh is in the frustum planes
  28667. */
  28668. isInFrustum(frustumPlanes: Plane[]): boolean;
  28669. /**
  28670. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28671. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28672. * @param frustumPlanes defines the frustum to test
  28673. * @returns true if the mesh is completely in the frustum planes
  28674. */
  28675. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28676. /**
  28677. * True if the mesh intersects another mesh or a SolidParticle object
  28678. * @param mesh defines a target mesh or SolidParticle to test
  28679. * @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)
  28680. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28681. * @returns true if there is an intersection
  28682. */
  28683. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28684. /**
  28685. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28686. * @param point defines the point to test
  28687. * @returns true if there is an intersection
  28688. */
  28689. intersectsPoint(point: Vector3): boolean;
  28690. /**
  28691. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28692. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28693. */
  28694. get checkCollisions(): boolean;
  28695. set checkCollisions(collisionEnabled: boolean);
  28696. /**
  28697. * Gets Collider object used to compute collisions (not physics)
  28698. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28699. */
  28700. get collider(): Nullable<Collider>;
  28701. /**
  28702. * Move the mesh using collision engine
  28703. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28704. * @param displacement defines the requested displacement vector
  28705. * @returns the current mesh
  28706. */
  28707. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28708. private _onCollisionPositionChange;
  28709. /** @hidden */
  28710. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28711. /** @hidden */
  28712. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28713. /** @hidden */
  28714. _checkCollision(collider: Collider): AbstractMesh;
  28715. /** @hidden */
  28716. _generatePointsArray(): boolean;
  28717. /**
  28718. * Checks if the passed Ray intersects with the mesh
  28719. * @param ray defines the ray to use
  28720. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28721. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28722. * @returns the picking info
  28723. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28724. */
  28725. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28726. /**
  28727. * Clones the current mesh
  28728. * @param name defines the mesh name
  28729. * @param newParent defines the new mesh parent
  28730. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28731. * @returns the new mesh
  28732. */
  28733. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28734. /**
  28735. * Disposes all the submeshes of the current meshnp
  28736. * @returns the current mesh
  28737. */
  28738. releaseSubMeshes(): AbstractMesh;
  28739. /**
  28740. * Releases resources associated with this abstract mesh.
  28741. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28742. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28743. */
  28744. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28745. /**
  28746. * Adds the passed mesh as a child to the current mesh
  28747. * @param mesh defines the child mesh
  28748. * @returns the current mesh
  28749. */
  28750. addChild(mesh: AbstractMesh): AbstractMesh;
  28751. /**
  28752. * Removes the passed mesh from the current mesh children list
  28753. * @param mesh defines the child mesh
  28754. * @returns the current mesh
  28755. */
  28756. removeChild(mesh: AbstractMesh): AbstractMesh;
  28757. /** @hidden */
  28758. private _initFacetData;
  28759. /**
  28760. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28761. * This method can be called within the render loop.
  28762. * 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
  28763. * @returns the current mesh
  28764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28765. */
  28766. updateFacetData(): AbstractMesh;
  28767. /**
  28768. * Returns the facetLocalNormals array.
  28769. * The normals are expressed in the mesh local spac
  28770. * @returns an array of Vector3
  28771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28772. */
  28773. getFacetLocalNormals(): Vector3[];
  28774. /**
  28775. * Returns the facetLocalPositions array.
  28776. * The facet positions are expressed in the mesh local space
  28777. * @returns an array of Vector3
  28778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28779. */
  28780. getFacetLocalPositions(): Vector3[];
  28781. /**
  28782. * Returns the facetLocalPartioning array
  28783. * @returns an array of array of numbers
  28784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28785. */
  28786. getFacetLocalPartitioning(): number[][];
  28787. /**
  28788. * Returns the i-th facet position in the world system.
  28789. * This method allocates a new Vector3 per call
  28790. * @param i defines the facet index
  28791. * @returns a new Vector3
  28792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28793. */
  28794. getFacetPosition(i: number): Vector3;
  28795. /**
  28796. * Sets the reference Vector3 with the i-th facet position in the world system
  28797. * @param i defines the facet index
  28798. * @param ref defines the target vector
  28799. * @returns the current mesh
  28800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28801. */
  28802. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28803. /**
  28804. * Returns the i-th facet normal in the world system.
  28805. * This method allocates a new Vector3 per call
  28806. * @param i defines the facet index
  28807. * @returns a new Vector3
  28808. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28809. */
  28810. getFacetNormal(i: number): Vector3;
  28811. /**
  28812. * Sets the reference Vector3 with the i-th facet normal in the world system
  28813. * @param i defines the facet index
  28814. * @param ref defines the target vector
  28815. * @returns the current mesh
  28816. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28817. */
  28818. getFacetNormalToRef(i: number, ref: Vector3): this;
  28819. /**
  28820. * 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)
  28821. * @param x defines x coordinate
  28822. * @param y defines y coordinate
  28823. * @param z defines z coordinate
  28824. * @returns the array of facet indexes
  28825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28826. */
  28827. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28828. /**
  28829. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28830. * @param projected sets as the (x,y,z) world projection on the facet
  28831. * @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
  28832. * @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
  28833. * @param x defines x coordinate
  28834. * @param y defines y coordinate
  28835. * @param z defines z coordinate
  28836. * @returns the face index if found (or null instead)
  28837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28838. */
  28839. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28840. /**
  28841. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28842. * @param projected sets as the (x,y,z) local projection on the facet
  28843. * @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
  28844. * @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
  28845. * @param x defines x coordinate
  28846. * @param y defines y coordinate
  28847. * @param z defines z coordinate
  28848. * @returns the face index if found (or null instead)
  28849. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28850. */
  28851. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28852. /**
  28853. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28854. * @returns the parameters
  28855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28856. */
  28857. getFacetDataParameters(): any;
  28858. /**
  28859. * Disables the feature FacetData and frees the related memory
  28860. * @returns the current mesh
  28861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28862. */
  28863. disableFacetData(): AbstractMesh;
  28864. /**
  28865. * Updates the AbstractMesh indices array
  28866. * @param indices defines the data source
  28867. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28868. * @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)
  28869. * @returns the current mesh
  28870. */
  28871. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28872. /**
  28873. * Creates new normals data for the mesh
  28874. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28875. * @returns the current mesh
  28876. */
  28877. createNormals(updatable: boolean): AbstractMesh;
  28878. /**
  28879. * Align the mesh with a normal
  28880. * @param normal defines the normal to use
  28881. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28882. * @returns the current mesh
  28883. */
  28884. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28885. /** @hidden */
  28886. _checkOcclusionQuery(): boolean;
  28887. /**
  28888. * Disables the mesh edge rendering mode
  28889. * @returns the currentAbstractMesh
  28890. */
  28891. disableEdgesRendering(): AbstractMesh;
  28892. /**
  28893. * Enables the edge rendering mode on the mesh.
  28894. * This mode makes the mesh edges visible
  28895. * @param epsilon defines the maximal distance between two angles to detect a face
  28896. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28897. * @returns the currentAbstractMesh
  28898. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28899. */
  28900. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28901. }
  28902. }
  28903. declare module BABYLON {
  28904. /**
  28905. * Interface used to define ActionEvent
  28906. */
  28907. export interface IActionEvent {
  28908. /** The mesh or sprite that triggered the action */
  28909. source: any;
  28910. /** The X mouse cursor position at the time of the event */
  28911. pointerX: number;
  28912. /** The Y mouse cursor position at the time of the event */
  28913. pointerY: number;
  28914. /** The mesh that is currently pointed at (can be null) */
  28915. meshUnderPointer: Nullable<AbstractMesh>;
  28916. /** the original (browser) event that triggered the ActionEvent */
  28917. sourceEvent?: any;
  28918. /** additional data for the event */
  28919. additionalData?: any;
  28920. }
  28921. /**
  28922. * ActionEvent is the event being sent when an action is triggered.
  28923. */
  28924. export class ActionEvent implements IActionEvent {
  28925. /** The mesh or sprite that triggered the action */
  28926. source: any;
  28927. /** The X mouse cursor position at the time of the event */
  28928. pointerX: number;
  28929. /** The Y mouse cursor position at the time of the event */
  28930. pointerY: number;
  28931. /** The mesh that is currently pointed at (can be null) */
  28932. meshUnderPointer: Nullable<AbstractMesh>;
  28933. /** the original (browser) event that triggered the ActionEvent */
  28934. sourceEvent?: any;
  28935. /** additional data for the event */
  28936. additionalData?: any;
  28937. /**
  28938. * Creates a new ActionEvent
  28939. * @param source The mesh or sprite that triggered the action
  28940. * @param pointerX The X mouse cursor position at the time of the event
  28941. * @param pointerY The Y mouse cursor position at the time of the event
  28942. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28943. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28944. * @param additionalData additional data for the event
  28945. */
  28946. constructor(
  28947. /** The mesh or sprite that triggered the action */
  28948. source: any,
  28949. /** The X mouse cursor position at the time of the event */
  28950. pointerX: number,
  28951. /** The Y mouse cursor position at the time of the event */
  28952. pointerY: number,
  28953. /** The mesh that is currently pointed at (can be null) */
  28954. meshUnderPointer: Nullable<AbstractMesh>,
  28955. /** the original (browser) event that triggered the ActionEvent */
  28956. sourceEvent?: any,
  28957. /** additional data for the event */
  28958. additionalData?: any);
  28959. /**
  28960. * Helper function to auto-create an ActionEvent from a source mesh.
  28961. * @param source The source mesh that triggered the event
  28962. * @param evt The original (browser) event
  28963. * @param additionalData additional data for the event
  28964. * @returns the new ActionEvent
  28965. */
  28966. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28967. /**
  28968. * Helper function to auto-create an ActionEvent from a source sprite
  28969. * @param source The source sprite that triggered the event
  28970. * @param scene Scene associated with the sprite
  28971. * @param evt The original (browser) event
  28972. * @param additionalData additional data for the event
  28973. * @returns the new ActionEvent
  28974. */
  28975. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28976. /**
  28977. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28978. * @param scene the scene where the event occurred
  28979. * @param evt The original (browser) event
  28980. * @returns the new ActionEvent
  28981. */
  28982. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28983. /**
  28984. * Helper function to auto-create an ActionEvent from a primitive
  28985. * @param prim defines the target primitive
  28986. * @param pointerPos defines the pointer position
  28987. * @param evt The original (browser) event
  28988. * @param additionalData additional data for the event
  28989. * @returns the new ActionEvent
  28990. */
  28991. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28992. }
  28993. }
  28994. declare module BABYLON {
  28995. /**
  28996. * Abstract class used to decouple action Manager from scene and meshes.
  28997. * Do not instantiate.
  28998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28999. */
  29000. export abstract class AbstractActionManager implements IDisposable {
  29001. /** Gets the list of active triggers */
  29002. static Triggers: {
  29003. [key: string]: number;
  29004. };
  29005. /** Gets the cursor to use when hovering items */
  29006. hoverCursor: string;
  29007. /** Gets the list of actions */
  29008. actions: IAction[];
  29009. /**
  29010. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29011. */
  29012. isRecursive: boolean;
  29013. /**
  29014. * Releases all associated resources
  29015. */
  29016. abstract dispose(): void;
  29017. /**
  29018. * Does this action manager has pointer triggers
  29019. */
  29020. abstract get hasPointerTriggers(): boolean;
  29021. /**
  29022. * Does this action manager has pick triggers
  29023. */
  29024. abstract get hasPickTriggers(): boolean;
  29025. /**
  29026. * Process a specific trigger
  29027. * @param trigger defines the trigger to process
  29028. * @param evt defines the event details to be processed
  29029. */
  29030. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29031. /**
  29032. * Does this action manager handles actions of any of the given triggers
  29033. * @param triggers defines the triggers to be tested
  29034. * @return a boolean indicating whether one (or more) of the triggers is handled
  29035. */
  29036. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29037. /**
  29038. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29039. * speed.
  29040. * @param triggerA defines the trigger to be tested
  29041. * @param triggerB defines the trigger to be tested
  29042. * @return a boolean indicating whether one (or more) of the triggers is handled
  29043. */
  29044. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29045. /**
  29046. * Does this action manager handles actions of a given trigger
  29047. * @param trigger defines the trigger to be tested
  29048. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29049. * @return whether the trigger is handled
  29050. */
  29051. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29052. /**
  29053. * Serialize this manager to a JSON object
  29054. * @param name defines the property name to store this manager
  29055. * @returns a JSON representation of this manager
  29056. */
  29057. abstract serialize(name: string): any;
  29058. /**
  29059. * Registers an action to this action manager
  29060. * @param action defines the action to be registered
  29061. * @return the action amended (prepared) after registration
  29062. */
  29063. abstract registerAction(action: IAction): Nullable<IAction>;
  29064. /**
  29065. * Unregisters an action to this action manager
  29066. * @param action defines the action to be unregistered
  29067. * @return a boolean indicating whether the action has been unregistered
  29068. */
  29069. abstract unregisterAction(action: IAction): Boolean;
  29070. /**
  29071. * Does exist one action manager with at least one trigger
  29072. **/
  29073. static get HasTriggers(): boolean;
  29074. /**
  29075. * Does exist one action manager with at least one pick trigger
  29076. **/
  29077. static get HasPickTriggers(): boolean;
  29078. /**
  29079. * Does exist one action manager that handles actions of a given trigger
  29080. * @param trigger defines the trigger to be tested
  29081. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29082. **/
  29083. static HasSpecificTrigger(trigger: number): boolean;
  29084. }
  29085. }
  29086. declare module BABYLON {
  29087. /**
  29088. * Defines how a node can be built from a string name.
  29089. */
  29090. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29091. /**
  29092. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29093. */
  29094. export class Node implements IBehaviorAware<Node> {
  29095. /** @hidden */
  29096. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29097. private static _NodeConstructors;
  29098. /**
  29099. * Add a new node constructor
  29100. * @param type defines the type name of the node to construct
  29101. * @param constructorFunc defines the constructor function
  29102. */
  29103. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29104. /**
  29105. * Returns a node constructor based on type name
  29106. * @param type defines the type name
  29107. * @param name defines the new node name
  29108. * @param scene defines the hosting scene
  29109. * @param options defines optional options to transmit to constructors
  29110. * @returns the new constructor or null
  29111. */
  29112. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29113. /**
  29114. * Gets or sets the name of the node
  29115. */
  29116. name: string;
  29117. /**
  29118. * Gets or sets the id of the node
  29119. */
  29120. id: string;
  29121. /**
  29122. * Gets or sets the unique id of the node
  29123. */
  29124. uniqueId: number;
  29125. /**
  29126. * Gets or sets a string used to store user defined state for the node
  29127. */
  29128. state: string;
  29129. /**
  29130. * Gets or sets an object used to store user defined information for the node
  29131. */
  29132. metadata: any;
  29133. /**
  29134. * For internal use only. Please do not use.
  29135. */
  29136. reservedDataStore: any;
  29137. /**
  29138. * List of inspectable custom properties (used by the Inspector)
  29139. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29140. */
  29141. inspectableCustomProperties: IInspectable[];
  29142. private _doNotSerialize;
  29143. /**
  29144. * Gets or sets a boolean used to define if the node must be serialized
  29145. */
  29146. get doNotSerialize(): boolean;
  29147. set doNotSerialize(value: boolean);
  29148. /** @hidden */
  29149. _isDisposed: boolean;
  29150. /**
  29151. * Gets a list of Animations associated with the node
  29152. */
  29153. animations: Animation[];
  29154. protected _ranges: {
  29155. [name: string]: Nullable<AnimationRange>;
  29156. };
  29157. /**
  29158. * Callback raised when the node is ready to be used
  29159. */
  29160. onReady: Nullable<(node: Node) => void>;
  29161. private _isEnabled;
  29162. private _isParentEnabled;
  29163. private _isReady;
  29164. /** @hidden */
  29165. _currentRenderId: number;
  29166. private _parentUpdateId;
  29167. /** @hidden */
  29168. _childUpdateId: number;
  29169. /** @hidden */
  29170. _waitingParentId: Nullable<string>;
  29171. /** @hidden */
  29172. _scene: Scene;
  29173. /** @hidden */
  29174. _cache: any;
  29175. private _parentNode;
  29176. private _children;
  29177. /** @hidden */
  29178. _worldMatrix: Matrix;
  29179. /** @hidden */
  29180. _worldMatrixDeterminant: number;
  29181. /** @hidden */
  29182. _worldMatrixDeterminantIsDirty: boolean;
  29183. /** @hidden */
  29184. private _sceneRootNodesIndex;
  29185. /**
  29186. * Gets a boolean indicating if the node has been disposed
  29187. * @returns true if the node was disposed
  29188. */
  29189. isDisposed(): boolean;
  29190. /**
  29191. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29192. * @see https://doc.babylonjs.com/how_to/parenting
  29193. */
  29194. set parent(parent: Nullable<Node>);
  29195. get parent(): Nullable<Node>;
  29196. /** @hidden */
  29197. _addToSceneRootNodes(): void;
  29198. /** @hidden */
  29199. _removeFromSceneRootNodes(): void;
  29200. private _animationPropertiesOverride;
  29201. /**
  29202. * Gets or sets the animation properties override
  29203. */
  29204. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29205. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29206. /**
  29207. * Gets a string idenfifying the name of the class
  29208. * @returns "Node" string
  29209. */
  29210. getClassName(): string;
  29211. /** @hidden */
  29212. readonly _isNode: boolean;
  29213. /**
  29214. * An event triggered when the mesh is disposed
  29215. */
  29216. onDisposeObservable: Observable<Node>;
  29217. private _onDisposeObserver;
  29218. /**
  29219. * Sets a callback that will be raised when the node will be disposed
  29220. */
  29221. set onDispose(callback: () => void);
  29222. /**
  29223. * Creates a new Node
  29224. * @param name the name and id to be given to this node
  29225. * @param scene the scene this node will be added to
  29226. */
  29227. constructor(name: string, scene?: Nullable<Scene>);
  29228. /**
  29229. * Gets the scene of the node
  29230. * @returns a scene
  29231. */
  29232. getScene(): Scene;
  29233. /**
  29234. * Gets the engine of the node
  29235. * @returns a Engine
  29236. */
  29237. getEngine(): Engine;
  29238. private _behaviors;
  29239. /**
  29240. * Attach a behavior to the node
  29241. * @see http://doc.babylonjs.com/features/behaviour
  29242. * @param behavior defines the behavior to attach
  29243. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29244. * @returns the current Node
  29245. */
  29246. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29247. /**
  29248. * Remove an attached behavior
  29249. * @see http://doc.babylonjs.com/features/behaviour
  29250. * @param behavior defines the behavior to attach
  29251. * @returns the current Node
  29252. */
  29253. removeBehavior(behavior: Behavior<Node>): Node;
  29254. /**
  29255. * Gets the list of attached behaviors
  29256. * @see http://doc.babylonjs.com/features/behaviour
  29257. */
  29258. get behaviors(): Behavior<Node>[];
  29259. /**
  29260. * Gets an attached behavior by name
  29261. * @param name defines the name of the behavior to look for
  29262. * @see http://doc.babylonjs.com/features/behaviour
  29263. * @returns null if behavior was not found else the requested behavior
  29264. */
  29265. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29266. /**
  29267. * Returns the latest update of the World matrix
  29268. * @returns a Matrix
  29269. */
  29270. getWorldMatrix(): Matrix;
  29271. /** @hidden */
  29272. _getWorldMatrixDeterminant(): number;
  29273. /**
  29274. * Returns directly the latest state of the mesh World matrix.
  29275. * A Matrix is returned.
  29276. */
  29277. get worldMatrixFromCache(): Matrix;
  29278. /** @hidden */
  29279. _initCache(): void;
  29280. /** @hidden */
  29281. updateCache(force?: boolean): void;
  29282. /** @hidden */
  29283. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29284. /** @hidden */
  29285. _updateCache(ignoreParentClass?: boolean): void;
  29286. /** @hidden */
  29287. _isSynchronized(): boolean;
  29288. /** @hidden */
  29289. _markSyncedWithParent(): void;
  29290. /** @hidden */
  29291. isSynchronizedWithParent(): boolean;
  29292. /** @hidden */
  29293. isSynchronized(): boolean;
  29294. /**
  29295. * Is this node ready to be used/rendered
  29296. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29297. * @return true if the node is ready
  29298. */
  29299. isReady(completeCheck?: boolean): boolean;
  29300. /**
  29301. * Is this node enabled?
  29302. * 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
  29303. * @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
  29304. * @return whether this node (and its parent) is enabled
  29305. */
  29306. isEnabled(checkAncestors?: boolean): boolean;
  29307. /** @hidden */
  29308. protected _syncParentEnabledState(): void;
  29309. /**
  29310. * Set the enabled state of this node
  29311. * @param value defines the new enabled state
  29312. */
  29313. setEnabled(value: boolean): void;
  29314. /**
  29315. * Is this node a descendant of the given node?
  29316. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29317. * @param ancestor defines the parent node to inspect
  29318. * @returns a boolean indicating if this node is a descendant of the given node
  29319. */
  29320. isDescendantOf(ancestor: Node): boolean;
  29321. /** @hidden */
  29322. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29323. /**
  29324. * Will return all nodes that have this node as ascendant
  29325. * @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
  29326. * @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
  29327. * @return all children nodes of all types
  29328. */
  29329. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29330. /**
  29331. * Get all child-meshes of this node
  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 (Default: false)
  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. * @returns an array of AbstractMesh
  29335. */
  29336. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29337. /**
  29338. * Get all direct children of this node
  29339. * @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
  29340. * @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)
  29341. * @returns an array of Node
  29342. */
  29343. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29344. /** @hidden */
  29345. _setReady(state: boolean): void;
  29346. /**
  29347. * Get an animation by name
  29348. * @param name defines the name of the animation to look for
  29349. * @returns null if not found else the requested animation
  29350. */
  29351. getAnimationByName(name: string): Nullable<Animation>;
  29352. /**
  29353. * Creates an animation range for this node
  29354. * @param name defines the name of the range
  29355. * @param from defines the starting key
  29356. * @param to defines the end key
  29357. */
  29358. createAnimationRange(name: string, from: number, to: number): void;
  29359. /**
  29360. * Delete a specific animation range
  29361. * @param name defines the name of the range to delete
  29362. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29363. */
  29364. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29365. /**
  29366. * Get an animation range by name
  29367. * @param name defines the name of the animation range to look for
  29368. * @returns null if not found else the requested animation range
  29369. */
  29370. getAnimationRange(name: string): Nullable<AnimationRange>;
  29371. /**
  29372. * Gets the list of all animation ranges defined on this node
  29373. * @returns an array
  29374. */
  29375. getAnimationRanges(): Nullable<AnimationRange>[];
  29376. /**
  29377. * Will start the animation sequence
  29378. * @param name defines the range frames for animation sequence
  29379. * @param loop defines if the animation should loop (false by default)
  29380. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29381. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29382. * @returns the object created for this animation. If range does not exist, it will return null
  29383. */
  29384. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29385. /**
  29386. * Serialize animation ranges into a JSON compatible object
  29387. * @returns serialization object
  29388. */
  29389. serializeAnimationRanges(): any;
  29390. /**
  29391. * Computes the world matrix of the node
  29392. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29393. * @returns the world matrix
  29394. */
  29395. computeWorldMatrix(force?: boolean): Matrix;
  29396. /**
  29397. * Releases resources associated with this node.
  29398. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29399. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29400. */
  29401. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29402. /**
  29403. * Parse animation range data from a serialization object and store them into a given node
  29404. * @param node defines where to store the animation ranges
  29405. * @param parsedNode defines the serialization object to read data from
  29406. * @param scene defines the hosting scene
  29407. */
  29408. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29409. /**
  29410. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29411. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29412. * @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
  29413. * @returns the new bounding vectors
  29414. */
  29415. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29416. min: Vector3;
  29417. max: Vector3;
  29418. };
  29419. }
  29420. }
  29421. declare module BABYLON {
  29422. /**
  29423. * @hidden
  29424. */
  29425. export class _IAnimationState {
  29426. key: number;
  29427. repeatCount: number;
  29428. workValue?: any;
  29429. loopMode?: number;
  29430. offsetValue?: any;
  29431. highLimitValue?: any;
  29432. }
  29433. /**
  29434. * Class used to store any kind of animation
  29435. */
  29436. export class Animation {
  29437. /**Name of the animation */
  29438. name: string;
  29439. /**Property to animate */
  29440. targetProperty: string;
  29441. /**The frames per second of the animation */
  29442. framePerSecond: number;
  29443. /**The data type of the animation */
  29444. dataType: number;
  29445. /**The loop mode of the animation */
  29446. loopMode?: number | undefined;
  29447. /**Specifies if blending should be enabled */
  29448. enableBlending?: boolean | undefined;
  29449. /**
  29450. * Use matrix interpolation instead of using direct key value when animating matrices
  29451. */
  29452. static AllowMatricesInterpolation: boolean;
  29453. /**
  29454. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29455. */
  29456. static AllowMatrixDecomposeForInterpolation: boolean;
  29457. /**
  29458. * Stores the key frames of the animation
  29459. */
  29460. private _keys;
  29461. /**
  29462. * Stores the easing function of the animation
  29463. */
  29464. private _easingFunction;
  29465. /**
  29466. * @hidden Internal use only
  29467. */
  29468. _runtimeAnimations: RuntimeAnimation[];
  29469. /**
  29470. * The set of event that will be linked to this animation
  29471. */
  29472. private _events;
  29473. /**
  29474. * Stores an array of target property paths
  29475. */
  29476. targetPropertyPath: string[];
  29477. /**
  29478. * Stores the blending speed of the animation
  29479. */
  29480. blendingSpeed: number;
  29481. /**
  29482. * Stores the animation ranges for the animation
  29483. */
  29484. private _ranges;
  29485. /**
  29486. * @hidden Internal use
  29487. */
  29488. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29489. /**
  29490. * Sets up an animation
  29491. * @param property The property to animate
  29492. * @param animationType The animation type to apply
  29493. * @param framePerSecond The frames per second of the animation
  29494. * @param easingFunction The easing function used in the animation
  29495. * @returns The created animation
  29496. */
  29497. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29498. /**
  29499. * Create and start an animation on a node
  29500. * @param name defines the name of the global animation that will be run on all nodes
  29501. * @param node defines the root node where the animation will take place
  29502. * @param targetProperty defines property to animate
  29503. * @param framePerSecond defines the number of frame per second yo use
  29504. * @param totalFrame defines the number of frames in total
  29505. * @param from defines the initial value
  29506. * @param to defines the final value
  29507. * @param loopMode defines which loop mode you want to use (off by default)
  29508. * @param easingFunction defines the easing function to use (linear by default)
  29509. * @param onAnimationEnd defines the callback to call when animation end
  29510. * @returns the animatable created for this animation
  29511. */
  29512. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29513. /**
  29514. * Create and start an animation on a node and its descendants
  29515. * @param name defines the name of the global animation that will be run on all nodes
  29516. * @param node defines the root node where the animation will take place
  29517. * @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
  29518. * @param targetProperty defines property to animate
  29519. * @param framePerSecond defines the number of frame per second to use
  29520. * @param totalFrame defines the number of frames in total
  29521. * @param from defines the initial value
  29522. * @param to defines the final value
  29523. * @param loopMode defines which loop mode you want to use (off by default)
  29524. * @param easingFunction defines the easing function to use (linear by default)
  29525. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29526. * @returns the list of animatables created for all nodes
  29527. * @example https://www.babylonjs-playground.com/#MH0VLI
  29528. */
  29529. 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[]>;
  29530. /**
  29531. * Creates a new animation, merges it with the existing animations and starts it
  29532. * @param name Name of the animation
  29533. * @param node Node which contains the scene that begins the animations
  29534. * @param targetProperty Specifies which property to animate
  29535. * @param framePerSecond The frames per second of the animation
  29536. * @param totalFrame The total number of frames
  29537. * @param from The frame at the beginning of the animation
  29538. * @param to The frame at the end of the animation
  29539. * @param loopMode Specifies the loop mode of the animation
  29540. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29541. * @param onAnimationEnd Callback to run once the animation is complete
  29542. * @returns Nullable animation
  29543. */
  29544. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29545. /**
  29546. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29547. * @param sourceAnimation defines the Animation containing keyframes to convert
  29548. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29549. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29550. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29551. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29552. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29553. */
  29554. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29555. /**
  29556. * Transition property of an host to the target Value
  29557. * @param property The property to transition
  29558. * @param targetValue The target Value of the property
  29559. * @param host The object where the property to animate belongs
  29560. * @param scene Scene used to run the animation
  29561. * @param frameRate Framerate (in frame/s) to use
  29562. * @param transition The transition type we want to use
  29563. * @param duration The duration of the animation, in milliseconds
  29564. * @param onAnimationEnd Callback trigger at the end of the animation
  29565. * @returns Nullable animation
  29566. */
  29567. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29568. /**
  29569. * Return the array of runtime animations currently using this animation
  29570. */
  29571. get runtimeAnimations(): RuntimeAnimation[];
  29572. /**
  29573. * Specifies if any of the runtime animations are currently running
  29574. */
  29575. get hasRunningRuntimeAnimations(): boolean;
  29576. /**
  29577. * Initializes the animation
  29578. * @param name Name of the animation
  29579. * @param targetProperty Property to animate
  29580. * @param framePerSecond The frames per second of the animation
  29581. * @param dataType The data type of the animation
  29582. * @param loopMode The loop mode of the animation
  29583. * @param enableBlending Specifies if blending should be enabled
  29584. */
  29585. constructor(
  29586. /**Name of the animation */
  29587. name: string,
  29588. /**Property to animate */
  29589. targetProperty: string,
  29590. /**The frames per second of the animation */
  29591. framePerSecond: number,
  29592. /**The data type of the animation */
  29593. dataType: number,
  29594. /**The loop mode of the animation */
  29595. loopMode?: number | undefined,
  29596. /**Specifies if blending should be enabled */
  29597. enableBlending?: boolean | undefined);
  29598. /**
  29599. * Converts the animation to a string
  29600. * @param fullDetails support for multiple levels of logging within scene loading
  29601. * @returns String form of the animation
  29602. */
  29603. toString(fullDetails?: boolean): string;
  29604. /**
  29605. * Add an event to this animation
  29606. * @param event Event to add
  29607. */
  29608. addEvent(event: AnimationEvent): void;
  29609. /**
  29610. * Remove all events found at the given frame
  29611. * @param frame The frame to remove events from
  29612. */
  29613. removeEvents(frame: number): void;
  29614. /**
  29615. * Retrieves all the events from the animation
  29616. * @returns Events from the animation
  29617. */
  29618. getEvents(): AnimationEvent[];
  29619. /**
  29620. * Creates an animation range
  29621. * @param name Name of the animation range
  29622. * @param from Starting frame of the animation range
  29623. * @param to Ending frame of the animation
  29624. */
  29625. createRange(name: string, from: number, to: number): void;
  29626. /**
  29627. * Deletes an animation range by name
  29628. * @param name Name of the animation range to delete
  29629. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29630. */
  29631. deleteRange(name: string, deleteFrames?: boolean): void;
  29632. /**
  29633. * Gets the animation range by name, or null if not defined
  29634. * @param name Name of the animation range
  29635. * @returns Nullable animation range
  29636. */
  29637. getRange(name: string): Nullable<AnimationRange>;
  29638. /**
  29639. * Gets the key frames from the animation
  29640. * @returns The key frames of the animation
  29641. */
  29642. getKeys(): Array<IAnimationKey>;
  29643. /**
  29644. * Gets the highest frame rate of the animation
  29645. * @returns Highest frame rate of the animation
  29646. */
  29647. getHighestFrame(): number;
  29648. /**
  29649. * Gets the easing function of the animation
  29650. * @returns Easing function of the animation
  29651. */
  29652. getEasingFunction(): IEasingFunction;
  29653. /**
  29654. * Sets the easing function of the animation
  29655. * @param easingFunction A custom mathematical formula for animation
  29656. */
  29657. setEasingFunction(easingFunction: EasingFunction): void;
  29658. /**
  29659. * Interpolates a scalar linearly
  29660. * @param startValue Start value of the animation curve
  29661. * @param endValue End value of the animation curve
  29662. * @param gradient Scalar amount to interpolate
  29663. * @returns Interpolated scalar value
  29664. */
  29665. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29666. /**
  29667. * Interpolates a scalar cubically
  29668. * @param startValue Start value of the animation curve
  29669. * @param outTangent End tangent of the animation
  29670. * @param endValue End value of the animation curve
  29671. * @param inTangent Start tangent of the animation curve
  29672. * @param gradient Scalar amount to interpolate
  29673. * @returns Interpolated scalar value
  29674. */
  29675. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29676. /**
  29677. * Interpolates a quaternion using a spherical linear interpolation
  29678. * @param startValue Start value of the animation curve
  29679. * @param endValue End value of the animation curve
  29680. * @param gradient Scalar amount to interpolate
  29681. * @returns Interpolated quaternion value
  29682. */
  29683. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29684. /**
  29685. * Interpolates a quaternion cubically
  29686. * @param startValue Start value of the animation curve
  29687. * @param outTangent End tangent of the animation curve
  29688. * @param endValue End value of the animation curve
  29689. * @param inTangent Start tangent of the animation curve
  29690. * @param gradient Scalar amount to interpolate
  29691. * @returns Interpolated quaternion value
  29692. */
  29693. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29694. /**
  29695. * Interpolates a Vector3 linearl
  29696. * @param startValue Start value of the animation curve
  29697. * @param endValue End value of the animation curve
  29698. * @param gradient Scalar amount to interpolate
  29699. * @returns Interpolated scalar value
  29700. */
  29701. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29702. /**
  29703. * Interpolates a Vector3 cubically
  29704. * @param startValue Start value of the animation curve
  29705. * @param outTangent End tangent of the animation
  29706. * @param endValue End value of the animation curve
  29707. * @param inTangent Start tangent of the animation curve
  29708. * @param gradient Scalar amount to interpolate
  29709. * @returns InterpolatedVector3 value
  29710. */
  29711. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29712. /**
  29713. * Interpolates a Vector2 linearly
  29714. * @param startValue Start value of the animation curve
  29715. * @param endValue End value of the animation curve
  29716. * @param gradient Scalar amount to interpolate
  29717. * @returns Interpolated Vector2 value
  29718. */
  29719. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29720. /**
  29721. * Interpolates a Vector2 cubically
  29722. * @param startValue Start value of the animation curve
  29723. * @param outTangent End tangent of the animation
  29724. * @param endValue End value of the animation curve
  29725. * @param inTangent Start tangent of the animation curve
  29726. * @param gradient Scalar amount to interpolate
  29727. * @returns Interpolated Vector2 value
  29728. */
  29729. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29730. /**
  29731. * Interpolates a size linearly
  29732. * @param startValue Start value of the animation curve
  29733. * @param endValue End value of the animation curve
  29734. * @param gradient Scalar amount to interpolate
  29735. * @returns Interpolated Size value
  29736. */
  29737. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29738. /**
  29739. * Interpolates a Color3 linearly
  29740. * @param startValue Start value of the animation curve
  29741. * @param endValue End value of the animation curve
  29742. * @param gradient Scalar amount to interpolate
  29743. * @returns Interpolated Color3 value
  29744. */
  29745. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29746. /**
  29747. * Interpolates a Color4 linearly
  29748. * @param startValue Start value of the animation curve
  29749. * @param endValue End value of the animation curve
  29750. * @param gradient Scalar amount to interpolate
  29751. * @returns Interpolated Color3 value
  29752. */
  29753. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29754. /**
  29755. * @hidden Internal use only
  29756. */
  29757. _getKeyValue(value: any): any;
  29758. /**
  29759. * @hidden Internal use only
  29760. */
  29761. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29762. /**
  29763. * Defines the function to use to interpolate matrices
  29764. * @param startValue defines the start matrix
  29765. * @param endValue defines the end matrix
  29766. * @param gradient defines the gradient between both matrices
  29767. * @param result defines an optional target matrix where to store the interpolation
  29768. * @returns the interpolated matrix
  29769. */
  29770. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29771. /**
  29772. * Makes a copy of the animation
  29773. * @returns Cloned animation
  29774. */
  29775. clone(): Animation;
  29776. /**
  29777. * Sets the key frames of the animation
  29778. * @param values The animation key frames to set
  29779. */
  29780. setKeys(values: Array<IAnimationKey>): void;
  29781. /**
  29782. * Serializes the animation to an object
  29783. * @returns Serialized object
  29784. */
  29785. serialize(): any;
  29786. /**
  29787. * Float animation type
  29788. */
  29789. static readonly ANIMATIONTYPE_FLOAT: number;
  29790. /**
  29791. * Vector3 animation type
  29792. */
  29793. static readonly ANIMATIONTYPE_VECTOR3: number;
  29794. /**
  29795. * Quaternion animation type
  29796. */
  29797. static readonly ANIMATIONTYPE_QUATERNION: number;
  29798. /**
  29799. * Matrix animation type
  29800. */
  29801. static readonly ANIMATIONTYPE_MATRIX: number;
  29802. /**
  29803. * Color3 animation type
  29804. */
  29805. static readonly ANIMATIONTYPE_COLOR3: number;
  29806. /**
  29807. * Color3 animation type
  29808. */
  29809. static readonly ANIMATIONTYPE_COLOR4: number;
  29810. /**
  29811. * Vector2 animation type
  29812. */
  29813. static readonly ANIMATIONTYPE_VECTOR2: number;
  29814. /**
  29815. * Size animation type
  29816. */
  29817. static readonly ANIMATIONTYPE_SIZE: number;
  29818. /**
  29819. * Relative Loop Mode
  29820. */
  29821. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29822. /**
  29823. * Cycle Loop Mode
  29824. */
  29825. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29826. /**
  29827. * Constant Loop Mode
  29828. */
  29829. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29830. /** @hidden */
  29831. static _UniversalLerp(left: any, right: any, amount: number): any;
  29832. /**
  29833. * Parses an animation object and creates an animation
  29834. * @param parsedAnimation Parsed animation object
  29835. * @returns Animation object
  29836. */
  29837. static Parse(parsedAnimation: any): Animation;
  29838. /**
  29839. * Appends the serialized animations from the source animations
  29840. * @param source Source containing the animations
  29841. * @param destination Target to store the animations
  29842. */
  29843. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29844. }
  29845. }
  29846. declare module BABYLON {
  29847. /**
  29848. * Interface containing an array of animations
  29849. */
  29850. export interface IAnimatable {
  29851. /**
  29852. * Array of animations
  29853. */
  29854. animations: Nullable<Array<Animation>>;
  29855. }
  29856. }
  29857. declare module BABYLON {
  29858. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29859. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29860. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29861. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29862. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29863. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29864. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29865. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29866. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29867. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29868. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29869. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29870. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29871. /**
  29872. * Decorator used to define property that can be serialized as reference to a camera
  29873. * @param sourceName defines the name of the property to decorate
  29874. */
  29875. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29876. /**
  29877. * Class used to help serialization objects
  29878. */
  29879. export class SerializationHelper {
  29880. /** @hidden */
  29881. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29882. /** @hidden */
  29883. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29884. /** @hidden */
  29885. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29886. /** @hidden */
  29887. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29888. /**
  29889. * Appends the serialized animations from the source animations
  29890. * @param source Source containing the animations
  29891. * @param destination Target to store the animations
  29892. */
  29893. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29894. /**
  29895. * Static function used to serialized a specific entity
  29896. * @param entity defines the entity to serialize
  29897. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29898. * @returns a JSON compatible object representing the serialization of the entity
  29899. */
  29900. static Serialize<T>(entity: T, serializationObject?: any): any;
  29901. /**
  29902. * Creates a new entity from a serialization data object
  29903. * @param creationFunction defines a function used to instanciated the new entity
  29904. * @param source defines the source serialization data
  29905. * @param scene defines the hosting scene
  29906. * @param rootUrl defines the root url for resources
  29907. * @returns a new entity
  29908. */
  29909. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29910. /**
  29911. * Clones an object
  29912. * @param creationFunction defines the function used to instanciate the new object
  29913. * @param source defines the source object
  29914. * @returns the cloned object
  29915. */
  29916. static Clone<T>(creationFunction: () => T, source: T): T;
  29917. /**
  29918. * Instanciates a new object based on a source one (some data will be shared between both object)
  29919. * @param creationFunction defines the function used to instanciate the new object
  29920. * @param source defines the source object
  29921. * @returns the new object
  29922. */
  29923. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29924. }
  29925. }
  29926. declare module BABYLON {
  29927. /**
  29928. * Class used to manipulate GUIDs
  29929. */
  29930. export class GUID {
  29931. /**
  29932. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29933. * Be aware Math.random() could cause collisions, but:
  29934. * "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"
  29935. * @returns a pseudo random id
  29936. */
  29937. static RandomId(): string;
  29938. }
  29939. }
  29940. declare module BABYLON {
  29941. /**
  29942. * Base class of all the textures in babylon.
  29943. * It groups all the common properties the materials, post process, lights... might need
  29944. * in order to make a correct use of the texture.
  29945. */
  29946. export class BaseTexture implements IAnimatable {
  29947. /**
  29948. * Default anisotropic filtering level for the application.
  29949. * It is set to 4 as a good tradeoff between perf and quality.
  29950. */
  29951. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29952. /**
  29953. * Gets or sets the unique id of the texture
  29954. */
  29955. uniqueId: number;
  29956. /**
  29957. * Define the name of the texture.
  29958. */
  29959. name: string;
  29960. /**
  29961. * Gets or sets an object used to store user defined information.
  29962. */
  29963. metadata: any;
  29964. /**
  29965. * For internal use only. Please do not use.
  29966. */
  29967. reservedDataStore: any;
  29968. private _hasAlpha;
  29969. /**
  29970. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29971. */
  29972. set hasAlpha(value: boolean);
  29973. get hasAlpha(): boolean;
  29974. /**
  29975. * Defines if the alpha value should be determined via the rgb values.
  29976. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29977. */
  29978. getAlphaFromRGB: boolean;
  29979. /**
  29980. * Intensity or strength of the texture.
  29981. * It is commonly used by materials to fine tune the intensity of the texture
  29982. */
  29983. level: number;
  29984. /**
  29985. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29986. * This is part of the texture as textures usually maps to one uv set.
  29987. */
  29988. coordinatesIndex: number;
  29989. private _coordinatesMode;
  29990. /**
  29991. * How a texture is mapped.
  29992. *
  29993. * | Value | Type | Description |
  29994. * | ----- | ----------------------------------- | ----------- |
  29995. * | 0 | EXPLICIT_MODE | |
  29996. * | 1 | SPHERICAL_MODE | |
  29997. * | 2 | PLANAR_MODE | |
  29998. * | 3 | CUBIC_MODE | |
  29999. * | 4 | PROJECTION_MODE | |
  30000. * | 5 | SKYBOX_MODE | |
  30001. * | 6 | INVCUBIC_MODE | |
  30002. * | 7 | EQUIRECTANGULAR_MODE | |
  30003. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30004. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30005. */
  30006. set coordinatesMode(value: number);
  30007. get coordinatesMode(): number;
  30008. /**
  30009. * | Value | Type | Description |
  30010. * | ----- | ------------------ | ----------- |
  30011. * | 0 | CLAMP_ADDRESSMODE | |
  30012. * | 1 | WRAP_ADDRESSMODE | |
  30013. * | 2 | MIRROR_ADDRESSMODE | |
  30014. */
  30015. wrapU: number;
  30016. /**
  30017. * | Value | Type | Description |
  30018. * | ----- | ------------------ | ----------- |
  30019. * | 0 | CLAMP_ADDRESSMODE | |
  30020. * | 1 | WRAP_ADDRESSMODE | |
  30021. * | 2 | MIRROR_ADDRESSMODE | |
  30022. */
  30023. wrapV: number;
  30024. /**
  30025. * | Value | Type | Description |
  30026. * | ----- | ------------------ | ----------- |
  30027. * | 0 | CLAMP_ADDRESSMODE | |
  30028. * | 1 | WRAP_ADDRESSMODE | |
  30029. * | 2 | MIRROR_ADDRESSMODE | |
  30030. */
  30031. wrapR: number;
  30032. /**
  30033. * With compliant hardware and browser (supporting anisotropic filtering)
  30034. * this defines the level of anisotropic filtering in the texture.
  30035. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30036. */
  30037. anisotropicFilteringLevel: number;
  30038. /**
  30039. * Define if the texture is a cube texture or if false a 2d texture.
  30040. */
  30041. get isCube(): boolean;
  30042. set isCube(value: boolean);
  30043. /**
  30044. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30045. */
  30046. get is3D(): boolean;
  30047. set is3D(value: boolean);
  30048. /**
  30049. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30050. */
  30051. get is2DArray(): boolean;
  30052. set is2DArray(value: boolean);
  30053. /**
  30054. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30055. * HDR texture are usually stored in linear space.
  30056. * This only impacts the PBR and Background materials
  30057. */
  30058. gammaSpace: boolean;
  30059. /**
  30060. * Gets or sets whether or not the texture contains RGBD data.
  30061. */
  30062. get isRGBD(): boolean;
  30063. set isRGBD(value: boolean);
  30064. /**
  30065. * Is Z inverted in the texture (useful in a cube texture).
  30066. */
  30067. invertZ: boolean;
  30068. /**
  30069. * Are mip maps generated for this texture or not.
  30070. */
  30071. get noMipmap(): boolean;
  30072. /**
  30073. * @hidden
  30074. */
  30075. lodLevelInAlpha: boolean;
  30076. /**
  30077. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30078. */
  30079. get lodGenerationOffset(): number;
  30080. set lodGenerationOffset(value: number);
  30081. /**
  30082. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30083. */
  30084. get lodGenerationScale(): number;
  30085. set lodGenerationScale(value: number);
  30086. /**
  30087. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30088. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30089. * average roughness values.
  30090. */
  30091. get linearSpecularLOD(): boolean;
  30092. set linearSpecularLOD(value: boolean);
  30093. /**
  30094. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30095. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30096. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30097. */
  30098. get irradianceTexture(): Nullable<BaseTexture>;
  30099. set irradianceTexture(value: Nullable<BaseTexture>);
  30100. /**
  30101. * Define if the texture is a render target.
  30102. */
  30103. isRenderTarget: boolean;
  30104. /**
  30105. * Define the unique id of the texture in the scene.
  30106. */
  30107. get uid(): string;
  30108. /**
  30109. * Return a string representation of the texture.
  30110. * @returns the texture as a string
  30111. */
  30112. toString(): string;
  30113. /**
  30114. * Get the class name of the texture.
  30115. * @returns "BaseTexture"
  30116. */
  30117. getClassName(): string;
  30118. /**
  30119. * Define the list of animation attached to the texture.
  30120. */
  30121. animations: Animation[];
  30122. /**
  30123. * An event triggered when the texture is disposed.
  30124. */
  30125. onDisposeObservable: Observable<BaseTexture>;
  30126. private _onDisposeObserver;
  30127. /**
  30128. * Callback triggered when the texture has been disposed.
  30129. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30130. */
  30131. set onDispose(callback: () => void);
  30132. /**
  30133. * Define the current state of the loading sequence when in delayed load mode.
  30134. */
  30135. delayLoadState: number;
  30136. private _scene;
  30137. /** @hidden */
  30138. _texture: Nullable<InternalTexture>;
  30139. private _uid;
  30140. /**
  30141. * Define if the texture is preventinga material to render or not.
  30142. * If not and the texture is not ready, the engine will use a default black texture instead.
  30143. */
  30144. get isBlocking(): boolean;
  30145. /**
  30146. * Instantiates a new BaseTexture.
  30147. * Base class of all the textures in babylon.
  30148. * It groups all the common properties the materials, post process, lights... might need
  30149. * in order to make a correct use of the texture.
  30150. * @param scene Define the scene the texture blongs to
  30151. */
  30152. constructor(scene: Nullable<Scene>);
  30153. /**
  30154. * Get the scene the texture belongs to.
  30155. * @returns the scene or null if undefined
  30156. */
  30157. getScene(): Nullable<Scene>;
  30158. /**
  30159. * Get the texture transform matrix used to offset tile the texture for istance.
  30160. * @returns the transformation matrix
  30161. */
  30162. getTextureMatrix(): Matrix;
  30163. /**
  30164. * Get the texture reflection matrix used to rotate/transform the reflection.
  30165. * @returns the reflection matrix
  30166. */
  30167. getReflectionTextureMatrix(): Matrix;
  30168. /**
  30169. * Get the underlying lower level texture from Babylon.
  30170. * @returns the insternal texture
  30171. */
  30172. getInternalTexture(): Nullable<InternalTexture>;
  30173. /**
  30174. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30175. * @returns true if ready or not blocking
  30176. */
  30177. isReadyOrNotBlocking(): boolean;
  30178. /**
  30179. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30180. * @returns true if fully ready
  30181. */
  30182. isReady(): boolean;
  30183. private _cachedSize;
  30184. /**
  30185. * Get the size of the texture.
  30186. * @returns the texture size.
  30187. */
  30188. getSize(): ISize;
  30189. /**
  30190. * Get the base size of the texture.
  30191. * It can be different from the size if the texture has been resized for POT for instance
  30192. * @returns the base size
  30193. */
  30194. getBaseSize(): ISize;
  30195. /**
  30196. * Update the sampling mode of the texture.
  30197. * Default is Trilinear mode.
  30198. *
  30199. * | Value | Type | Description |
  30200. * | ----- | ------------------ | ----------- |
  30201. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30202. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30203. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30204. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30205. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30206. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30207. * | 7 | NEAREST_LINEAR | |
  30208. * | 8 | NEAREST_NEAREST | |
  30209. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30210. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30211. * | 11 | LINEAR_LINEAR | |
  30212. * | 12 | LINEAR_NEAREST | |
  30213. *
  30214. * > _mag_: magnification filter (close to the viewer)
  30215. * > _min_: minification filter (far from the viewer)
  30216. * > _mip_: filter used between mip map levels
  30217. *@param samplingMode Define the new sampling mode of the texture
  30218. */
  30219. updateSamplingMode(samplingMode: number): void;
  30220. /**
  30221. * Scales the texture if is `canRescale()`
  30222. * @param ratio the resize factor we want to use to rescale
  30223. */
  30224. scale(ratio: number): void;
  30225. /**
  30226. * Get if the texture can rescale.
  30227. */
  30228. get canRescale(): boolean;
  30229. /** @hidden */
  30230. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30231. /** @hidden */
  30232. _rebuild(): void;
  30233. /**
  30234. * Triggers the load sequence in delayed load mode.
  30235. */
  30236. delayLoad(): void;
  30237. /**
  30238. * Clones the texture.
  30239. * @returns the cloned texture
  30240. */
  30241. clone(): Nullable<BaseTexture>;
  30242. /**
  30243. * Get the texture underlying type (INT, FLOAT...)
  30244. */
  30245. get textureType(): number;
  30246. /**
  30247. * Get the texture underlying format (RGB, RGBA...)
  30248. */
  30249. get textureFormat(): number;
  30250. /**
  30251. * Indicates that textures need to be re-calculated for all materials
  30252. */
  30253. protected _markAllSubMeshesAsTexturesDirty(): void;
  30254. /**
  30255. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30256. * This will returns an RGBA array buffer containing either in values (0-255) or
  30257. * float values (0-1) depending of the underlying buffer type.
  30258. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30259. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30260. * @param buffer defines a user defined buffer to fill with data (can be null)
  30261. * @returns The Array buffer containing the pixels data.
  30262. */
  30263. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30264. /**
  30265. * Release and destroy the underlying lower level texture aka internalTexture.
  30266. */
  30267. releaseInternalTexture(): void;
  30268. /** @hidden */
  30269. get _lodTextureHigh(): Nullable<BaseTexture>;
  30270. /** @hidden */
  30271. get _lodTextureMid(): Nullable<BaseTexture>;
  30272. /** @hidden */
  30273. get _lodTextureLow(): Nullable<BaseTexture>;
  30274. /**
  30275. * Dispose the texture and release its associated resources.
  30276. */
  30277. dispose(): void;
  30278. /**
  30279. * Serialize the texture into a JSON representation that can be parsed later on.
  30280. * @returns the JSON representation of the texture
  30281. */
  30282. serialize(): any;
  30283. /**
  30284. * Helper function to be called back once a list of texture contains only ready textures.
  30285. * @param textures Define the list of textures to wait for
  30286. * @param callback Define the callback triggered once the entire list will be ready
  30287. */
  30288. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30289. }
  30290. }
  30291. declare module BABYLON {
  30292. /**
  30293. * Options to be used when creating an effect.
  30294. */
  30295. export interface IEffectCreationOptions {
  30296. /**
  30297. * Atrributes that will be used in the shader.
  30298. */
  30299. attributes: string[];
  30300. /**
  30301. * Uniform varible names that will be set in the shader.
  30302. */
  30303. uniformsNames: string[];
  30304. /**
  30305. * Uniform buffer variable names that will be set in the shader.
  30306. */
  30307. uniformBuffersNames: string[];
  30308. /**
  30309. * Sampler texture variable names that will be set in the shader.
  30310. */
  30311. samplers: string[];
  30312. /**
  30313. * Define statements that will be set in the shader.
  30314. */
  30315. defines: any;
  30316. /**
  30317. * Possible fallbacks for this effect to improve performance when needed.
  30318. */
  30319. fallbacks: Nullable<IEffectFallbacks>;
  30320. /**
  30321. * Callback that will be called when the shader is compiled.
  30322. */
  30323. onCompiled: Nullable<(effect: Effect) => void>;
  30324. /**
  30325. * Callback that will be called if an error occurs during shader compilation.
  30326. */
  30327. onError: Nullable<(effect: Effect, errors: string) => void>;
  30328. /**
  30329. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30330. */
  30331. indexParameters?: any;
  30332. /**
  30333. * Max number of lights that can be used in the shader.
  30334. */
  30335. maxSimultaneousLights?: number;
  30336. /**
  30337. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30338. */
  30339. transformFeedbackVaryings?: Nullable<string[]>;
  30340. }
  30341. /**
  30342. * Effect containing vertex and fragment shader that can be executed on an object.
  30343. */
  30344. export class Effect implements IDisposable {
  30345. /**
  30346. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30347. */
  30348. static ShadersRepository: string;
  30349. /**
  30350. * Enable logging of the shader code when a compilation error occurs
  30351. */
  30352. static LogShaderCodeOnCompilationError: boolean;
  30353. /**
  30354. * Name of the effect.
  30355. */
  30356. name: any;
  30357. /**
  30358. * String container all the define statements that should be set on the shader.
  30359. */
  30360. defines: string;
  30361. /**
  30362. * Callback that will be called when the shader is compiled.
  30363. */
  30364. onCompiled: Nullable<(effect: Effect) => void>;
  30365. /**
  30366. * Callback that will be called if an error occurs during shader compilation.
  30367. */
  30368. onError: Nullable<(effect: Effect, errors: string) => void>;
  30369. /**
  30370. * Callback that will be called when effect is bound.
  30371. */
  30372. onBind: Nullable<(effect: Effect) => void>;
  30373. /**
  30374. * Unique ID of the effect.
  30375. */
  30376. uniqueId: number;
  30377. /**
  30378. * Observable that will be called when the shader is compiled.
  30379. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30380. */
  30381. onCompileObservable: Observable<Effect>;
  30382. /**
  30383. * Observable that will be called if an error occurs during shader compilation.
  30384. */
  30385. onErrorObservable: Observable<Effect>;
  30386. /** @hidden */
  30387. _onBindObservable: Nullable<Observable<Effect>>;
  30388. /**
  30389. * @hidden
  30390. * Specifies if the effect was previously ready
  30391. */
  30392. _wasPreviouslyReady: boolean;
  30393. /**
  30394. * Observable that will be called when effect is bound.
  30395. */
  30396. get onBindObservable(): Observable<Effect>;
  30397. /** @hidden */
  30398. _bonesComputationForcedToCPU: boolean;
  30399. private static _uniqueIdSeed;
  30400. private _engine;
  30401. private _uniformBuffersNames;
  30402. private _uniformsNames;
  30403. private _samplerList;
  30404. private _samplers;
  30405. private _isReady;
  30406. private _compilationError;
  30407. private _allFallbacksProcessed;
  30408. private _attributesNames;
  30409. private _attributes;
  30410. private _attributeLocationByName;
  30411. private _uniforms;
  30412. /**
  30413. * Key for the effect.
  30414. * @hidden
  30415. */
  30416. _key: string;
  30417. private _indexParameters;
  30418. private _fallbacks;
  30419. private _vertexSourceCode;
  30420. private _fragmentSourceCode;
  30421. private _vertexSourceCodeOverride;
  30422. private _fragmentSourceCodeOverride;
  30423. private _transformFeedbackVaryings;
  30424. /**
  30425. * Compiled shader to webGL program.
  30426. * @hidden
  30427. */
  30428. _pipelineContext: Nullable<IPipelineContext>;
  30429. private _valueCache;
  30430. private static _baseCache;
  30431. /**
  30432. * Instantiates an effect.
  30433. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30434. * @param baseName Name of the effect.
  30435. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30436. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30437. * @param samplers List of sampler variables that will be passed to the shader.
  30438. * @param engine Engine to be used to render the effect
  30439. * @param defines Define statements to be added to the shader.
  30440. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30441. * @param onCompiled Callback that will be called when the shader is compiled.
  30442. * @param onError Callback that will be called if an error occurs during shader compilation.
  30443. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30444. */
  30445. 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);
  30446. private _useFinalCode;
  30447. /**
  30448. * Unique key for this effect
  30449. */
  30450. get key(): string;
  30451. /**
  30452. * If the effect has been compiled and prepared.
  30453. * @returns if the effect is compiled and prepared.
  30454. */
  30455. isReady(): boolean;
  30456. private _isReadyInternal;
  30457. /**
  30458. * The engine the effect was initialized with.
  30459. * @returns the engine.
  30460. */
  30461. getEngine(): Engine;
  30462. /**
  30463. * The pipeline context for this effect
  30464. * @returns the associated pipeline context
  30465. */
  30466. getPipelineContext(): Nullable<IPipelineContext>;
  30467. /**
  30468. * The set of names of attribute variables for the shader.
  30469. * @returns An array of attribute names.
  30470. */
  30471. getAttributesNames(): string[];
  30472. /**
  30473. * Returns the attribute at the given index.
  30474. * @param index The index of the attribute.
  30475. * @returns The location of the attribute.
  30476. */
  30477. getAttributeLocation(index: number): number;
  30478. /**
  30479. * Returns the attribute based on the name of the variable.
  30480. * @param name of the attribute to look up.
  30481. * @returns the attribute location.
  30482. */
  30483. getAttributeLocationByName(name: string): number;
  30484. /**
  30485. * The number of attributes.
  30486. * @returns the numnber of attributes.
  30487. */
  30488. getAttributesCount(): number;
  30489. /**
  30490. * Gets the index of a uniform variable.
  30491. * @param uniformName of the uniform to look up.
  30492. * @returns the index.
  30493. */
  30494. getUniformIndex(uniformName: string): number;
  30495. /**
  30496. * Returns the attribute based on the name of the variable.
  30497. * @param uniformName of the uniform to look up.
  30498. * @returns the location of the uniform.
  30499. */
  30500. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30501. /**
  30502. * Returns an array of sampler variable names
  30503. * @returns The array of sampler variable neames.
  30504. */
  30505. getSamplers(): string[];
  30506. /**
  30507. * The error from the last compilation.
  30508. * @returns the error string.
  30509. */
  30510. getCompilationError(): string;
  30511. /**
  30512. * Gets a boolean indicating that all fallbacks were used during compilation
  30513. * @returns true if all fallbacks were used
  30514. */
  30515. allFallbacksProcessed(): boolean;
  30516. /**
  30517. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30518. * @param func The callback to be used.
  30519. */
  30520. executeWhenCompiled(func: (effect: Effect) => void): void;
  30521. private _checkIsReady;
  30522. private _loadShader;
  30523. /**
  30524. * Recompiles the webGL program
  30525. * @param vertexSourceCode The source code for the vertex shader.
  30526. * @param fragmentSourceCode The source code for the fragment shader.
  30527. * @param onCompiled Callback called when completed.
  30528. * @param onError Callback called on error.
  30529. * @hidden
  30530. */
  30531. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30532. /**
  30533. * Prepares the effect
  30534. * @hidden
  30535. */
  30536. _prepareEffect(): void;
  30537. private _getShaderCodeAndErrorLine;
  30538. private _processCompilationErrors;
  30539. /**
  30540. * Checks if the effect is supported. (Must be called after compilation)
  30541. */
  30542. get isSupported(): boolean;
  30543. /**
  30544. * Binds a texture to the engine to be used as output of the shader.
  30545. * @param channel Name of the output variable.
  30546. * @param texture Texture to bind.
  30547. * @hidden
  30548. */
  30549. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30550. /**
  30551. * Sets a texture on the engine to be used in the shader.
  30552. * @param channel Name of the sampler variable.
  30553. * @param texture Texture to set.
  30554. */
  30555. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30556. /**
  30557. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30558. * @param channel Name of the sampler variable.
  30559. * @param texture Texture to set.
  30560. */
  30561. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30562. /**
  30563. * Sets an array of textures on the engine to be used in the shader.
  30564. * @param channel Name of the variable.
  30565. * @param textures Textures to set.
  30566. */
  30567. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30568. /**
  30569. * 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)
  30570. * @param channel Name of the sampler variable.
  30571. * @param postProcess Post process to get the input texture from.
  30572. */
  30573. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30574. /**
  30575. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30576. * 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)
  30577. * @param channel Name of the sampler variable.
  30578. * @param postProcess Post process to get the output texture from.
  30579. */
  30580. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30581. /** @hidden */
  30582. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30583. /** @hidden */
  30584. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30585. /** @hidden */
  30586. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30587. /** @hidden */
  30588. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30589. /**
  30590. * Binds a buffer to a uniform.
  30591. * @param buffer Buffer to bind.
  30592. * @param name Name of the uniform variable to bind to.
  30593. */
  30594. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30595. /**
  30596. * Binds block to a uniform.
  30597. * @param blockName Name of the block to bind.
  30598. * @param index Index to bind.
  30599. */
  30600. bindUniformBlock(blockName: string, index: number): void;
  30601. /**
  30602. * Sets an interger value on a uniform variable.
  30603. * @param uniformName Name of the variable.
  30604. * @param value Value to be set.
  30605. * @returns this effect.
  30606. */
  30607. setInt(uniformName: string, value: number): Effect;
  30608. /**
  30609. * Sets an int array on a uniform variable.
  30610. * @param uniformName Name of the variable.
  30611. * @param array array to be set.
  30612. * @returns this effect.
  30613. */
  30614. setIntArray(uniformName: string, array: Int32Array): Effect;
  30615. /**
  30616. * 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)
  30617. * @param uniformName Name of the variable.
  30618. * @param array array to be set.
  30619. * @returns this effect.
  30620. */
  30621. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30622. /**
  30623. * 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)
  30624. * @param uniformName Name of the variable.
  30625. * @param array array to be set.
  30626. * @returns this effect.
  30627. */
  30628. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30629. /**
  30630. * 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)
  30631. * @param uniformName Name of the variable.
  30632. * @param array array to be set.
  30633. * @returns this effect.
  30634. */
  30635. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30636. /**
  30637. * Sets an float array on a uniform variable.
  30638. * @param uniformName Name of the variable.
  30639. * @param array array to be set.
  30640. * @returns this effect.
  30641. */
  30642. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30643. /**
  30644. * 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)
  30645. * @param uniformName Name of the variable.
  30646. * @param array array to be set.
  30647. * @returns this effect.
  30648. */
  30649. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30650. /**
  30651. * 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)
  30652. * @param uniformName Name of the variable.
  30653. * @param array array to be set.
  30654. * @returns this effect.
  30655. */
  30656. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30657. /**
  30658. * 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)
  30659. * @param uniformName Name of the variable.
  30660. * @param array array to be set.
  30661. * @returns this effect.
  30662. */
  30663. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30664. /**
  30665. * Sets an array on a uniform variable.
  30666. * @param uniformName Name of the variable.
  30667. * @param array array to be set.
  30668. * @returns this effect.
  30669. */
  30670. setArray(uniformName: string, array: number[]): Effect;
  30671. /**
  30672. * 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)
  30673. * @param uniformName Name of the variable.
  30674. * @param array array to be set.
  30675. * @returns this effect.
  30676. */
  30677. setArray2(uniformName: string, array: number[]): Effect;
  30678. /**
  30679. * 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)
  30680. * @param uniformName Name of the variable.
  30681. * @param array array to be set.
  30682. * @returns this effect.
  30683. */
  30684. setArray3(uniformName: string, array: number[]): Effect;
  30685. /**
  30686. * 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)
  30687. * @param uniformName Name of the variable.
  30688. * @param array array to be set.
  30689. * @returns this effect.
  30690. */
  30691. setArray4(uniformName: string, array: number[]): Effect;
  30692. /**
  30693. * Sets matrices on a uniform variable.
  30694. * @param uniformName Name of the variable.
  30695. * @param matrices matrices to be set.
  30696. * @returns this effect.
  30697. */
  30698. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30699. /**
  30700. * Sets matrix on a uniform variable.
  30701. * @param uniformName Name of the variable.
  30702. * @param matrix matrix to be set.
  30703. * @returns this effect.
  30704. */
  30705. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30706. /**
  30707. * 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)
  30708. * @param uniformName Name of the variable.
  30709. * @param matrix matrix to be set.
  30710. * @returns this effect.
  30711. */
  30712. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30713. /**
  30714. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30715. * @param uniformName Name of the variable.
  30716. * @param matrix matrix to be set.
  30717. * @returns this effect.
  30718. */
  30719. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30720. /**
  30721. * Sets a float on a uniform variable.
  30722. * @param uniformName Name of the variable.
  30723. * @param value value to be set.
  30724. * @returns this effect.
  30725. */
  30726. setFloat(uniformName: string, value: number): Effect;
  30727. /**
  30728. * Sets a boolean on a uniform variable.
  30729. * @param uniformName Name of the variable.
  30730. * @param bool value to be set.
  30731. * @returns this effect.
  30732. */
  30733. setBool(uniformName: string, bool: boolean): Effect;
  30734. /**
  30735. * Sets a Vector2 on a uniform variable.
  30736. * @param uniformName Name of the variable.
  30737. * @param vector2 vector2 to be set.
  30738. * @returns this effect.
  30739. */
  30740. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30741. /**
  30742. * Sets a float2 on a uniform variable.
  30743. * @param uniformName Name of the variable.
  30744. * @param x First float in float2.
  30745. * @param y Second float in float2.
  30746. * @returns this effect.
  30747. */
  30748. setFloat2(uniformName: string, x: number, y: number): Effect;
  30749. /**
  30750. * Sets a Vector3 on a uniform variable.
  30751. * @param uniformName Name of the variable.
  30752. * @param vector3 Value to be set.
  30753. * @returns this effect.
  30754. */
  30755. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30756. /**
  30757. * Sets a float3 on a uniform variable.
  30758. * @param uniformName Name of the variable.
  30759. * @param x First float in float3.
  30760. * @param y Second float in float3.
  30761. * @param z Third float in float3.
  30762. * @returns this effect.
  30763. */
  30764. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30765. /**
  30766. * Sets a Vector4 on a uniform variable.
  30767. * @param uniformName Name of the variable.
  30768. * @param vector4 Value to be set.
  30769. * @returns this effect.
  30770. */
  30771. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30772. /**
  30773. * Sets a float4 on a uniform variable.
  30774. * @param uniformName Name of the variable.
  30775. * @param x First float in float4.
  30776. * @param y Second float in float4.
  30777. * @param z Third float in float4.
  30778. * @param w Fourth float in float4.
  30779. * @returns this effect.
  30780. */
  30781. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30782. /**
  30783. * Sets a Color3 on a uniform variable.
  30784. * @param uniformName Name of the variable.
  30785. * @param color3 Value to be set.
  30786. * @returns this effect.
  30787. */
  30788. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30789. /**
  30790. * Sets a Color4 on a uniform variable.
  30791. * @param uniformName Name of the variable.
  30792. * @param color3 Value to be set.
  30793. * @param alpha Alpha value to be set.
  30794. * @returns this effect.
  30795. */
  30796. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30797. /**
  30798. * Sets a Color4 on a uniform variable
  30799. * @param uniformName defines the name of the variable
  30800. * @param color4 defines the value to be set
  30801. * @returns this effect.
  30802. */
  30803. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30804. /** Release all associated resources */
  30805. dispose(): void;
  30806. /**
  30807. * This function will add a new shader to the shader store
  30808. * @param name the name of the shader
  30809. * @param pixelShader optional pixel shader content
  30810. * @param vertexShader optional vertex shader content
  30811. */
  30812. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30813. /**
  30814. * Store of each shader (The can be looked up using effect.key)
  30815. */
  30816. static ShadersStore: {
  30817. [key: string]: string;
  30818. };
  30819. /**
  30820. * Store of each included file for a shader (The can be looked up using effect.key)
  30821. */
  30822. static IncludesShadersStore: {
  30823. [key: string]: string;
  30824. };
  30825. /**
  30826. * Resets the cache of effects.
  30827. */
  30828. static ResetCache(): void;
  30829. }
  30830. }
  30831. declare module BABYLON {
  30832. /**
  30833. * Interface used to describe the capabilities of the engine relatively to the current browser
  30834. */
  30835. export interface EngineCapabilities {
  30836. /** Maximum textures units per fragment shader */
  30837. maxTexturesImageUnits: number;
  30838. /** Maximum texture units per vertex shader */
  30839. maxVertexTextureImageUnits: number;
  30840. /** Maximum textures units in the entire pipeline */
  30841. maxCombinedTexturesImageUnits: number;
  30842. /** Maximum texture size */
  30843. maxTextureSize: number;
  30844. /** Maximum texture samples */
  30845. maxSamples?: number;
  30846. /** Maximum cube texture size */
  30847. maxCubemapTextureSize: number;
  30848. /** Maximum render texture size */
  30849. maxRenderTextureSize: number;
  30850. /** Maximum number of vertex attributes */
  30851. maxVertexAttribs: number;
  30852. /** Maximum number of varyings */
  30853. maxVaryingVectors: number;
  30854. /** Maximum number of uniforms per vertex shader */
  30855. maxVertexUniformVectors: number;
  30856. /** Maximum number of uniforms per fragment shader */
  30857. maxFragmentUniformVectors: number;
  30858. /** Defines if standard derivates (dx/dy) are supported */
  30859. standardDerivatives: boolean;
  30860. /** Defines if s3tc texture compression is supported */
  30861. s3tc?: WEBGL_compressed_texture_s3tc;
  30862. /** Defines if pvrtc texture compression is supported */
  30863. pvrtc: any;
  30864. /** Defines if etc1 texture compression is supported */
  30865. etc1: any;
  30866. /** Defines if etc2 texture compression is supported */
  30867. etc2: any;
  30868. /** Defines if astc texture compression is supported */
  30869. astc: any;
  30870. /** Defines if float textures are supported */
  30871. textureFloat: boolean;
  30872. /** Defines if vertex array objects are supported */
  30873. vertexArrayObject: boolean;
  30874. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30875. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30876. /** Gets the maximum level of anisotropy supported */
  30877. maxAnisotropy: number;
  30878. /** Defines if instancing is supported */
  30879. instancedArrays: boolean;
  30880. /** Defines if 32 bits indices are supported */
  30881. uintIndices: boolean;
  30882. /** Defines if high precision shaders are supported */
  30883. highPrecisionShaderSupported: boolean;
  30884. /** Defines if depth reading in the fragment shader is supported */
  30885. fragmentDepthSupported: boolean;
  30886. /** Defines if float texture linear filtering is supported*/
  30887. textureFloatLinearFiltering: boolean;
  30888. /** Defines if rendering to float textures is supported */
  30889. textureFloatRender: boolean;
  30890. /** Defines if half float textures are supported*/
  30891. textureHalfFloat: boolean;
  30892. /** Defines if half float texture linear filtering is supported*/
  30893. textureHalfFloatLinearFiltering: boolean;
  30894. /** Defines if rendering to half float textures is supported */
  30895. textureHalfFloatRender: boolean;
  30896. /** Defines if textureLOD shader command is supported */
  30897. textureLOD: boolean;
  30898. /** Defines if draw buffers extension is supported */
  30899. drawBuffersExtension: boolean;
  30900. /** Defines if depth textures are supported */
  30901. depthTextureExtension: boolean;
  30902. /** Defines if float color buffer are supported */
  30903. colorBufferFloat: boolean;
  30904. /** Gets disjoint timer query extension (null if not supported) */
  30905. timerQuery?: EXT_disjoint_timer_query;
  30906. /** Defines if timestamp can be used with timer query */
  30907. canUseTimestampForTimerQuery: boolean;
  30908. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30909. multiview?: any;
  30910. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30911. oculusMultiview?: any;
  30912. /** Function used to let the system compiles shaders in background */
  30913. parallelShaderCompile?: {
  30914. COMPLETION_STATUS_KHR: number;
  30915. };
  30916. /** Max number of texture samples for MSAA */
  30917. maxMSAASamples: number;
  30918. /** Defines if the blend min max extension is supported */
  30919. blendMinMax: boolean;
  30920. }
  30921. }
  30922. declare module BABYLON {
  30923. /**
  30924. * @hidden
  30925. **/
  30926. export class DepthCullingState {
  30927. private _isDepthTestDirty;
  30928. private _isDepthMaskDirty;
  30929. private _isDepthFuncDirty;
  30930. private _isCullFaceDirty;
  30931. private _isCullDirty;
  30932. private _isZOffsetDirty;
  30933. private _isFrontFaceDirty;
  30934. private _depthTest;
  30935. private _depthMask;
  30936. private _depthFunc;
  30937. private _cull;
  30938. private _cullFace;
  30939. private _zOffset;
  30940. private _frontFace;
  30941. /**
  30942. * Initializes the state.
  30943. */
  30944. constructor();
  30945. get isDirty(): boolean;
  30946. get zOffset(): number;
  30947. set zOffset(value: number);
  30948. get cullFace(): Nullable<number>;
  30949. set cullFace(value: Nullable<number>);
  30950. get cull(): Nullable<boolean>;
  30951. set cull(value: Nullable<boolean>);
  30952. get depthFunc(): Nullable<number>;
  30953. set depthFunc(value: Nullable<number>);
  30954. get depthMask(): boolean;
  30955. set depthMask(value: boolean);
  30956. get depthTest(): boolean;
  30957. set depthTest(value: boolean);
  30958. get frontFace(): Nullable<number>;
  30959. set frontFace(value: Nullable<number>);
  30960. reset(): void;
  30961. apply(gl: WebGLRenderingContext): void;
  30962. }
  30963. }
  30964. declare module BABYLON {
  30965. /**
  30966. * @hidden
  30967. **/
  30968. export class StencilState {
  30969. /** 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 */
  30970. static readonly ALWAYS: number;
  30971. /** Passed to stencilOperation to specify that stencil value must be kept */
  30972. static readonly KEEP: number;
  30973. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30974. static readonly REPLACE: number;
  30975. private _isStencilTestDirty;
  30976. private _isStencilMaskDirty;
  30977. private _isStencilFuncDirty;
  30978. private _isStencilOpDirty;
  30979. private _stencilTest;
  30980. private _stencilMask;
  30981. private _stencilFunc;
  30982. private _stencilFuncRef;
  30983. private _stencilFuncMask;
  30984. private _stencilOpStencilFail;
  30985. private _stencilOpDepthFail;
  30986. private _stencilOpStencilDepthPass;
  30987. get isDirty(): boolean;
  30988. get stencilFunc(): number;
  30989. set stencilFunc(value: number);
  30990. get stencilFuncRef(): number;
  30991. set stencilFuncRef(value: number);
  30992. get stencilFuncMask(): number;
  30993. set stencilFuncMask(value: number);
  30994. get stencilOpStencilFail(): number;
  30995. set stencilOpStencilFail(value: number);
  30996. get stencilOpDepthFail(): number;
  30997. set stencilOpDepthFail(value: number);
  30998. get stencilOpStencilDepthPass(): number;
  30999. set stencilOpStencilDepthPass(value: number);
  31000. get stencilMask(): number;
  31001. set stencilMask(value: number);
  31002. get stencilTest(): boolean;
  31003. set stencilTest(value: boolean);
  31004. constructor();
  31005. reset(): void;
  31006. apply(gl: WebGLRenderingContext): void;
  31007. }
  31008. }
  31009. declare module BABYLON {
  31010. /**
  31011. * @hidden
  31012. **/
  31013. export class AlphaState {
  31014. private _isAlphaBlendDirty;
  31015. private _isBlendFunctionParametersDirty;
  31016. private _isBlendEquationParametersDirty;
  31017. private _isBlendConstantsDirty;
  31018. private _alphaBlend;
  31019. private _blendFunctionParameters;
  31020. private _blendEquationParameters;
  31021. private _blendConstants;
  31022. /**
  31023. * Initializes the state.
  31024. */
  31025. constructor();
  31026. get isDirty(): boolean;
  31027. get alphaBlend(): boolean;
  31028. set alphaBlend(value: boolean);
  31029. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31030. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31031. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31032. reset(): void;
  31033. apply(gl: WebGLRenderingContext): void;
  31034. }
  31035. }
  31036. declare module BABYLON {
  31037. /** @hidden */
  31038. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31039. attributeProcessor(attribute: string): string;
  31040. varyingProcessor(varying: string, isFragment: boolean): string;
  31041. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31042. }
  31043. }
  31044. declare module BABYLON {
  31045. /**
  31046. * Interface for attribute information associated with buffer instanciation
  31047. */
  31048. export interface InstancingAttributeInfo {
  31049. /**
  31050. * Name of the GLSL attribute
  31051. * if attribute index is not specified, this is used to retrieve the index from the effect
  31052. */
  31053. attributeName: string;
  31054. /**
  31055. * Index/offset of the attribute in the vertex shader
  31056. * if not specified, this will be computes from the name.
  31057. */
  31058. index?: number;
  31059. /**
  31060. * size of the attribute, 1, 2, 3 or 4
  31061. */
  31062. attributeSize: number;
  31063. /**
  31064. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31065. */
  31066. offset: number;
  31067. /**
  31068. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31069. * default to 1
  31070. */
  31071. divisor?: number;
  31072. /**
  31073. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31074. * default is FLOAT
  31075. */
  31076. attributeType?: number;
  31077. /**
  31078. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31079. */
  31080. normalized?: boolean;
  31081. }
  31082. }
  31083. declare module BABYLON {
  31084. interface ThinEngine {
  31085. /**
  31086. * Update a video texture
  31087. * @param texture defines the texture to update
  31088. * @param video defines the video element to use
  31089. * @param invertY defines if data must be stored with Y axis inverted
  31090. */
  31091. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31092. }
  31093. }
  31094. declare module BABYLON {
  31095. /**
  31096. * Settings for finer control over video usage
  31097. */
  31098. export interface VideoTextureSettings {
  31099. /**
  31100. * Applies `autoplay` to video, if specified
  31101. */
  31102. autoPlay?: boolean;
  31103. /**
  31104. * Applies `loop` to video, if specified
  31105. */
  31106. loop?: boolean;
  31107. /**
  31108. * Automatically updates internal texture from video at every frame in the render loop
  31109. */
  31110. autoUpdateTexture: boolean;
  31111. /**
  31112. * Image src displayed during the video loading or until the user interacts with the video.
  31113. */
  31114. poster?: string;
  31115. }
  31116. /**
  31117. * If you want to display a video in your scene, this is the special texture for that.
  31118. * This special texture works similar to other textures, with the exception of a few parameters.
  31119. * @see https://doc.babylonjs.com/how_to/video_texture
  31120. */
  31121. export class VideoTexture extends Texture {
  31122. /**
  31123. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31124. */
  31125. readonly autoUpdateTexture: boolean;
  31126. /**
  31127. * The video instance used by the texture internally
  31128. */
  31129. readonly video: HTMLVideoElement;
  31130. private _onUserActionRequestedObservable;
  31131. /**
  31132. * Event triggerd when a dom action is required by the user to play the video.
  31133. * This happens due to recent changes in browser policies preventing video to auto start.
  31134. */
  31135. get onUserActionRequestedObservable(): Observable<Texture>;
  31136. private _generateMipMaps;
  31137. private _engine;
  31138. private _stillImageCaptured;
  31139. private _displayingPosterTexture;
  31140. private _settings;
  31141. private _createInternalTextureOnEvent;
  31142. private _frameId;
  31143. private _currentSrc;
  31144. /**
  31145. * Creates a video texture.
  31146. * If you want to display a video in your scene, this is the special texture for that.
  31147. * This special texture works similar to other textures, with the exception of a few parameters.
  31148. * @see https://doc.babylonjs.com/how_to/video_texture
  31149. * @param name optional name, will detect from video source, if not defined
  31150. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31151. * @param scene is obviously the current scene.
  31152. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31153. * @param invertY is false by default but can be used to invert video on Y axis
  31154. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31155. * @param settings allows finer control over video usage
  31156. */
  31157. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31158. private _getName;
  31159. private _getVideo;
  31160. private _createInternalTexture;
  31161. private reset;
  31162. /**
  31163. * @hidden Internal method to initiate `update`.
  31164. */
  31165. _rebuild(): void;
  31166. /**
  31167. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31168. */
  31169. update(): void;
  31170. /**
  31171. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31172. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31173. */
  31174. updateTexture(isVisible: boolean): void;
  31175. protected _updateInternalTexture: () => void;
  31176. /**
  31177. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31178. * @param url New url.
  31179. */
  31180. updateURL(url: string): void;
  31181. /**
  31182. * Clones the texture.
  31183. * @returns the cloned texture
  31184. */
  31185. clone(): VideoTexture;
  31186. /**
  31187. * Dispose the texture and release its associated resources.
  31188. */
  31189. dispose(): void;
  31190. /**
  31191. * Creates a video texture straight from a stream.
  31192. * @param scene Define the scene the texture should be created in
  31193. * @param stream Define the stream the texture should be created from
  31194. * @returns The created video texture as a promise
  31195. */
  31196. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31197. /**
  31198. * Creates a video texture straight from your WebCam video feed.
  31199. * @param scene Define the scene the texture should be created in
  31200. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31201. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31202. * @returns The created video texture as a promise
  31203. */
  31204. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31205. minWidth: number;
  31206. maxWidth: number;
  31207. minHeight: number;
  31208. maxHeight: number;
  31209. deviceId: string;
  31210. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31211. /**
  31212. * Creates a video texture straight from your WebCam video feed.
  31213. * @param scene Define the scene the texture should be created in
  31214. * @param onReady Define a callback to triggered once the texture will be ready
  31215. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31216. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31217. */
  31218. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31219. minWidth: number;
  31220. maxWidth: number;
  31221. minHeight: number;
  31222. maxHeight: number;
  31223. deviceId: string;
  31224. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31225. }
  31226. }
  31227. declare module BABYLON {
  31228. /**
  31229. * Defines the interface used by objects working like Scene
  31230. * @hidden
  31231. */
  31232. export interface ISceneLike {
  31233. _addPendingData(data: any): void;
  31234. _removePendingData(data: any): void;
  31235. offlineProvider: IOfflineProvider;
  31236. }
  31237. /** Interface defining initialization parameters for Engine class */
  31238. export interface EngineOptions extends WebGLContextAttributes {
  31239. /**
  31240. * Defines if the engine should no exceed a specified device ratio
  31241. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31242. */
  31243. limitDeviceRatio?: number;
  31244. /**
  31245. * Defines if webvr should be enabled automatically
  31246. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31247. */
  31248. autoEnableWebVR?: boolean;
  31249. /**
  31250. * Defines if webgl2 should be turned off even if supported
  31251. * @see http://doc.babylonjs.com/features/webgl2
  31252. */
  31253. disableWebGL2Support?: boolean;
  31254. /**
  31255. * Defines if webaudio should be initialized as well
  31256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31257. */
  31258. audioEngine?: boolean;
  31259. /**
  31260. * Defines if animations should run using a deterministic lock step
  31261. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31262. */
  31263. deterministicLockstep?: boolean;
  31264. /** Defines the maximum steps to use with deterministic lock step mode */
  31265. lockstepMaxSteps?: number;
  31266. /** Defines the seconds between each deterministic lock step */
  31267. timeStep?: number;
  31268. /**
  31269. * Defines that engine should ignore context lost events
  31270. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31271. */
  31272. doNotHandleContextLost?: boolean;
  31273. /**
  31274. * Defines that engine should ignore modifying touch action attribute and style
  31275. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31276. */
  31277. doNotHandleTouchAction?: boolean;
  31278. /**
  31279. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31280. */
  31281. useHighPrecisionFloats?: boolean;
  31282. }
  31283. /**
  31284. * The base engine class (root of all engines)
  31285. */
  31286. export class ThinEngine {
  31287. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31288. static ExceptionList: ({
  31289. key: string;
  31290. capture: string;
  31291. captureConstraint: number;
  31292. targets: string[];
  31293. } | {
  31294. key: string;
  31295. capture: null;
  31296. captureConstraint: null;
  31297. targets: string[];
  31298. })[];
  31299. /** @hidden */
  31300. static _TextureLoaders: IInternalTextureLoader[];
  31301. /**
  31302. * Returns the current npm package of the sdk
  31303. */
  31304. static get NpmPackage(): string;
  31305. /**
  31306. * Returns the current version of the framework
  31307. */
  31308. static get Version(): string;
  31309. /**
  31310. * Returns a string describing the current engine
  31311. */
  31312. get description(): string;
  31313. /**
  31314. * Gets or sets the epsilon value used by collision engine
  31315. */
  31316. static CollisionsEpsilon: number;
  31317. /**
  31318. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31319. */
  31320. static get ShadersRepository(): string;
  31321. static set ShadersRepository(value: string);
  31322. /** @hidden */
  31323. _shaderProcessor: IShaderProcessor;
  31324. /**
  31325. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31326. */
  31327. forcePOTTextures: boolean;
  31328. /**
  31329. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31330. */
  31331. isFullscreen: boolean;
  31332. /**
  31333. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31334. */
  31335. cullBackFaces: boolean;
  31336. /**
  31337. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31338. */
  31339. renderEvenInBackground: boolean;
  31340. /**
  31341. * Gets or sets a boolean indicating that cache can be kept between frames
  31342. */
  31343. preventCacheWipeBetweenFrames: boolean;
  31344. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31345. validateShaderPrograms: boolean;
  31346. /**
  31347. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31348. * This can provide greater z depth for distant objects.
  31349. */
  31350. useReverseDepthBuffer: boolean;
  31351. /**
  31352. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31353. */
  31354. disableUniformBuffers: boolean;
  31355. /** @hidden */
  31356. _uniformBuffers: UniformBuffer[];
  31357. /**
  31358. * Gets a boolean indicating that the engine supports uniform buffers
  31359. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31360. */
  31361. get supportsUniformBuffers(): boolean;
  31362. /** @hidden */
  31363. _gl: WebGLRenderingContext;
  31364. /** @hidden */
  31365. _webGLVersion: number;
  31366. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31367. protected _windowIsBackground: boolean;
  31368. protected _creationOptions: EngineOptions;
  31369. protected _highPrecisionShadersAllowed: boolean;
  31370. /** @hidden */
  31371. get _shouldUseHighPrecisionShader(): boolean;
  31372. /**
  31373. * Gets a boolean indicating that only power of 2 textures are supported
  31374. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31375. */
  31376. get needPOTTextures(): boolean;
  31377. /** @hidden */
  31378. _badOS: boolean;
  31379. /** @hidden */
  31380. _badDesktopOS: boolean;
  31381. private _hardwareScalingLevel;
  31382. /** @hidden */
  31383. _caps: EngineCapabilities;
  31384. private _isStencilEnable;
  31385. private _glVersion;
  31386. private _glRenderer;
  31387. private _glVendor;
  31388. /** @hidden */
  31389. _videoTextureSupported: boolean;
  31390. protected _renderingQueueLaunched: boolean;
  31391. protected _activeRenderLoops: (() => void)[];
  31392. /**
  31393. * Observable signaled when a context lost event is raised
  31394. */
  31395. onContextLostObservable: Observable<ThinEngine>;
  31396. /**
  31397. * Observable signaled when a context restored event is raised
  31398. */
  31399. onContextRestoredObservable: Observable<ThinEngine>;
  31400. private _onContextLost;
  31401. private _onContextRestored;
  31402. protected _contextWasLost: boolean;
  31403. /** @hidden */
  31404. _doNotHandleContextLost: boolean;
  31405. /**
  31406. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31408. */
  31409. get doNotHandleContextLost(): boolean;
  31410. set doNotHandleContextLost(value: boolean);
  31411. /**
  31412. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31413. */
  31414. disableVertexArrayObjects: boolean;
  31415. /** @hidden */
  31416. protected _colorWrite: boolean;
  31417. /** @hidden */
  31418. protected _colorWriteChanged: boolean;
  31419. /** @hidden */
  31420. protected _depthCullingState: DepthCullingState;
  31421. /** @hidden */
  31422. protected _stencilState: StencilState;
  31423. /** @hidden */
  31424. _alphaState: AlphaState;
  31425. /** @hidden */
  31426. _alphaMode: number;
  31427. /** @hidden */
  31428. _alphaEquation: number;
  31429. /** @hidden */
  31430. _internalTexturesCache: InternalTexture[];
  31431. /** @hidden */
  31432. protected _activeChannel: number;
  31433. private _currentTextureChannel;
  31434. /** @hidden */
  31435. protected _boundTexturesCache: {
  31436. [key: string]: Nullable<InternalTexture>;
  31437. };
  31438. /** @hidden */
  31439. protected _currentEffect: Nullable<Effect>;
  31440. /** @hidden */
  31441. protected _currentProgram: Nullable<WebGLProgram>;
  31442. private _compiledEffects;
  31443. private _vertexAttribArraysEnabled;
  31444. /** @hidden */
  31445. protected _cachedViewport: Nullable<IViewportLike>;
  31446. private _cachedVertexArrayObject;
  31447. /** @hidden */
  31448. protected _cachedVertexBuffers: any;
  31449. /** @hidden */
  31450. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31451. /** @hidden */
  31452. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31453. /** @hidden */
  31454. _currentRenderTarget: Nullable<InternalTexture>;
  31455. private _uintIndicesCurrentlySet;
  31456. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31457. /** @hidden */
  31458. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31459. private _currentBufferPointers;
  31460. private _currentInstanceLocations;
  31461. private _currentInstanceBuffers;
  31462. private _textureUnits;
  31463. /** @hidden */
  31464. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31465. /** @hidden */
  31466. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31467. /** @hidden */
  31468. _boundRenderFunction: any;
  31469. private _vaoRecordInProgress;
  31470. private _mustWipeVertexAttributes;
  31471. private _emptyTexture;
  31472. private _emptyCubeTexture;
  31473. private _emptyTexture3D;
  31474. private _emptyTexture2DArray;
  31475. /** @hidden */
  31476. _frameHandler: number;
  31477. private _nextFreeTextureSlots;
  31478. private _maxSimultaneousTextures;
  31479. private _activeRequests;
  31480. /** @hidden */
  31481. _transformTextureUrl: Nullable<(url: string) => string>;
  31482. protected get _supportsHardwareTextureRescaling(): boolean;
  31483. private _framebufferDimensionsObject;
  31484. /**
  31485. * sets the object from which width and height will be taken from when getting render width and height
  31486. * Will fallback to the gl object
  31487. * @param dimensions the framebuffer width and height that will be used.
  31488. */
  31489. set framebufferDimensionsObject(dimensions: Nullable<{
  31490. framebufferWidth: number;
  31491. framebufferHeight: number;
  31492. }>);
  31493. /**
  31494. * Gets the current viewport
  31495. */
  31496. get currentViewport(): Nullable<IViewportLike>;
  31497. /**
  31498. * Gets the default empty texture
  31499. */
  31500. get emptyTexture(): InternalTexture;
  31501. /**
  31502. * Gets the default empty 3D texture
  31503. */
  31504. get emptyTexture3D(): InternalTexture;
  31505. /**
  31506. * Gets the default empty 2D array texture
  31507. */
  31508. get emptyTexture2DArray(): InternalTexture;
  31509. /**
  31510. * Gets the default empty cube texture
  31511. */
  31512. get emptyCubeTexture(): InternalTexture;
  31513. /**
  31514. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31515. */
  31516. readonly premultipliedAlpha: boolean;
  31517. /**
  31518. * Observable event triggered before each texture is initialized
  31519. */
  31520. onBeforeTextureInitObservable: Observable<Texture>;
  31521. /**
  31522. * Creates a new engine
  31523. * @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
  31524. * @param antialias defines enable antialiasing (default: false)
  31525. * @param options defines further options to be sent to the getContext() function
  31526. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31527. */
  31528. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31529. private _rebuildInternalTextures;
  31530. private _rebuildEffects;
  31531. /**
  31532. * Gets a boolean indicating if all created effects are ready
  31533. * @returns true if all effects are ready
  31534. */
  31535. areAllEffectsReady(): boolean;
  31536. protected _rebuildBuffers(): void;
  31537. protected _initGLContext(): void;
  31538. /**
  31539. * Gets version of the current webGL context
  31540. */
  31541. get webGLVersion(): number;
  31542. /**
  31543. * Gets a string idenfifying the name of the class
  31544. * @returns "Engine" string
  31545. */
  31546. getClassName(): string;
  31547. /**
  31548. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31549. */
  31550. get isStencilEnable(): boolean;
  31551. /** @hidden */
  31552. _prepareWorkingCanvas(): void;
  31553. /**
  31554. * Reset the texture cache to empty state
  31555. */
  31556. resetTextureCache(): void;
  31557. /**
  31558. * Gets an object containing information about the current webGL context
  31559. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31560. */
  31561. getGlInfo(): {
  31562. vendor: string;
  31563. renderer: string;
  31564. version: string;
  31565. };
  31566. /**
  31567. * Defines the hardware scaling level.
  31568. * By default the hardware scaling level is computed from the window device ratio.
  31569. * 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.
  31570. * @param level defines the level to use
  31571. */
  31572. setHardwareScalingLevel(level: number): void;
  31573. /**
  31574. * Gets the current 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. * @returns a number indicating the current hardware scaling level
  31578. */
  31579. getHardwareScalingLevel(): number;
  31580. /**
  31581. * Gets the list of loaded textures
  31582. * @returns an array containing all loaded textures
  31583. */
  31584. getLoadedTexturesCache(): InternalTexture[];
  31585. /**
  31586. * Gets the object containing all engine capabilities
  31587. * @returns the EngineCapabilities object
  31588. */
  31589. getCaps(): EngineCapabilities;
  31590. /**
  31591. * stop executing a render loop function and remove it from the execution array
  31592. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31593. */
  31594. stopRenderLoop(renderFunction?: () => void): void;
  31595. /** @hidden */
  31596. _renderLoop(): void;
  31597. /**
  31598. * Gets the HTML canvas attached with the current webGL context
  31599. * @returns a HTML canvas
  31600. */
  31601. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31602. /**
  31603. * Gets host window
  31604. * @returns the host window object
  31605. */
  31606. getHostWindow(): Nullable<Window>;
  31607. /**
  31608. * Gets the current render width
  31609. * @param useScreen defines if screen size must be used (or the current render target if any)
  31610. * @returns a number defining the current render width
  31611. */
  31612. getRenderWidth(useScreen?: boolean): number;
  31613. /**
  31614. * Gets the current render height
  31615. * @param useScreen defines if screen size must be used (or the current render target if any)
  31616. * @returns a number defining the current render height
  31617. */
  31618. getRenderHeight(useScreen?: boolean): number;
  31619. /**
  31620. * Can be used to override the current requestAnimationFrame requester.
  31621. * @hidden
  31622. */
  31623. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31624. /**
  31625. * Register and execute a render loop. The engine can have more than one render function
  31626. * @param renderFunction defines the function to continuously execute
  31627. */
  31628. runRenderLoop(renderFunction: () => void): void;
  31629. /**
  31630. * Clear the current render buffer or the current render target (if any is set up)
  31631. * @param color defines the color to use
  31632. * @param backBuffer defines if the back buffer must be cleared
  31633. * @param depth defines if the depth buffer must be cleared
  31634. * @param stencil defines if the stencil buffer must be cleared
  31635. */
  31636. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31637. private _viewportCached;
  31638. /** @hidden */
  31639. _viewport(x: number, y: number, width: number, height: number): void;
  31640. /**
  31641. * Set the WebGL's viewport
  31642. * @param viewport defines the viewport element to be used
  31643. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31644. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31645. */
  31646. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31647. /**
  31648. * Begin a new frame
  31649. */
  31650. beginFrame(): void;
  31651. /**
  31652. * Enf the current frame
  31653. */
  31654. endFrame(): void;
  31655. /**
  31656. * Resize the view according to the canvas' size
  31657. */
  31658. resize(): void;
  31659. /**
  31660. * Force a specific size of the canvas
  31661. * @param width defines the new canvas' width
  31662. * @param height defines the new canvas' height
  31663. */
  31664. setSize(width: number, height: number): void;
  31665. /**
  31666. * Binds the frame buffer to the specified texture.
  31667. * @param texture The texture to render to or null for the default canvas
  31668. * @param faceIndex The face of the texture to render to in case of cube texture
  31669. * @param requiredWidth The width of the target to render to
  31670. * @param requiredHeight The height of the target to render to
  31671. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31672. * @param lodLevel defines the lod level to bind to the frame buffer
  31673. * @param layer defines the 2d array index to bind to frame buffer to
  31674. */
  31675. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31676. /** @hidden */
  31677. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31678. /**
  31679. * Unbind the current render target texture from the webGL context
  31680. * @param texture defines the render target texture to unbind
  31681. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31682. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31683. */
  31684. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31685. /**
  31686. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31687. */
  31688. flushFramebuffer(): void;
  31689. /**
  31690. * Unbind the current render target and bind the default framebuffer
  31691. */
  31692. restoreDefaultFramebuffer(): void;
  31693. /** @hidden */
  31694. protected _resetVertexBufferBinding(): void;
  31695. /**
  31696. * Creates a vertex buffer
  31697. * @param data the data for the vertex buffer
  31698. * @returns the new WebGL static buffer
  31699. */
  31700. createVertexBuffer(data: DataArray): DataBuffer;
  31701. private _createVertexBuffer;
  31702. /**
  31703. * Creates a dynamic vertex buffer
  31704. * @param data the data for the dynamic vertex buffer
  31705. * @returns the new WebGL dynamic buffer
  31706. */
  31707. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31708. protected _resetIndexBufferBinding(): void;
  31709. /**
  31710. * Creates a new index buffer
  31711. * @param indices defines the content of the index buffer
  31712. * @param updatable defines if the index buffer must be updatable
  31713. * @returns a new webGL buffer
  31714. */
  31715. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31716. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31717. /**
  31718. * Bind a webGL buffer to the webGL context
  31719. * @param buffer defines the buffer to bind
  31720. */
  31721. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31722. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31723. private bindBuffer;
  31724. /**
  31725. * update the bound buffer with the given data
  31726. * @param data defines the data to update
  31727. */
  31728. updateArrayBuffer(data: Float32Array): void;
  31729. private _vertexAttribPointer;
  31730. /** @hidden */
  31731. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31732. private _bindVertexBuffersAttributes;
  31733. /**
  31734. * Records a vertex array object
  31735. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31736. * @param vertexBuffers defines the list of vertex buffers to store
  31737. * @param indexBuffer defines the index buffer to store
  31738. * @param effect defines the effect to store
  31739. * @returns the new vertex array object
  31740. */
  31741. recordVertexArrayObject(vertexBuffers: {
  31742. [key: string]: VertexBuffer;
  31743. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31744. /**
  31745. * Bind a specific vertex array object
  31746. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31747. * @param vertexArrayObject defines the vertex array object to bind
  31748. * @param indexBuffer defines the index buffer to bind
  31749. */
  31750. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31751. /**
  31752. * Bind webGl buffers directly to the webGL context
  31753. * @param vertexBuffer defines the vertex buffer to bind
  31754. * @param indexBuffer defines the index buffer to bind
  31755. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31756. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31757. * @param effect defines the effect associated with the vertex buffer
  31758. */
  31759. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31760. private _unbindVertexArrayObject;
  31761. /**
  31762. * Bind a list of vertex buffers to the webGL context
  31763. * @param vertexBuffers defines the list of vertex buffers to bind
  31764. * @param indexBuffer defines the index buffer to bind
  31765. * @param effect defines the effect associated with the vertex buffers
  31766. */
  31767. bindBuffers(vertexBuffers: {
  31768. [key: string]: Nullable<VertexBuffer>;
  31769. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31770. /**
  31771. * Unbind all instance attributes
  31772. */
  31773. unbindInstanceAttributes(): void;
  31774. /**
  31775. * Release and free the memory of a vertex array object
  31776. * @param vao defines the vertex array object to delete
  31777. */
  31778. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31779. /** @hidden */
  31780. _releaseBuffer(buffer: DataBuffer): boolean;
  31781. protected _deleteBuffer(buffer: DataBuffer): void;
  31782. /**
  31783. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31784. * @param instancesBuffer defines the webGL buffer to update and bind
  31785. * @param data defines the data to store in the buffer
  31786. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31787. */
  31788. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31789. /**
  31790. * Bind the content of a webGL buffer used with instantiation
  31791. * @param instancesBuffer defines the webGL buffer to bind
  31792. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31793. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31794. */
  31795. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31796. /**
  31797. * Disable the instance attribute corresponding to the name in parameter
  31798. * @param name defines the name of the attribute to disable
  31799. */
  31800. disableInstanceAttributeByName(name: string): void;
  31801. /**
  31802. * Disable the instance attribute corresponding to the location in parameter
  31803. * @param attributeLocation defines the attribute location of the attribute to disable
  31804. */
  31805. disableInstanceAttribute(attributeLocation: number): void;
  31806. /**
  31807. * Disable the attribute corresponding to the location in parameter
  31808. * @param attributeLocation defines the attribute location of the attribute to disable
  31809. */
  31810. disableAttributeByIndex(attributeLocation: number): void;
  31811. /**
  31812. * Send a draw order
  31813. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31814. * @param indexStart defines the starting index
  31815. * @param indexCount defines the number of index to draw
  31816. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31817. */
  31818. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31819. /**
  31820. * Draw a list of points
  31821. * @param verticesStart defines the index of first vertex to draw
  31822. * @param verticesCount defines the count of vertices to draw
  31823. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31824. */
  31825. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31826. /**
  31827. * Draw a list of unindexed primitives
  31828. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31829. * @param verticesStart defines the index of first vertex to draw
  31830. * @param verticesCount defines the count of vertices to draw
  31831. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31832. */
  31833. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31834. /**
  31835. * Draw a list of indexed primitives
  31836. * @param fillMode defines the primitive to use
  31837. * @param indexStart defines the starting index
  31838. * @param indexCount defines the number of index to draw
  31839. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31840. */
  31841. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31842. /**
  31843. * Draw a list of unindexed primitives
  31844. * @param fillMode defines the primitive to use
  31845. * @param verticesStart defines the index of first vertex to draw
  31846. * @param verticesCount defines the count of vertices to draw
  31847. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31848. */
  31849. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31850. private _drawMode;
  31851. /** @hidden */
  31852. protected _reportDrawCall(): void;
  31853. /** @hidden */
  31854. _releaseEffect(effect: Effect): void;
  31855. /** @hidden */
  31856. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31857. /**
  31858. * Create a new effect (used to store vertex/fragment shaders)
  31859. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31860. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31861. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31862. * @param samplers defines an array of string used to represent textures
  31863. * @param defines defines the string containing the defines to use to compile the shaders
  31864. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31865. * @param onCompiled defines a function to call when the effect creation is successful
  31866. * @param onError defines a function to call when the effect creation has failed
  31867. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31868. * @returns the new Effect
  31869. */
  31870. 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;
  31871. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31872. private _compileShader;
  31873. private _compileRawShader;
  31874. /** @hidden */
  31875. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31876. /**
  31877. * Directly creates a webGL program
  31878. * @param pipelineContext defines the pipeline context to attach to
  31879. * @param vertexCode defines the vertex shader code to use
  31880. * @param fragmentCode defines the fragment shader code to use
  31881. * @param context defines the webGL context to use (if not set, the current one will be used)
  31882. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31883. * @returns the new webGL program
  31884. */
  31885. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31886. /**
  31887. * Creates a webGL program
  31888. * @param pipelineContext defines the pipeline context to attach to
  31889. * @param vertexCode defines the vertex shader code to use
  31890. * @param fragmentCode defines the fragment shader code to use
  31891. * @param defines defines the string containing the defines to use to compile the shaders
  31892. * @param context defines the webGL context to use (if not set, the current one will be used)
  31893. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31894. * @returns the new webGL program
  31895. */
  31896. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31897. /**
  31898. * Creates a new pipeline context
  31899. * @returns the new pipeline
  31900. */
  31901. createPipelineContext(): IPipelineContext;
  31902. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31903. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31904. /** @hidden */
  31905. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31906. /** @hidden */
  31907. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31908. /** @hidden */
  31909. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31910. /**
  31911. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31912. * @param pipelineContext defines the pipeline context to use
  31913. * @param uniformsNames defines the list of uniform names
  31914. * @returns an array of webGL uniform locations
  31915. */
  31916. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31917. /**
  31918. * Gets the lsit of active attributes for a given webGL program
  31919. * @param pipelineContext defines the pipeline context to use
  31920. * @param attributesNames defines the list of attribute names to get
  31921. * @returns an array of indices indicating the offset of each attribute
  31922. */
  31923. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31924. /**
  31925. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31926. * @param effect defines the effect to activate
  31927. */
  31928. enableEffect(effect: Nullable<Effect>): void;
  31929. /**
  31930. * Set the value of an uniform to a number (int)
  31931. * @param uniform defines the webGL uniform location where to store the value
  31932. * @param value defines the int number to store
  31933. */
  31934. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31935. /**
  31936. * Set the value of an uniform to an array of int32
  31937. * @param uniform defines the webGL uniform location where to store the value
  31938. * @param array defines the array of int32 to store
  31939. */
  31940. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31941. /**
  31942. * Set the value of an uniform to an array of int32 (stored as vec2)
  31943. * @param uniform defines the webGL uniform location where to store the value
  31944. * @param array defines the array of int32 to store
  31945. */
  31946. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31947. /**
  31948. * Set the value of an uniform to an array of int32 (stored as vec3)
  31949. * @param uniform defines the webGL uniform location where to store the value
  31950. * @param array defines the array of int32 to store
  31951. */
  31952. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31953. /**
  31954. * Set the value of an uniform to an array of int32 (stored as vec4)
  31955. * @param uniform defines the webGL uniform location where to store the value
  31956. * @param array defines the array of int32 to store
  31957. */
  31958. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31959. /**
  31960. * Set the value of an uniform to an array of number
  31961. * @param uniform defines the webGL uniform location where to store the value
  31962. * @param array defines the array of number to store
  31963. */
  31964. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31965. /**
  31966. * Set the value of an uniform to an array of number (stored as vec2)
  31967. * @param uniform defines the webGL uniform location where to store the value
  31968. * @param array defines the array of number to store
  31969. */
  31970. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31971. /**
  31972. * Set the value of an uniform to an array of number (stored as vec3)
  31973. * @param uniform defines the webGL uniform location where to store the value
  31974. * @param array defines the array of number to store
  31975. */
  31976. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31977. /**
  31978. * Set the value of an uniform to an array of number (stored as vec4)
  31979. * @param uniform defines the webGL uniform location where to store the value
  31980. * @param array defines the array of number to store
  31981. */
  31982. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31983. /**
  31984. * Set the value of an uniform to an array of float32 (stored as matrices)
  31985. * @param uniform defines the webGL uniform location where to store the value
  31986. * @param matrices defines the array of float32 to store
  31987. */
  31988. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31989. /**
  31990. * Set the value of an uniform to a matrix (3x3)
  31991. * @param uniform defines the webGL uniform location where to store the value
  31992. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31993. */
  31994. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31995. /**
  31996. * Set the value of an uniform to a matrix (2x2)
  31997. * @param uniform defines the webGL uniform location where to store the value
  31998. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31999. */
  32000. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32001. /**
  32002. * Set the value of an uniform to a number (float)
  32003. * @param uniform defines the webGL uniform location where to store the value
  32004. * @param value defines the float number to store
  32005. */
  32006. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32007. /**
  32008. * Set the value of an uniform to a vec2
  32009. * @param uniform defines the webGL uniform location where to store the value
  32010. * @param x defines the 1st component of the value
  32011. * @param y defines the 2nd component of the value
  32012. */
  32013. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32014. /**
  32015. * Set the value of an uniform to a vec3
  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. * @param z defines the 3rd component of the value
  32020. */
  32021. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32022. /**
  32023. * Set the value of an uniform to a vec4
  32024. * @param uniform defines the webGL uniform location where to store the value
  32025. * @param x defines the 1st component of the value
  32026. * @param y defines the 2nd component of the value
  32027. * @param z defines the 3rd component of the value
  32028. * @param w defines the 4th component of the value
  32029. */
  32030. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32031. /**
  32032. * Apply all cached states (depth, culling, stencil and alpha)
  32033. */
  32034. applyStates(): void;
  32035. /**
  32036. * Enable or disable color writing
  32037. * @param enable defines the state to set
  32038. */
  32039. setColorWrite(enable: boolean): void;
  32040. /**
  32041. * Gets a boolean indicating if color writing is enabled
  32042. * @returns the current color writing state
  32043. */
  32044. getColorWrite(): boolean;
  32045. /**
  32046. * Gets the depth culling state manager
  32047. */
  32048. get depthCullingState(): DepthCullingState;
  32049. /**
  32050. * Gets the alpha state manager
  32051. */
  32052. get alphaState(): AlphaState;
  32053. /**
  32054. * Gets the stencil state manager
  32055. */
  32056. get stencilState(): StencilState;
  32057. /**
  32058. * Clears the list of texture accessible through engine.
  32059. * This can help preventing texture load conflict due to name collision.
  32060. */
  32061. clearInternalTexturesCache(): void;
  32062. /**
  32063. * Force the entire cache to be cleared
  32064. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32065. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32066. */
  32067. wipeCaches(bruteForce?: boolean): void;
  32068. /** @hidden */
  32069. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32070. min: number;
  32071. mag: number;
  32072. };
  32073. /** @hidden */
  32074. _createTexture(): WebGLTexture;
  32075. /**
  32076. * Usually called from Texture.ts.
  32077. * Passed information to create a WebGLTexture
  32078. * @param url defines a value which contains one of the following:
  32079. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32080. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32081. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32082. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32083. * @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)
  32084. * @param scene needed for loading to the correct scene
  32085. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32086. * @param onLoad optional callback to be called upon successful completion
  32087. * @param onError optional callback to be called upon failure
  32088. * @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
  32089. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32090. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32091. * @param forcedExtension defines the extension to use to pick the right loader
  32092. * @param mimeType defines an optional mime type
  32093. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32094. */
  32095. 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;
  32096. /**
  32097. * Loads an image as an HTMLImageElement.
  32098. * @param input url string, ArrayBuffer, or Blob to load
  32099. * @param onLoad callback called when the image successfully loads
  32100. * @param onError callback called when the image fails to load
  32101. * @param offlineProvider offline provider for caching
  32102. * @param mimeType optional mime type
  32103. * @returns the HTMLImageElement of the loaded image
  32104. * @hidden
  32105. */
  32106. 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>;
  32107. /**
  32108. * @hidden
  32109. */
  32110. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32111. /**
  32112. * Creates a raw texture
  32113. * @param data defines the data to store in the texture
  32114. * @param width defines the width of the texture
  32115. * @param height defines the height of the texture
  32116. * @param format defines the format of the data
  32117. * @param generateMipMaps defines if the engine should generate the mip levels
  32118. * @param invertY defines if data must be stored with Y axis inverted
  32119. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32120. * @param compression defines the compression used (null by default)
  32121. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32122. * @returns the raw texture inside an InternalTexture
  32123. */
  32124. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32125. /**
  32126. * Creates a new raw cube texture
  32127. * @param data defines the array of data to use to create each face
  32128. * @param size defines the size of the textures
  32129. * @param format defines the format of the data
  32130. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32131. * @param generateMipMaps defines if the engine should generate the mip levels
  32132. * @param invertY defines if data must be stored with Y axis inverted
  32133. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32134. * @param compression defines the compression used (null by default)
  32135. * @returns the cube texture as an InternalTexture
  32136. */
  32137. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32138. /**
  32139. * Creates a new raw 3D texture
  32140. * @param data defines the data used to create the texture
  32141. * @param width defines the width of the texture
  32142. * @param height defines the height of the texture
  32143. * @param depth defines the depth of the texture
  32144. * @param format defines the format of the texture
  32145. * @param generateMipMaps defines if the engine must generate mip levels
  32146. * @param invertY defines if data must be stored with Y axis inverted
  32147. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32148. * @param compression defines the compressed used (can be null)
  32149. * @param textureType defines the compressed used (can be null)
  32150. * @returns a new raw 3D texture (stored in an InternalTexture)
  32151. */
  32152. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32153. /**
  32154. * Creates a new raw 2D array texture
  32155. * @param data defines the data used to create the texture
  32156. * @param width defines the width of the texture
  32157. * @param height defines the height of the texture
  32158. * @param depth defines the number of layers of the texture
  32159. * @param format defines the format of the texture
  32160. * @param generateMipMaps defines if the engine must generate mip levels
  32161. * @param invertY defines if data must be stored with Y axis inverted
  32162. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32163. * @param compression defines the compressed used (can be null)
  32164. * @param textureType defines the compressed used (can be null)
  32165. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32166. */
  32167. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32168. private _unpackFlipYCached;
  32169. /**
  32170. * In case you are sharing the context with other applications, it might
  32171. * be interested to not cache the unpack flip y state to ensure a consistent
  32172. * value would be set.
  32173. */
  32174. enableUnpackFlipYCached: boolean;
  32175. /** @hidden */
  32176. _unpackFlipY(value: boolean): void;
  32177. /** @hidden */
  32178. _getUnpackAlignement(): number;
  32179. private _getTextureTarget;
  32180. /**
  32181. * Update the sampling mode of a given texture
  32182. * @param samplingMode defines the required sampling mode
  32183. * @param texture defines the texture to update
  32184. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32185. */
  32186. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32187. /**
  32188. * Update the sampling mode of a given texture
  32189. * @param texture defines the texture to update
  32190. * @param wrapU defines the texture wrap mode of the u coordinates
  32191. * @param wrapV defines the texture wrap mode of the v coordinates
  32192. * @param wrapR defines the texture wrap mode of the r coordinates
  32193. */
  32194. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32195. /** @hidden */
  32196. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32197. width: number;
  32198. height: number;
  32199. layers?: number;
  32200. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32201. /** @hidden */
  32202. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32203. /** @hidden */
  32204. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32205. /**
  32206. * Update a portion of an internal texture
  32207. * @param texture defines the texture to update
  32208. * @param imageData defines the data to store into the texture
  32209. * @param xOffset defines the x coordinates of the update rectangle
  32210. * @param yOffset defines the y coordinates of the update rectangle
  32211. * @param width defines the width of the update rectangle
  32212. * @param height defines the height of the update rectangle
  32213. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32214. * @param lod defines the lod level to update (0 by default)
  32215. */
  32216. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32217. /** @hidden */
  32218. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32219. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32220. private _prepareWebGLTexture;
  32221. /** @hidden */
  32222. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32223. private _getDepthStencilBuffer;
  32224. /** @hidden */
  32225. _releaseFramebufferObjects(texture: InternalTexture): void;
  32226. /** @hidden */
  32227. _releaseTexture(texture: InternalTexture): void;
  32228. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32229. protected _setProgram(program: WebGLProgram): void;
  32230. protected _boundUniforms: {
  32231. [key: number]: WebGLUniformLocation;
  32232. };
  32233. /**
  32234. * Binds an effect to the webGL context
  32235. * @param effect defines the effect to bind
  32236. */
  32237. bindSamplers(effect: Effect): void;
  32238. private _activateCurrentTexture;
  32239. /** @hidden */
  32240. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32241. /** @hidden */
  32242. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32243. /**
  32244. * Unbind all textures from the webGL context
  32245. */
  32246. unbindAllTextures(): void;
  32247. /**
  32248. * Sets a texture to the according uniform.
  32249. * @param channel The texture channel
  32250. * @param uniform The uniform to set
  32251. * @param texture The texture to apply
  32252. */
  32253. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32254. private _bindSamplerUniformToChannel;
  32255. private _getTextureWrapMode;
  32256. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32257. /**
  32258. * Sets an array of texture to the webGL context
  32259. * @param channel defines the channel where the texture array must be set
  32260. * @param uniform defines the associated uniform location
  32261. * @param textures defines the array of textures to bind
  32262. */
  32263. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32264. /** @hidden */
  32265. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32266. private _setTextureParameterFloat;
  32267. private _setTextureParameterInteger;
  32268. /**
  32269. * Unbind all vertex attributes from the webGL context
  32270. */
  32271. unbindAllAttributes(): void;
  32272. /**
  32273. * 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
  32274. */
  32275. releaseEffects(): void;
  32276. /**
  32277. * Dispose and release all associated resources
  32278. */
  32279. dispose(): void;
  32280. /**
  32281. * Attach a new callback raised when context lost event is fired
  32282. * @param callback defines the callback to call
  32283. */
  32284. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32285. /**
  32286. * Attach a new callback raised when context restored event is fired
  32287. * @param callback defines the callback to call
  32288. */
  32289. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32290. /**
  32291. * Get the current error code of the webGL context
  32292. * @returns the error code
  32293. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32294. */
  32295. getError(): number;
  32296. private _canRenderToFloatFramebuffer;
  32297. private _canRenderToHalfFloatFramebuffer;
  32298. private _canRenderToFramebuffer;
  32299. /** @hidden */
  32300. _getWebGLTextureType(type: number): number;
  32301. /** @hidden */
  32302. _getInternalFormat(format: number): number;
  32303. /** @hidden */
  32304. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32305. /** @hidden */
  32306. _getRGBAMultiSampleBufferFormat(type: number): number;
  32307. /** @hidden */
  32308. _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;
  32309. /**
  32310. * Loads a file from a url
  32311. * @param url url to load
  32312. * @param onSuccess callback called when the file successfully loads
  32313. * @param onProgress callback called while file is loading (if the server supports this mode)
  32314. * @param offlineProvider defines the offline provider for caching
  32315. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32316. * @param onError callback called when the file fails to load
  32317. * @returns a file request object
  32318. * @hidden
  32319. */
  32320. 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;
  32321. /**
  32322. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32323. * @param x defines the x coordinate of the rectangle where pixels must be read
  32324. * @param y defines the y coordinate of the rectangle where pixels must be read
  32325. * @param width defines the width of the rectangle where pixels must be read
  32326. * @param height defines the height of the rectangle where pixels must be read
  32327. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32328. * @returns a Uint8Array containing RGBA colors
  32329. */
  32330. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32331. private static _isSupported;
  32332. /**
  32333. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32334. * @returns true if the engine can be created
  32335. * @ignorenaming
  32336. */
  32337. static isSupported(): boolean;
  32338. /**
  32339. * Find the next highest power of two.
  32340. * @param x Number to start search from.
  32341. * @return Next highest power of two.
  32342. */
  32343. static CeilingPOT(x: number): number;
  32344. /**
  32345. * Find the next lowest power of two.
  32346. * @param x Number to start search from.
  32347. * @return Next lowest power of two.
  32348. */
  32349. static FloorPOT(x: number): number;
  32350. /**
  32351. * Find the nearest power of two.
  32352. * @param x Number to start search from.
  32353. * @return Next nearest power of two.
  32354. */
  32355. static NearestPOT(x: number): number;
  32356. /**
  32357. * Get the closest exponent of two
  32358. * @param value defines the value to approximate
  32359. * @param max defines the maximum value to return
  32360. * @param mode defines how to define the closest value
  32361. * @returns closest exponent of two of the given value
  32362. */
  32363. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32364. /**
  32365. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32366. * @param func - the function to be called
  32367. * @param requester - the object that will request the next frame. Falls back to window.
  32368. * @returns frame number
  32369. */
  32370. static QueueNewFrame(func: () => void, requester?: any): number;
  32371. /**
  32372. * Gets host document
  32373. * @returns the host document object
  32374. */
  32375. getHostDocument(): Nullable<Document>;
  32376. }
  32377. }
  32378. declare module BABYLON {
  32379. /**
  32380. * Class representing spherical harmonics coefficients to the 3rd degree
  32381. */
  32382. export class SphericalHarmonics {
  32383. /**
  32384. * Defines whether or not the harmonics have been prescaled for rendering.
  32385. */
  32386. preScaled: boolean;
  32387. /**
  32388. * The l0,0 coefficients of the spherical harmonics
  32389. */
  32390. l00: Vector3;
  32391. /**
  32392. * The l1,-1 coefficients of the spherical harmonics
  32393. */
  32394. l1_1: Vector3;
  32395. /**
  32396. * The l1,0 coefficients of the spherical harmonics
  32397. */
  32398. l10: Vector3;
  32399. /**
  32400. * The l1,1 coefficients of the spherical harmonics
  32401. */
  32402. l11: Vector3;
  32403. /**
  32404. * The l2,-2 coefficients of the spherical harmonics
  32405. */
  32406. l2_2: Vector3;
  32407. /**
  32408. * The l2,-1 coefficients of the spherical harmonics
  32409. */
  32410. l2_1: Vector3;
  32411. /**
  32412. * The l2,0 coefficients of the spherical harmonics
  32413. */
  32414. l20: Vector3;
  32415. /**
  32416. * The l2,1 coefficients of the spherical harmonics
  32417. */
  32418. l21: Vector3;
  32419. /**
  32420. * The l2,2 coefficients of the spherical harmonics
  32421. */
  32422. l22: Vector3;
  32423. /**
  32424. * Adds a light to the spherical harmonics
  32425. * @param direction the direction of the light
  32426. * @param color the color of the light
  32427. * @param deltaSolidAngle the delta solid angle of the light
  32428. */
  32429. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32430. /**
  32431. * Scales the spherical harmonics by the given amount
  32432. * @param scale the amount to scale
  32433. */
  32434. scaleInPlace(scale: number): void;
  32435. /**
  32436. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32437. *
  32438. * ```
  32439. * E_lm = A_l * L_lm
  32440. * ```
  32441. *
  32442. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32443. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32444. * the scaling factors are given in equation 9.
  32445. */
  32446. convertIncidentRadianceToIrradiance(): void;
  32447. /**
  32448. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32449. *
  32450. * ```
  32451. * L = (1/pi) * E * rho
  32452. * ```
  32453. *
  32454. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32455. */
  32456. convertIrradianceToLambertianRadiance(): void;
  32457. /**
  32458. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32459. * required operations at run time.
  32460. *
  32461. * This is simply done by scaling back the SH with Ylm constants parameter.
  32462. * The trigonometric part being applied by the shader at run time.
  32463. */
  32464. preScaleForRendering(): void;
  32465. /**
  32466. * Constructs a spherical harmonics from an array.
  32467. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32468. * @returns the spherical harmonics
  32469. */
  32470. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32471. /**
  32472. * Gets the spherical harmonics from polynomial
  32473. * @param polynomial the spherical polynomial
  32474. * @returns the spherical harmonics
  32475. */
  32476. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32477. }
  32478. /**
  32479. * Class representing spherical polynomial coefficients to the 3rd degree
  32480. */
  32481. export class SphericalPolynomial {
  32482. private _harmonics;
  32483. /**
  32484. * The spherical harmonics used to create the polynomials.
  32485. */
  32486. get preScaledHarmonics(): SphericalHarmonics;
  32487. /**
  32488. * The x coefficients of the spherical polynomial
  32489. */
  32490. x: Vector3;
  32491. /**
  32492. * The y coefficients of the spherical polynomial
  32493. */
  32494. y: Vector3;
  32495. /**
  32496. * The z coefficients of the spherical polynomial
  32497. */
  32498. z: Vector3;
  32499. /**
  32500. * The xx coefficients of the spherical polynomial
  32501. */
  32502. xx: Vector3;
  32503. /**
  32504. * The yy coefficients of the spherical polynomial
  32505. */
  32506. yy: Vector3;
  32507. /**
  32508. * The zz coefficients of the spherical polynomial
  32509. */
  32510. zz: Vector3;
  32511. /**
  32512. * The xy coefficients of the spherical polynomial
  32513. */
  32514. xy: Vector3;
  32515. /**
  32516. * The yz coefficients of the spherical polynomial
  32517. */
  32518. yz: Vector3;
  32519. /**
  32520. * The zx coefficients of the spherical polynomial
  32521. */
  32522. zx: Vector3;
  32523. /**
  32524. * Adds an ambient color to the spherical polynomial
  32525. * @param color the color to add
  32526. */
  32527. addAmbient(color: Color3): void;
  32528. /**
  32529. * Scales the spherical polynomial by the given amount
  32530. * @param scale the amount to scale
  32531. */
  32532. scaleInPlace(scale: number): void;
  32533. /**
  32534. * Gets the spherical polynomial from harmonics
  32535. * @param harmonics the spherical harmonics
  32536. * @returns the spherical polynomial
  32537. */
  32538. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32539. /**
  32540. * Constructs a spherical polynomial from an array.
  32541. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32542. * @returns the spherical polynomial
  32543. */
  32544. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32545. }
  32546. }
  32547. declare module BABYLON {
  32548. /**
  32549. * Defines the source of the internal texture
  32550. */
  32551. export enum InternalTextureSource {
  32552. /**
  32553. * The source of the texture data is unknown
  32554. */
  32555. Unknown = 0,
  32556. /**
  32557. * Texture data comes from an URL
  32558. */
  32559. Url = 1,
  32560. /**
  32561. * Texture data is only used for temporary storage
  32562. */
  32563. Temp = 2,
  32564. /**
  32565. * Texture data comes from raw data (ArrayBuffer)
  32566. */
  32567. Raw = 3,
  32568. /**
  32569. * Texture content is dynamic (video or dynamic texture)
  32570. */
  32571. Dynamic = 4,
  32572. /**
  32573. * Texture content is generated by rendering to it
  32574. */
  32575. RenderTarget = 5,
  32576. /**
  32577. * Texture content is part of a multi render target process
  32578. */
  32579. MultiRenderTarget = 6,
  32580. /**
  32581. * Texture data comes from a cube data file
  32582. */
  32583. Cube = 7,
  32584. /**
  32585. * Texture data comes from a raw cube data
  32586. */
  32587. CubeRaw = 8,
  32588. /**
  32589. * Texture data come from a prefiltered cube data file
  32590. */
  32591. CubePrefiltered = 9,
  32592. /**
  32593. * Texture content is raw 3D data
  32594. */
  32595. Raw3D = 10,
  32596. /**
  32597. * Texture content is raw 2D array data
  32598. */
  32599. Raw2DArray = 11,
  32600. /**
  32601. * Texture content is a depth texture
  32602. */
  32603. Depth = 12,
  32604. /**
  32605. * Texture data comes from a raw cube data encoded with RGBD
  32606. */
  32607. CubeRawRGBD = 13
  32608. }
  32609. /**
  32610. * Class used to store data associated with WebGL texture data for the engine
  32611. * This class should not be used directly
  32612. */
  32613. export class InternalTexture {
  32614. /** @hidden */
  32615. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32616. /**
  32617. * Defines if the texture is ready
  32618. */
  32619. isReady: boolean;
  32620. /**
  32621. * Defines if the texture is a cube texture
  32622. */
  32623. isCube: boolean;
  32624. /**
  32625. * Defines if the texture contains 3D data
  32626. */
  32627. is3D: boolean;
  32628. /**
  32629. * Defines if the texture contains 2D array data
  32630. */
  32631. is2DArray: boolean;
  32632. /**
  32633. * Defines if the texture contains multiview data
  32634. */
  32635. isMultiview: boolean;
  32636. /**
  32637. * Gets the URL used to load this texture
  32638. */
  32639. url: string;
  32640. /**
  32641. * Gets the sampling mode of the texture
  32642. */
  32643. samplingMode: number;
  32644. /**
  32645. * Gets a boolean indicating if the texture needs mipmaps generation
  32646. */
  32647. generateMipMaps: boolean;
  32648. /**
  32649. * Gets the number of samples used by the texture (WebGL2+ only)
  32650. */
  32651. samples: number;
  32652. /**
  32653. * Gets the type of the texture (int, float...)
  32654. */
  32655. type: number;
  32656. /**
  32657. * Gets the format of the texture (RGB, RGBA...)
  32658. */
  32659. format: number;
  32660. /**
  32661. * Observable called when the texture is loaded
  32662. */
  32663. onLoadedObservable: Observable<InternalTexture>;
  32664. /**
  32665. * Gets the width of the texture
  32666. */
  32667. width: number;
  32668. /**
  32669. * Gets the height of the texture
  32670. */
  32671. height: number;
  32672. /**
  32673. * Gets the depth of the texture
  32674. */
  32675. depth: number;
  32676. /**
  32677. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32678. */
  32679. baseWidth: number;
  32680. /**
  32681. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32682. */
  32683. baseHeight: number;
  32684. /**
  32685. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32686. */
  32687. baseDepth: number;
  32688. /**
  32689. * Gets a boolean indicating if the texture is inverted on Y axis
  32690. */
  32691. invertY: boolean;
  32692. /** @hidden */
  32693. _invertVScale: boolean;
  32694. /** @hidden */
  32695. _associatedChannel: number;
  32696. /** @hidden */
  32697. _source: InternalTextureSource;
  32698. /** @hidden */
  32699. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32700. /** @hidden */
  32701. _bufferView: Nullable<ArrayBufferView>;
  32702. /** @hidden */
  32703. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32704. /** @hidden */
  32705. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32706. /** @hidden */
  32707. _size: number;
  32708. /** @hidden */
  32709. _extension: string;
  32710. /** @hidden */
  32711. _files: Nullable<string[]>;
  32712. /** @hidden */
  32713. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32714. /** @hidden */
  32715. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32716. /** @hidden */
  32717. _framebuffer: Nullable<WebGLFramebuffer>;
  32718. /** @hidden */
  32719. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32720. /** @hidden */
  32721. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32722. /** @hidden */
  32723. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32724. /** @hidden */
  32725. _attachments: Nullable<number[]>;
  32726. /** @hidden */
  32727. _cachedCoordinatesMode: Nullable<number>;
  32728. /** @hidden */
  32729. _cachedWrapU: Nullable<number>;
  32730. /** @hidden */
  32731. _cachedWrapV: Nullable<number>;
  32732. /** @hidden */
  32733. _cachedWrapR: Nullable<number>;
  32734. /** @hidden */
  32735. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32736. /** @hidden */
  32737. _isDisabled: boolean;
  32738. /** @hidden */
  32739. _compression: Nullable<string>;
  32740. /** @hidden */
  32741. _generateStencilBuffer: boolean;
  32742. /** @hidden */
  32743. _generateDepthBuffer: boolean;
  32744. /** @hidden */
  32745. _comparisonFunction: number;
  32746. /** @hidden */
  32747. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32748. /** @hidden */
  32749. _lodGenerationScale: number;
  32750. /** @hidden */
  32751. _lodGenerationOffset: number;
  32752. /** @hidden */
  32753. _depthStencilTexture: Nullable<InternalTexture>;
  32754. /** @hidden */
  32755. _colorTextureArray: Nullable<WebGLTexture>;
  32756. /** @hidden */
  32757. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32758. /** @hidden */
  32759. _lodTextureHigh: Nullable<BaseTexture>;
  32760. /** @hidden */
  32761. _lodTextureMid: Nullable<BaseTexture>;
  32762. /** @hidden */
  32763. _lodTextureLow: Nullable<BaseTexture>;
  32764. /** @hidden */
  32765. _isRGBD: boolean;
  32766. /** @hidden */
  32767. _linearSpecularLOD: boolean;
  32768. /** @hidden */
  32769. _irradianceTexture: Nullable<BaseTexture>;
  32770. /** @hidden */
  32771. _webGLTexture: Nullable<WebGLTexture>;
  32772. /** @hidden */
  32773. _references: number;
  32774. private _engine;
  32775. /**
  32776. * Gets the Engine the texture belongs to.
  32777. * @returns The babylon engine
  32778. */
  32779. getEngine(): ThinEngine;
  32780. /**
  32781. * Gets the data source type of the texture
  32782. */
  32783. get source(): InternalTextureSource;
  32784. /**
  32785. * Creates a new InternalTexture
  32786. * @param engine defines the engine to use
  32787. * @param source defines the type of data that will be used
  32788. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32789. */
  32790. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32791. /**
  32792. * Increments the number of references (ie. the number of Texture that point to it)
  32793. */
  32794. incrementReferences(): void;
  32795. /**
  32796. * Change the size of the texture (not the size of the content)
  32797. * @param width defines the new width
  32798. * @param height defines the new height
  32799. * @param depth defines the new depth (1 by default)
  32800. */
  32801. updateSize(width: int, height: int, depth?: int): void;
  32802. /** @hidden */
  32803. _rebuild(): void;
  32804. /** @hidden */
  32805. _swapAndDie(target: InternalTexture): void;
  32806. /**
  32807. * Dispose the current allocated resources
  32808. */
  32809. dispose(): void;
  32810. }
  32811. }
  32812. declare module BABYLON {
  32813. /**
  32814. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32816. */
  32817. export class Analyser {
  32818. /**
  32819. * Gets or sets the smoothing
  32820. * @ignorenaming
  32821. */
  32822. SMOOTHING: number;
  32823. /**
  32824. * Gets or sets the FFT table size
  32825. * @ignorenaming
  32826. */
  32827. FFT_SIZE: number;
  32828. /**
  32829. * Gets or sets the bar graph amplitude
  32830. * @ignorenaming
  32831. */
  32832. BARGRAPHAMPLITUDE: number;
  32833. /**
  32834. * Gets or sets the position of the debug canvas
  32835. * @ignorenaming
  32836. */
  32837. DEBUGCANVASPOS: {
  32838. x: number;
  32839. y: number;
  32840. };
  32841. /**
  32842. * Gets or sets the debug canvas size
  32843. * @ignorenaming
  32844. */
  32845. DEBUGCANVASSIZE: {
  32846. width: number;
  32847. height: number;
  32848. };
  32849. private _byteFreqs;
  32850. private _byteTime;
  32851. private _floatFreqs;
  32852. private _webAudioAnalyser;
  32853. private _debugCanvas;
  32854. private _debugCanvasContext;
  32855. private _scene;
  32856. private _registerFunc;
  32857. private _audioEngine;
  32858. /**
  32859. * Creates a new analyser
  32860. * @param scene defines hosting scene
  32861. */
  32862. constructor(scene: Scene);
  32863. /**
  32864. * Get the number of data values you will have to play with for the visualization
  32865. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32866. * @returns a number
  32867. */
  32868. getFrequencyBinCount(): number;
  32869. /**
  32870. * Gets the current frequency data as a byte array
  32871. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32872. * @returns a Uint8Array
  32873. */
  32874. getByteFrequencyData(): Uint8Array;
  32875. /**
  32876. * Gets the current waveform as a byte array
  32877. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32878. * @returns a Uint8Array
  32879. */
  32880. getByteTimeDomainData(): Uint8Array;
  32881. /**
  32882. * Gets the current frequency data as a float array
  32883. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32884. * @returns a Float32Array
  32885. */
  32886. getFloatFrequencyData(): Float32Array;
  32887. /**
  32888. * Renders the debug canvas
  32889. */
  32890. drawDebugCanvas(): void;
  32891. /**
  32892. * Stops rendering the debug canvas and removes it
  32893. */
  32894. stopDebugCanvas(): void;
  32895. /**
  32896. * Connects two audio nodes
  32897. * @param inputAudioNode defines first node to connect
  32898. * @param outputAudioNode defines second node to connect
  32899. */
  32900. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32901. /**
  32902. * Releases all associated resources
  32903. */
  32904. dispose(): void;
  32905. }
  32906. }
  32907. declare module BABYLON {
  32908. /**
  32909. * This represents an audio engine and it is responsible
  32910. * to play, synchronize and analyse sounds throughout the application.
  32911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32912. */
  32913. export interface IAudioEngine extends IDisposable {
  32914. /**
  32915. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32916. */
  32917. readonly canUseWebAudio: boolean;
  32918. /**
  32919. * Gets the current AudioContext if available.
  32920. */
  32921. readonly audioContext: Nullable<AudioContext>;
  32922. /**
  32923. * The master gain node defines the global audio volume of your audio engine.
  32924. */
  32925. readonly masterGain: GainNode;
  32926. /**
  32927. * Gets whether or not mp3 are supported by your browser.
  32928. */
  32929. readonly isMP3supported: boolean;
  32930. /**
  32931. * Gets whether or not ogg are supported by your browser.
  32932. */
  32933. readonly isOGGsupported: boolean;
  32934. /**
  32935. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32936. * @ignoreNaming
  32937. */
  32938. WarnedWebAudioUnsupported: boolean;
  32939. /**
  32940. * Defines if the audio engine relies on a custom unlocked button.
  32941. * In this case, the embedded button will not be displayed.
  32942. */
  32943. useCustomUnlockedButton: boolean;
  32944. /**
  32945. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32946. */
  32947. readonly unlocked: boolean;
  32948. /**
  32949. * Event raised when audio has been unlocked on the browser.
  32950. */
  32951. onAudioUnlockedObservable: Observable<AudioEngine>;
  32952. /**
  32953. * Event raised when audio has been locked on the browser.
  32954. */
  32955. onAudioLockedObservable: Observable<AudioEngine>;
  32956. /**
  32957. * Flags the audio engine in Locked state.
  32958. * This happens due to new browser policies preventing audio to autoplay.
  32959. */
  32960. lock(): void;
  32961. /**
  32962. * Unlocks the audio engine once a user action has been done on the dom.
  32963. * This is helpful to resume play once browser policies have been satisfied.
  32964. */
  32965. unlock(): void;
  32966. /**
  32967. * Gets the global volume sets on the master gain.
  32968. * @returns the global volume if set or -1 otherwise
  32969. */
  32970. getGlobalVolume(): number;
  32971. /**
  32972. * Sets the global volume of your experience (sets on the master gain).
  32973. * @param newVolume Defines the new global volume of the application
  32974. */
  32975. setGlobalVolume(newVolume: number): void;
  32976. /**
  32977. * Connect the audio engine to an audio analyser allowing some amazing
  32978. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32980. * @param analyser The analyser to connect to the engine
  32981. */
  32982. connectToAnalyser(analyser: Analyser): void;
  32983. }
  32984. /**
  32985. * This represents the default audio engine used in babylon.
  32986. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32988. */
  32989. export class AudioEngine implements IAudioEngine {
  32990. private _audioContext;
  32991. private _audioContextInitialized;
  32992. private _muteButton;
  32993. private _hostElement;
  32994. /**
  32995. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32996. */
  32997. canUseWebAudio: boolean;
  32998. /**
  32999. * The master gain node defines the global audio volume of your audio engine.
  33000. */
  33001. masterGain: GainNode;
  33002. /**
  33003. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33004. * @ignoreNaming
  33005. */
  33006. WarnedWebAudioUnsupported: boolean;
  33007. /**
  33008. * Gets whether or not mp3 are supported by your browser.
  33009. */
  33010. isMP3supported: boolean;
  33011. /**
  33012. * Gets whether or not ogg are supported by your browser.
  33013. */
  33014. isOGGsupported: boolean;
  33015. /**
  33016. * Gets whether audio has been unlocked on the device.
  33017. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33018. * a user interaction has happened.
  33019. */
  33020. unlocked: boolean;
  33021. /**
  33022. * Defines if the audio engine relies on a custom unlocked button.
  33023. * In this case, the embedded button will not be displayed.
  33024. */
  33025. useCustomUnlockedButton: boolean;
  33026. /**
  33027. * Event raised when audio has been unlocked on the browser.
  33028. */
  33029. onAudioUnlockedObservable: Observable<AudioEngine>;
  33030. /**
  33031. * Event raised when audio has been locked on the browser.
  33032. */
  33033. onAudioLockedObservable: Observable<AudioEngine>;
  33034. /**
  33035. * Gets the current AudioContext if available.
  33036. */
  33037. get audioContext(): Nullable<AudioContext>;
  33038. private _connectedAnalyser;
  33039. /**
  33040. * Instantiates a new audio engine.
  33041. *
  33042. * There should be only one per page as some browsers restrict the number
  33043. * of audio contexts you can create.
  33044. * @param hostElement defines the host element where to display the mute icon if necessary
  33045. */
  33046. constructor(hostElement?: Nullable<HTMLElement>);
  33047. /**
  33048. * Flags the audio engine in Locked state.
  33049. * This happens due to new browser policies preventing audio to autoplay.
  33050. */
  33051. lock(): void;
  33052. /**
  33053. * Unlocks the audio engine once a user action has been done on the dom.
  33054. * This is helpful to resume play once browser policies have been satisfied.
  33055. */
  33056. unlock(): void;
  33057. private _resumeAudioContext;
  33058. private _initializeAudioContext;
  33059. private _tryToRun;
  33060. private _triggerRunningState;
  33061. private _triggerSuspendedState;
  33062. private _displayMuteButton;
  33063. private _moveButtonToTopLeft;
  33064. private _onResize;
  33065. private _hideMuteButton;
  33066. /**
  33067. * Destroy and release the resources associated with the audio ccontext.
  33068. */
  33069. dispose(): void;
  33070. /**
  33071. * Gets the global volume sets on the master gain.
  33072. * @returns the global volume if set or -1 otherwise
  33073. */
  33074. getGlobalVolume(): number;
  33075. /**
  33076. * Sets the global volume of your experience (sets on the master gain).
  33077. * @param newVolume Defines the new global volume of the application
  33078. */
  33079. setGlobalVolume(newVolume: number): void;
  33080. /**
  33081. * Connect the audio engine to an audio analyser allowing some amazing
  33082. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33084. * @param analyser The analyser to connect to the engine
  33085. */
  33086. connectToAnalyser(analyser: Analyser): void;
  33087. }
  33088. }
  33089. declare module BABYLON {
  33090. /**
  33091. * Interface used to present a loading screen while loading a scene
  33092. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33093. */
  33094. export interface ILoadingScreen {
  33095. /**
  33096. * Function called to display the loading screen
  33097. */
  33098. displayLoadingUI: () => void;
  33099. /**
  33100. * Function called to hide the loading screen
  33101. */
  33102. hideLoadingUI: () => void;
  33103. /**
  33104. * Gets or sets the color to use for the background
  33105. */
  33106. loadingUIBackgroundColor: string;
  33107. /**
  33108. * Gets or sets the text to display while loading
  33109. */
  33110. loadingUIText: string;
  33111. }
  33112. /**
  33113. * Class used for the default loading screen
  33114. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33115. */
  33116. export class DefaultLoadingScreen implements ILoadingScreen {
  33117. private _renderingCanvas;
  33118. private _loadingText;
  33119. private _loadingDivBackgroundColor;
  33120. private _loadingDiv;
  33121. private _loadingTextDiv;
  33122. /** Gets or sets the logo url to use for the default loading screen */
  33123. static DefaultLogoUrl: string;
  33124. /** Gets or sets the spinner url to use for the default loading screen */
  33125. static DefaultSpinnerUrl: string;
  33126. /**
  33127. * Creates a new default loading screen
  33128. * @param _renderingCanvas defines the canvas used to render the scene
  33129. * @param _loadingText defines the default text to display
  33130. * @param _loadingDivBackgroundColor defines the default background color
  33131. */
  33132. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33133. /**
  33134. * Function called to display the loading screen
  33135. */
  33136. displayLoadingUI(): void;
  33137. /**
  33138. * Function called to hide the loading screen
  33139. */
  33140. hideLoadingUI(): void;
  33141. /**
  33142. * Gets or sets the text to display while loading
  33143. */
  33144. set loadingUIText(text: string);
  33145. get loadingUIText(): string;
  33146. /**
  33147. * Gets or sets the color to use for the background
  33148. */
  33149. get loadingUIBackgroundColor(): string;
  33150. set loadingUIBackgroundColor(color: string);
  33151. private _resizeLoadingUI;
  33152. }
  33153. }
  33154. declare module BABYLON {
  33155. /**
  33156. * Interface for any object that can request an animation frame
  33157. */
  33158. export interface ICustomAnimationFrameRequester {
  33159. /**
  33160. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33161. */
  33162. renderFunction?: Function;
  33163. /**
  33164. * Called to request the next frame to render to
  33165. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33166. */
  33167. requestAnimationFrame: Function;
  33168. /**
  33169. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33170. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33171. */
  33172. requestID?: number;
  33173. }
  33174. }
  33175. declare module BABYLON {
  33176. /**
  33177. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33178. */
  33179. export class PerformanceMonitor {
  33180. private _enabled;
  33181. private _rollingFrameTime;
  33182. private _lastFrameTimeMs;
  33183. /**
  33184. * constructor
  33185. * @param frameSampleSize The number of samples required to saturate the sliding window
  33186. */
  33187. constructor(frameSampleSize?: number);
  33188. /**
  33189. * Samples current frame
  33190. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33191. */
  33192. sampleFrame(timeMs?: number): void;
  33193. /**
  33194. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33195. */
  33196. get averageFrameTime(): number;
  33197. /**
  33198. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33199. */
  33200. get averageFrameTimeVariance(): number;
  33201. /**
  33202. * Returns the frame time of the most recent frame
  33203. */
  33204. get instantaneousFrameTime(): number;
  33205. /**
  33206. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33207. */
  33208. get averageFPS(): number;
  33209. /**
  33210. * Returns the average framerate in frames per second using the most recent frame time
  33211. */
  33212. get instantaneousFPS(): number;
  33213. /**
  33214. * Returns true if enough samples have been taken to completely fill the sliding window
  33215. */
  33216. get isSaturated(): boolean;
  33217. /**
  33218. * Enables contributions to the sliding window sample set
  33219. */
  33220. enable(): void;
  33221. /**
  33222. * Disables contributions to the sliding window sample set
  33223. * Samples will not be interpolated over the disabled period
  33224. */
  33225. disable(): void;
  33226. /**
  33227. * Returns true if sampling is enabled
  33228. */
  33229. get isEnabled(): boolean;
  33230. /**
  33231. * Resets performance monitor
  33232. */
  33233. reset(): void;
  33234. }
  33235. /**
  33236. * RollingAverage
  33237. *
  33238. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33239. */
  33240. export class RollingAverage {
  33241. /**
  33242. * Current average
  33243. */
  33244. average: number;
  33245. /**
  33246. * Current variance
  33247. */
  33248. variance: number;
  33249. protected _samples: Array<number>;
  33250. protected _sampleCount: number;
  33251. protected _pos: number;
  33252. protected _m2: number;
  33253. /**
  33254. * constructor
  33255. * @param length The number of samples required to saturate the sliding window
  33256. */
  33257. constructor(length: number);
  33258. /**
  33259. * Adds a sample to the sample set
  33260. * @param v The sample value
  33261. */
  33262. add(v: number): void;
  33263. /**
  33264. * Returns previously added values or null if outside of history or outside the sliding window domain
  33265. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33266. * @return Value previously recorded with add() or null if outside of range
  33267. */
  33268. history(i: number): number;
  33269. /**
  33270. * Returns true if enough samples have been taken to completely fill the sliding window
  33271. * @return true if sample-set saturated
  33272. */
  33273. isSaturated(): boolean;
  33274. /**
  33275. * Resets the rolling average (equivalent to 0 samples taken so far)
  33276. */
  33277. reset(): void;
  33278. /**
  33279. * Wraps a value around the sample range boundaries
  33280. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33281. * @return Wrapped position in sample range
  33282. */
  33283. protected _wrapPosition(i: number): number;
  33284. }
  33285. }
  33286. declare module BABYLON {
  33287. /**
  33288. * This class is used to track a performance counter which is number based.
  33289. * The user has access to many properties which give statistics of different nature.
  33290. *
  33291. * The implementer can track two kinds of Performance Counter: time and count.
  33292. * 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.
  33293. * 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.
  33294. */
  33295. export class PerfCounter {
  33296. /**
  33297. * Gets or sets a global boolean to turn on and off all the counters
  33298. */
  33299. static Enabled: boolean;
  33300. /**
  33301. * Returns the smallest value ever
  33302. */
  33303. get min(): number;
  33304. /**
  33305. * Returns the biggest value ever
  33306. */
  33307. get max(): number;
  33308. /**
  33309. * Returns the average value since the performance counter is running
  33310. */
  33311. get average(): number;
  33312. /**
  33313. * Returns the average value of the last second the counter was monitored
  33314. */
  33315. get lastSecAverage(): number;
  33316. /**
  33317. * Returns the current value
  33318. */
  33319. get current(): number;
  33320. /**
  33321. * Gets the accumulated total
  33322. */
  33323. get total(): number;
  33324. /**
  33325. * Gets the total value count
  33326. */
  33327. get count(): number;
  33328. /**
  33329. * Creates a new counter
  33330. */
  33331. constructor();
  33332. /**
  33333. * Call this method to start monitoring a new frame.
  33334. * 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.
  33335. */
  33336. fetchNewFrame(): void;
  33337. /**
  33338. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33339. * @param newCount the count value to add to the monitored count
  33340. * @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.
  33341. */
  33342. addCount(newCount: number, fetchResult: boolean): void;
  33343. /**
  33344. * Start monitoring this performance counter
  33345. */
  33346. beginMonitoring(): void;
  33347. /**
  33348. * Compute the time lapsed since the previous beginMonitoring() call.
  33349. * @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
  33350. */
  33351. endMonitoring(newFrame?: boolean): void;
  33352. private _fetchResult;
  33353. private _startMonitoringTime;
  33354. private _min;
  33355. private _max;
  33356. private _average;
  33357. private _current;
  33358. private _totalValueCount;
  33359. private _totalAccumulated;
  33360. private _lastSecAverage;
  33361. private _lastSecAccumulated;
  33362. private _lastSecTime;
  33363. private _lastSecValueCount;
  33364. }
  33365. }
  33366. declare module BABYLON {
  33367. interface ThinEngine {
  33368. /**
  33369. * Sets alpha constants used by some alpha blending modes
  33370. * @param r defines the red component
  33371. * @param g defines the green component
  33372. * @param b defines the blue component
  33373. * @param a defines the alpha component
  33374. */
  33375. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33376. /**
  33377. * Sets the current alpha mode
  33378. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33379. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33380. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33381. */
  33382. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33383. /**
  33384. * Gets the current alpha mode
  33385. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33386. * @returns the current alpha mode
  33387. */
  33388. getAlphaMode(): number;
  33389. /**
  33390. * Sets the current alpha equation
  33391. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33392. */
  33393. setAlphaEquation(equation: number): void;
  33394. /**
  33395. * Gets the current alpha equation.
  33396. * @returns the current alpha equation
  33397. */
  33398. getAlphaEquation(): number;
  33399. }
  33400. }
  33401. declare module BABYLON {
  33402. /**
  33403. * Defines the interface used by display changed events
  33404. */
  33405. export interface IDisplayChangedEventArgs {
  33406. /** Gets the vrDisplay object (if any) */
  33407. vrDisplay: Nullable<any>;
  33408. /** Gets a boolean indicating if webVR is supported */
  33409. vrSupported: boolean;
  33410. }
  33411. /**
  33412. * Defines the interface used by objects containing a viewport (like a camera)
  33413. */
  33414. interface IViewportOwnerLike {
  33415. /**
  33416. * Gets or sets the viewport
  33417. */
  33418. viewport: IViewportLike;
  33419. }
  33420. /**
  33421. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33422. */
  33423. export class Engine extends ThinEngine {
  33424. /** Defines that alpha blending is disabled */
  33425. static readonly ALPHA_DISABLE: number;
  33426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33427. static readonly ALPHA_ADD: number;
  33428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33429. static readonly ALPHA_COMBINE: number;
  33430. /** Defines that alpha blending to DEST - SRC * DEST */
  33431. static readonly ALPHA_SUBTRACT: number;
  33432. /** Defines that alpha blending to SRC * DEST */
  33433. static readonly ALPHA_MULTIPLY: number;
  33434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33435. static readonly ALPHA_MAXIMIZED: number;
  33436. /** Defines that alpha blending to SRC + DEST */
  33437. static readonly ALPHA_ONEONE: number;
  33438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33439. static readonly ALPHA_PREMULTIPLIED: number;
  33440. /**
  33441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33443. */
  33444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33446. static readonly ALPHA_INTERPOLATE: number;
  33447. /**
  33448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33450. */
  33451. static readonly ALPHA_SCREENMODE: number;
  33452. /** Defines that the ressource is not delayed*/
  33453. static readonly DELAYLOADSTATE_NONE: number;
  33454. /** Defines that the ressource was successfully delay loaded */
  33455. static readonly DELAYLOADSTATE_LOADED: number;
  33456. /** Defines that the ressource is currently delay loading */
  33457. static readonly DELAYLOADSTATE_LOADING: number;
  33458. /** Defines that the ressource is delayed and has not started loading */
  33459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33461. static readonly NEVER: number;
  33462. /** 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 */
  33463. static readonly ALWAYS: number;
  33464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33465. static readonly LESS: number;
  33466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33467. static readonly EQUAL: number;
  33468. /** 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 */
  33469. static readonly LEQUAL: number;
  33470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33471. static readonly GREATER: number;
  33472. /** 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 */
  33473. static readonly GEQUAL: number;
  33474. /** 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 */
  33475. static readonly NOTEQUAL: number;
  33476. /** Passed to stencilOperation to specify that stencil value must be kept */
  33477. static readonly KEEP: number;
  33478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33479. static readonly REPLACE: number;
  33480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33481. static readonly INCR: number;
  33482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33483. static readonly DECR: number;
  33484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33485. static readonly INVERT: number;
  33486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33487. static readonly INCR_WRAP: number;
  33488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33489. static readonly DECR_WRAP: number;
  33490. /** Texture is not repeating outside of 0..1 UVs */
  33491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33492. /** Texture is repeating outside of 0..1 UVs */
  33493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33494. /** Texture is repeating and mirrored */
  33495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33496. /** ALPHA */
  33497. static readonly TEXTUREFORMAT_ALPHA: number;
  33498. /** LUMINANCE */
  33499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33500. /** LUMINANCE_ALPHA */
  33501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33502. /** RGB */
  33503. static readonly TEXTUREFORMAT_RGB: number;
  33504. /** RGBA */
  33505. static readonly TEXTUREFORMAT_RGBA: number;
  33506. /** RED */
  33507. static readonly TEXTUREFORMAT_RED: number;
  33508. /** RED (2nd reference) */
  33509. static readonly TEXTUREFORMAT_R: number;
  33510. /** RG */
  33511. static readonly TEXTUREFORMAT_RG: number;
  33512. /** RED_INTEGER */
  33513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33514. /** RED_INTEGER (2nd reference) */
  33515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33516. /** RG_INTEGER */
  33517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33518. /** RGB_INTEGER */
  33519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33520. /** RGBA_INTEGER */
  33521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33522. /** UNSIGNED_BYTE */
  33523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33524. /** UNSIGNED_BYTE (2nd reference) */
  33525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33526. /** FLOAT */
  33527. static readonly TEXTURETYPE_FLOAT: number;
  33528. /** HALF_FLOAT */
  33529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33530. /** BYTE */
  33531. static readonly TEXTURETYPE_BYTE: number;
  33532. /** SHORT */
  33533. static readonly TEXTURETYPE_SHORT: number;
  33534. /** UNSIGNED_SHORT */
  33535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33536. /** INT */
  33537. static readonly TEXTURETYPE_INT: number;
  33538. /** UNSIGNED_INT */
  33539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33540. /** UNSIGNED_SHORT_4_4_4_4 */
  33541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33542. /** UNSIGNED_SHORT_5_5_5_1 */
  33543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33544. /** UNSIGNED_SHORT_5_6_5 */
  33545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33546. /** UNSIGNED_INT_2_10_10_10_REV */
  33547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33548. /** UNSIGNED_INT_24_8 */
  33549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33550. /** UNSIGNED_INT_10F_11F_11F_REV */
  33551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33552. /** UNSIGNED_INT_5_9_9_9_REV */
  33553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33556. /** nearest is mag = nearest and min = nearest and mip = linear */
  33557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33560. /** Trilinear is mag = linear and min = linear and mip = linear */
  33561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33562. /** nearest is mag = nearest and min = nearest and mip = linear */
  33563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33566. /** Trilinear is mag = linear and min = linear and mip = linear */
  33567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33568. /** mag = nearest and min = nearest and mip = nearest */
  33569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33570. /** mag = nearest and min = linear and mip = nearest */
  33571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33572. /** mag = nearest and min = linear and mip = linear */
  33573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33574. /** mag = nearest and min = linear and mip = none */
  33575. static readonly TEXTURE_NEAREST_LINEAR: number;
  33576. /** mag = nearest and min = nearest and mip = none */
  33577. static readonly TEXTURE_NEAREST_NEAREST: number;
  33578. /** mag = linear and min = nearest and mip = nearest */
  33579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33580. /** mag = linear and min = nearest and mip = linear */
  33581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33582. /** mag = linear and min = linear and mip = none */
  33583. static readonly TEXTURE_LINEAR_LINEAR: number;
  33584. /** mag = linear and min = nearest and mip = none */
  33585. static readonly TEXTURE_LINEAR_NEAREST: number;
  33586. /** Explicit coordinates mode */
  33587. static readonly TEXTURE_EXPLICIT_MODE: number;
  33588. /** Spherical coordinates mode */
  33589. static readonly TEXTURE_SPHERICAL_MODE: number;
  33590. /** Planar coordinates mode */
  33591. static readonly TEXTURE_PLANAR_MODE: number;
  33592. /** Cubic coordinates mode */
  33593. static readonly TEXTURE_CUBIC_MODE: number;
  33594. /** Projection coordinates mode */
  33595. static readonly TEXTURE_PROJECTION_MODE: number;
  33596. /** Skybox coordinates mode */
  33597. static readonly TEXTURE_SKYBOX_MODE: number;
  33598. /** Inverse Cubic coordinates mode */
  33599. static readonly TEXTURE_INVCUBIC_MODE: number;
  33600. /** Equirectangular coordinates mode */
  33601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33602. /** Equirectangular Fixed coordinates mode */
  33603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33604. /** Equirectangular Fixed Mirrored coordinates mode */
  33605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33607. static readonly SCALEMODE_FLOOR: number;
  33608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33609. static readonly SCALEMODE_NEAREST: number;
  33610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33611. static readonly SCALEMODE_CEILING: number;
  33612. /**
  33613. * Returns the current npm package of the sdk
  33614. */
  33615. static get NpmPackage(): string;
  33616. /**
  33617. * Returns the current version of the framework
  33618. */
  33619. static get Version(): string;
  33620. /** Gets the list of created engines */
  33621. static get Instances(): Engine[];
  33622. /**
  33623. * Gets the latest created engine
  33624. */
  33625. static get LastCreatedEngine(): Nullable<Engine>;
  33626. /**
  33627. * Gets the latest created scene
  33628. */
  33629. static get LastCreatedScene(): Nullable<Scene>;
  33630. /**
  33631. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33632. * @param flag defines which part of the materials must be marked as dirty
  33633. * @param predicate defines a predicate used to filter which materials should be affected
  33634. */
  33635. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33636. /**
  33637. * Method called to create the default loading screen.
  33638. * This can be overriden in your own app.
  33639. * @param canvas The rendering canvas element
  33640. * @returns The loading screen
  33641. */
  33642. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33643. /**
  33644. * Method called to create the default rescale post process on each engine.
  33645. */
  33646. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33647. /**
  33648. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33649. **/
  33650. enableOfflineSupport: boolean;
  33651. /**
  33652. * 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)
  33653. **/
  33654. disableManifestCheck: boolean;
  33655. /**
  33656. * Gets the list of created scenes
  33657. */
  33658. scenes: Scene[];
  33659. /**
  33660. * Event raised when a new scene is created
  33661. */
  33662. onNewSceneAddedObservable: Observable<Scene>;
  33663. /**
  33664. * Gets the list of created postprocesses
  33665. */
  33666. postProcesses: PostProcess[];
  33667. /**
  33668. * Gets a boolean indicating if the pointer is currently locked
  33669. */
  33670. isPointerLock: boolean;
  33671. /**
  33672. * Observable event triggered each time the rendering canvas is resized
  33673. */
  33674. onResizeObservable: Observable<Engine>;
  33675. /**
  33676. * Observable event triggered each time the canvas loses focus
  33677. */
  33678. onCanvasBlurObservable: Observable<Engine>;
  33679. /**
  33680. * Observable event triggered each time the canvas gains focus
  33681. */
  33682. onCanvasFocusObservable: Observable<Engine>;
  33683. /**
  33684. * Observable event triggered each time the canvas receives pointerout event
  33685. */
  33686. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33687. /**
  33688. * Observable raised when the engine begins a new frame
  33689. */
  33690. onBeginFrameObservable: Observable<Engine>;
  33691. /**
  33692. * If set, will be used to request the next animation frame for the render loop
  33693. */
  33694. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33695. /**
  33696. * Observable raised when the engine ends the current frame
  33697. */
  33698. onEndFrameObservable: Observable<Engine>;
  33699. /**
  33700. * Observable raised when the engine is about to compile a shader
  33701. */
  33702. onBeforeShaderCompilationObservable: Observable<Engine>;
  33703. /**
  33704. * Observable raised when the engine has jsut compiled a shader
  33705. */
  33706. onAfterShaderCompilationObservable: Observable<Engine>;
  33707. /**
  33708. * Gets the audio engine
  33709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33710. * @ignorenaming
  33711. */
  33712. static audioEngine: IAudioEngine;
  33713. /**
  33714. * Default AudioEngine factory responsible of creating the Audio Engine.
  33715. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33716. */
  33717. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33718. /**
  33719. * Default offline support factory responsible of creating a tool used to store data locally.
  33720. * By default, this will create a Database object if the workload has been embedded.
  33721. */
  33722. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33723. private _loadingScreen;
  33724. private _pointerLockRequested;
  33725. private _dummyFramebuffer;
  33726. private _rescalePostProcess;
  33727. private _deterministicLockstep;
  33728. private _lockstepMaxSteps;
  33729. private _timeStep;
  33730. protected get _supportsHardwareTextureRescaling(): boolean;
  33731. private _fps;
  33732. private _deltaTime;
  33733. /** @hidden */
  33734. _drawCalls: PerfCounter;
  33735. /** 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 */
  33736. canvasTabIndex: number;
  33737. /**
  33738. * Turn this value on if you want to pause FPS computation when in background
  33739. */
  33740. disablePerformanceMonitorInBackground: boolean;
  33741. private _performanceMonitor;
  33742. /**
  33743. * Gets the performance monitor attached to this engine
  33744. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33745. */
  33746. get performanceMonitor(): PerformanceMonitor;
  33747. private _onFocus;
  33748. private _onBlur;
  33749. private _onCanvasPointerOut;
  33750. private _onCanvasBlur;
  33751. private _onCanvasFocus;
  33752. private _onFullscreenChange;
  33753. private _onPointerLockChange;
  33754. /**
  33755. * Gets the HTML element used to attach event listeners
  33756. * @returns a HTML element
  33757. */
  33758. getInputElement(): Nullable<HTMLElement>;
  33759. /**
  33760. * Creates a new engine
  33761. * @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
  33762. * @param antialias defines enable antialiasing (default: false)
  33763. * @param options defines further options to be sent to the getContext() function
  33764. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33765. */
  33766. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33767. /**
  33768. * Gets current aspect ratio
  33769. * @param viewportOwner defines the camera to use to get the aspect ratio
  33770. * @param useScreen defines if screen size must be used (or the current render target if any)
  33771. * @returns a number defining the aspect ratio
  33772. */
  33773. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33774. /**
  33775. * Gets current screen aspect ratio
  33776. * @returns a number defining the aspect ratio
  33777. */
  33778. getScreenAspectRatio(): number;
  33779. /**
  33780. * Gets the client rect of the HTML canvas attached with the current webGL context
  33781. * @returns a client rectanglee
  33782. */
  33783. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33784. /**
  33785. * Gets the client rect of the HTML element used for events
  33786. * @returns a client rectanglee
  33787. */
  33788. getInputElementClientRect(): Nullable<ClientRect>;
  33789. /**
  33790. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33791. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33792. * @returns true if engine is in deterministic lock step mode
  33793. */
  33794. isDeterministicLockStep(): boolean;
  33795. /**
  33796. * Gets the max steps when engine is running in deterministic lock step
  33797. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33798. * @returns the max steps
  33799. */
  33800. getLockstepMaxSteps(): number;
  33801. /**
  33802. * Returns the time in ms between steps when using deterministic lock step.
  33803. * @returns time step in (ms)
  33804. */
  33805. getTimeStep(): number;
  33806. /**
  33807. * Force the mipmap generation for the given render target texture
  33808. * @param texture defines the render target texture to use
  33809. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33810. */
  33811. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33812. /** States */
  33813. /**
  33814. * Set various states to the webGL context
  33815. * @param culling defines backface culling state
  33816. * @param zOffset defines the value to apply to zOffset (0 by default)
  33817. * @param force defines if states must be applied even if cache is up to date
  33818. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33819. */
  33820. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33821. /**
  33822. * Set the z offset to apply to current rendering
  33823. * @param value defines the offset to apply
  33824. */
  33825. setZOffset(value: number): void;
  33826. /**
  33827. * Gets the current value of the zOffset
  33828. * @returns the current zOffset state
  33829. */
  33830. getZOffset(): number;
  33831. /**
  33832. * Enable or disable depth buffering
  33833. * @param enable defines the state to set
  33834. */
  33835. setDepthBuffer(enable: boolean): void;
  33836. /**
  33837. * Gets a boolean indicating if depth writing is enabled
  33838. * @returns the current depth writing state
  33839. */
  33840. getDepthWrite(): boolean;
  33841. /**
  33842. * Enable or disable depth writing
  33843. * @param enable defines the state to set
  33844. */
  33845. setDepthWrite(enable: boolean): void;
  33846. /**
  33847. * Gets a boolean indicating if stencil buffer is enabled
  33848. * @returns the current stencil buffer state
  33849. */
  33850. getStencilBuffer(): boolean;
  33851. /**
  33852. * Enable or disable the stencil buffer
  33853. * @param enable defines if the stencil buffer must be enabled or disabled
  33854. */
  33855. setStencilBuffer(enable: boolean): void;
  33856. /**
  33857. * Gets the current stencil mask
  33858. * @returns a number defining the new stencil mask to use
  33859. */
  33860. getStencilMask(): number;
  33861. /**
  33862. * Sets the current stencil mask
  33863. * @param mask defines the new stencil mask to use
  33864. */
  33865. setStencilMask(mask: number): void;
  33866. /**
  33867. * Gets the current stencil function
  33868. * @returns a number defining the stencil function to use
  33869. */
  33870. getStencilFunction(): number;
  33871. /**
  33872. * Gets the current stencil reference value
  33873. * @returns a number defining the stencil reference value to use
  33874. */
  33875. getStencilFunctionReference(): number;
  33876. /**
  33877. * Gets the current stencil mask
  33878. * @returns a number defining the stencil mask to use
  33879. */
  33880. getStencilFunctionMask(): number;
  33881. /**
  33882. * Sets the current stencil function
  33883. * @param stencilFunc defines the new stencil function to use
  33884. */
  33885. setStencilFunction(stencilFunc: number): void;
  33886. /**
  33887. * Sets the current stencil reference
  33888. * @param reference defines the new stencil reference to use
  33889. */
  33890. setStencilFunctionReference(reference: number): void;
  33891. /**
  33892. * Sets the current stencil mask
  33893. * @param mask defines the new stencil mask to use
  33894. */
  33895. setStencilFunctionMask(mask: number): void;
  33896. /**
  33897. * Gets the current stencil operation when stencil fails
  33898. * @returns a number defining stencil operation to use when stencil fails
  33899. */
  33900. getStencilOperationFail(): number;
  33901. /**
  33902. * Gets the current stencil operation when depth fails
  33903. * @returns a number defining stencil operation to use when depth fails
  33904. */
  33905. getStencilOperationDepthFail(): number;
  33906. /**
  33907. * Gets the current stencil operation when stencil passes
  33908. * @returns a number defining stencil operation to use when stencil passes
  33909. */
  33910. getStencilOperationPass(): number;
  33911. /**
  33912. * Sets the stencil operation to use when stencil fails
  33913. * @param operation defines the stencil operation to use when stencil fails
  33914. */
  33915. setStencilOperationFail(operation: number): void;
  33916. /**
  33917. * Sets the stencil operation to use when depth fails
  33918. * @param operation defines the stencil operation to use when depth fails
  33919. */
  33920. setStencilOperationDepthFail(operation: number): void;
  33921. /**
  33922. * Sets the stencil operation to use when stencil passes
  33923. * @param operation defines the stencil operation to use when stencil passes
  33924. */
  33925. setStencilOperationPass(operation: number): void;
  33926. /**
  33927. * Sets a boolean indicating if the dithering state is enabled or disabled
  33928. * @param value defines the dithering state
  33929. */
  33930. setDitheringState(value: boolean): void;
  33931. /**
  33932. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33933. * @param value defines the rasterizer state
  33934. */
  33935. setRasterizerState(value: boolean): void;
  33936. /**
  33937. * Gets the current depth function
  33938. * @returns a number defining the depth function
  33939. */
  33940. getDepthFunction(): Nullable<number>;
  33941. /**
  33942. * Sets the current depth function
  33943. * @param depthFunc defines the function to use
  33944. */
  33945. setDepthFunction(depthFunc: number): void;
  33946. /**
  33947. * Sets the current depth function to GREATER
  33948. */
  33949. setDepthFunctionToGreater(): void;
  33950. /**
  33951. * Sets the current depth function to GEQUAL
  33952. */
  33953. setDepthFunctionToGreaterOrEqual(): void;
  33954. /**
  33955. * Sets the current depth function to LESS
  33956. */
  33957. setDepthFunctionToLess(): void;
  33958. /**
  33959. * Sets the current depth function to LEQUAL
  33960. */
  33961. setDepthFunctionToLessOrEqual(): void;
  33962. private _cachedStencilBuffer;
  33963. private _cachedStencilFunction;
  33964. private _cachedStencilMask;
  33965. private _cachedStencilOperationPass;
  33966. private _cachedStencilOperationFail;
  33967. private _cachedStencilOperationDepthFail;
  33968. private _cachedStencilReference;
  33969. /**
  33970. * Caches the the state of the stencil buffer
  33971. */
  33972. cacheStencilState(): void;
  33973. /**
  33974. * Restores the state of the stencil buffer
  33975. */
  33976. restoreStencilState(): void;
  33977. /**
  33978. * Directly set the WebGL Viewport
  33979. * @param x defines the x coordinate of the viewport (in screen space)
  33980. * @param y defines the y coordinate of the viewport (in screen space)
  33981. * @param width defines the width of the viewport (in screen space)
  33982. * @param height defines the height of the viewport (in screen space)
  33983. * @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
  33984. */
  33985. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33986. /**
  33987. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33988. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33989. * @param y defines the y-coordinate of the corner of the clear rectangle
  33990. * @param width defines the width of the clear rectangle
  33991. * @param height defines the height of the clear rectangle
  33992. * @param clearColor defines the clear color
  33993. */
  33994. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33995. /**
  33996. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33997. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33998. * @param y defines the y-coordinate of the corner of the clear rectangle
  33999. * @param width defines the width of the clear rectangle
  34000. * @param height defines the height of the clear rectangle
  34001. */
  34002. enableScissor(x: number, y: number, width: number, height: number): void;
  34003. /**
  34004. * Disable previously set scissor test rectangle
  34005. */
  34006. disableScissor(): void;
  34007. protected _reportDrawCall(): void;
  34008. /**
  34009. * Initializes a webVR display and starts listening to display change events
  34010. * The onVRDisplayChangedObservable will be notified upon these changes
  34011. * @returns The onVRDisplayChangedObservable
  34012. */
  34013. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34014. /** @hidden */
  34015. _prepareVRComponent(): void;
  34016. /** @hidden */
  34017. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34018. /** @hidden */
  34019. _submitVRFrame(): void;
  34020. /**
  34021. * Call this function to leave webVR mode
  34022. * Will do nothing if webVR is not supported or if there is no webVR device
  34023. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34024. */
  34025. disableVR(): void;
  34026. /**
  34027. * Gets a boolean indicating that the system is in VR mode and is presenting
  34028. * @returns true if VR mode is engaged
  34029. */
  34030. isVRPresenting(): boolean;
  34031. /** @hidden */
  34032. _requestVRFrame(): void;
  34033. /** @hidden */
  34034. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34035. /**
  34036. * Gets the source code of the vertex shader associated with a specific webGL program
  34037. * @param program defines the program to use
  34038. * @returns a string containing the source code of the vertex shader associated with the program
  34039. */
  34040. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34041. /**
  34042. * Gets the source code of the fragment shader associated with a specific webGL program
  34043. * @param program defines the program to use
  34044. * @returns a string containing the source code of the fragment shader associated with the program
  34045. */
  34046. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34047. /**
  34048. * Sets a depth stencil texture from a render target to the according uniform.
  34049. * @param channel The texture channel
  34050. * @param uniform The uniform to set
  34051. * @param texture The render target texture containing the depth stencil texture to apply
  34052. */
  34053. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34054. /**
  34055. * Sets a texture to the webGL context from a postprocess
  34056. * @param channel defines the channel to use
  34057. * @param postProcess defines the source postprocess
  34058. */
  34059. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34060. /**
  34061. * Binds the output of the passed in post process to the texture channel specified
  34062. * @param channel The channel the texture should be bound to
  34063. * @param postProcess The post process which's output should be bound
  34064. */
  34065. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34066. /** @hidden */
  34067. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34068. protected _rebuildBuffers(): void;
  34069. /** @hidden */
  34070. _renderFrame(): void;
  34071. _renderLoop(): void;
  34072. /** @hidden */
  34073. _renderViews(): boolean;
  34074. /**
  34075. * Toggle full screen mode
  34076. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34077. */
  34078. switchFullscreen(requestPointerLock: boolean): void;
  34079. /**
  34080. * Enters full screen mode
  34081. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34082. */
  34083. enterFullscreen(requestPointerLock: boolean): void;
  34084. /**
  34085. * Exits full screen mode
  34086. */
  34087. exitFullscreen(): void;
  34088. /**
  34089. * Enters Pointerlock mode
  34090. */
  34091. enterPointerlock(): void;
  34092. /**
  34093. * Exits Pointerlock mode
  34094. */
  34095. exitPointerlock(): void;
  34096. /**
  34097. * Begin a new frame
  34098. */
  34099. beginFrame(): void;
  34100. /**
  34101. * Enf the current frame
  34102. */
  34103. endFrame(): void;
  34104. resize(): void;
  34105. /**
  34106. * Force a specific size of the canvas
  34107. * @param width defines the new canvas' width
  34108. * @param height defines the new canvas' height
  34109. */
  34110. setSize(width: number, height: number): void;
  34111. /**
  34112. * Updates a dynamic vertex buffer.
  34113. * @param vertexBuffer the vertex buffer to update
  34114. * @param data the data used to update the vertex buffer
  34115. * @param byteOffset the byte offset of the data
  34116. * @param byteLength the byte length of the data
  34117. */
  34118. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34119. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34120. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34121. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34122. _releaseTexture(texture: InternalTexture): void;
  34123. /**
  34124. * @hidden
  34125. * Rescales a texture
  34126. * @param source input texutre
  34127. * @param destination destination texture
  34128. * @param scene scene to use to render the resize
  34129. * @param internalFormat format to use when resizing
  34130. * @param onComplete callback to be called when resize has completed
  34131. */
  34132. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34133. /**
  34134. * Gets the current framerate
  34135. * @returns a number representing the framerate
  34136. */
  34137. getFps(): number;
  34138. /**
  34139. * Gets the time spent between current and previous frame
  34140. * @returns a number representing the delta time in ms
  34141. */
  34142. getDeltaTime(): number;
  34143. private _measureFps;
  34144. /** @hidden */
  34145. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34146. /**
  34147. * Update a dynamic index buffer
  34148. * @param indexBuffer defines the target index buffer
  34149. * @param indices defines the data to update
  34150. * @param offset defines the offset in the target index buffer where update should start
  34151. */
  34152. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34153. /**
  34154. * Updates the sample count of a render target texture
  34155. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34156. * @param texture defines the texture to update
  34157. * @param samples defines the sample count to set
  34158. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34159. */
  34160. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34161. /**
  34162. * Updates a depth texture Comparison Mode and Function.
  34163. * If the comparison Function is equal to 0, the mode will be set to none.
  34164. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34165. * @param texture The texture to set the comparison function for
  34166. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34167. */
  34168. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34169. /**
  34170. * Creates a webGL buffer to use with instanciation
  34171. * @param capacity defines the size of the buffer
  34172. * @returns the webGL buffer
  34173. */
  34174. createInstancesBuffer(capacity: number): DataBuffer;
  34175. /**
  34176. * Delete a webGL buffer used with instanciation
  34177. * @param buffer defines the webGL buffer to delete
  34178. */
  34179. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34180. private _clientWaitAsync;
  34181. /** @hidden */
  34182. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34183. /** @hidden */
  34184. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34185. dispose(): void;
  34186. private _disableTouchAction;
  34187. /**
  34188. * Display the loading screen
  34189. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34190. */
  34191. displayLoadingUI(): void;
  34192. /**
  34193. * Hide the loading screen
  34194. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34195. */
  34196. hideLoadingUI(): void;
  34197. /**
  34198. * Gets the current loading screen object
  34199. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34200. */
  34201. get loadingScreen(): ILoadingScreen;
  34202. /**
  34203. * Sets the current loading screen object
  34204. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34205. */
  34206. set loadingScreen(loadingScreen: ILoadingScreen);
  34207. /**
  34208. * Sets the current loading screen text
  34209. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34210. */
  34211. set loadingUIText(text: string);
  34212. /**
  34213. * Sets the current loading screen background color
  34214. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34215. */
  34216. set loadingUIBackgroundColor(color: string);
  34217. /** Pointerlock and fullscreen */
  34218. /**
  34219. * Ask the browser to promote the current element to pointerlock mode
  34220. * @param element defines the DOM element to promote
  34221. */
  34222. static _RequestPointerlock(element: HTMLElement): void;
  34223. /**
  34224. * Asks the browser to exit pointerlock mode
  34225. */
  34226. static _ExitPointerlock(): void;
  34227. /**
  34228. * Ask the browser to promote the current element to fullscreen rendering mode
  34229. * @param element defines the DOM element to promote
  34230. */
  34231. static _RequestFullscreen(element: HTMLElement): void;
  34232. /**
  34233. * Asks the browser to exit fullscreen mode
  34234. */
  34235. static _ExitFullscreen(): void;
  34236. }
  34237. }
  34238. declare module BABYLON {
  34239. /**
  34240. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34241. * during the life time of the application.
  34242. */
  34243. export class EngineStore {
  34244. /** Gets the list of created engines */
  34245. static Instances: Engine[];
  34246. /** @hidden */
  34247. static _LastCreatedScene: Nullable<Scene>;
  34248. /**
  34249. * Gets the latest created engine
  34250. */
  34251. static get LastCreatedEngine(): Nullable<Engine>;
  34252. /**
  34253. * Gets the latest created scene
  34254. */
  34255. static get LastCreatedScene(): Nullable<Scene>;
  34256. /**
  34257. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34258. * @ignorenaming
  34259. */
  34260. static UseFallbackTexture: boolean;
  34261. /**
  34262. * Texture content used if a texture cannot loaded
  34263. * @ignorenaming
  34264. */
  34265. static FallbackTexture: string;
  34266. }
  34267. }
  34268. declare module BABYLON {
  34269. /**
  34270. * Helper class that provides a small promise polyfill
  34271. */
  34272. export class PromisePolyfill {
  34273. /**
  34274. * Static function used to check if the polyfill is required
  34275. * If this is the case then the function will inject the polyfill to window.Promise
  34276. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34277. */
  34278. static Apply(force?: boolean): void;
  34279. }
  34280. }
  34281. declare module BABYLON {
  34282. /**
  34283. * Interface for screenshot methods with describe argument called `size` as object with options
  34284. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34285. */
  34286. export interface IScreenshotSize {
  34287. /**
  34288. * number in pixels for canvas height
  34289. */
  34290. height?: number;
  34291. /**
  34292. * multiplier allowing render at a higher or lower resolution
  34293. * If value is defined then height and width will be ignored and taken from camera
  34294. */
  34295. precision?: number;
  34296. /**
  34297. * number in pixels for canvas width
  34298. */
  34299. width?: number;
  34300. }
  34301. }
  34302. declare module BABYLON {
  34303. interface IColor4Like {
  34304. r: float;
  34305. g: float;
  34306. b: float;
  34307. a: float;
  34308. }
  34309. /**
  34310. * Class containing a set of static utilities functions
  34311. */
  34312. export class Tools {
  34313. /**
  34314. * Gets or sets the base URL to use to load assets
  34315. */
  34316. static get BaseUrl(): string;
  34317. static set BaseUrl(value: string);
  34318. /**
  34319. * Enable/Disable Custom HTTP Request Headers globally.
  34320. * default = false
  34321. * @see CustomRequestHeaders
  34322. */
  34323. static UseCustomRequestHeaders: boolean;
  34324. /**
  34325. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34326. * i.e. when loading files, where the server/service expects an Authorization header
  34327. */
  34328. static CustomRequestHeaders: {
  34329. [key: string]: string;
  34330. };
  34331. /**
  34332. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34333. */
  34334. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34335. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34336. /**
  34337. * Default behaviour for cors in the application.
  34338. * It can be a string if the expected behavior is identical in the entire app.
  34339. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34340. */
  34341. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34342. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34343. /**
  34344. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34345. * @ignorenaming
  34346. */
  34347. static get UseFallbackTexture(): boolean;
  34348. static set UseFallbackTexture(value: boolean);
  34349. /**
  34350. * Use this object to register external classes like custom textures or material
  34351. * to allow the laoders to instantiate them
  34352. */
  34353. static get RegisteredExternalClasses(): {
  34354. [key: string]: Object;
  34355. };
  34356. static set RegisteredExternalClasses(classes: {
  34357. [key: string]: Object;
  34358. });
  34359. /**
  34360. * Texture content used if a texture cannot loaded
  34361. * @ignorenaming
  34362. */
  34363. static get fallbackTexture(): string;
  34364. static set fallbackTexture(value: string);
  34365. /**
  34366. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34367. * @param u defines the coordinate on X axis
  34368. * @param v defines the coordinate on Y axis
  34369. * @param width defines the width of the source data
  34370. * @param height defines the height of the source data
  34371. * @param pixels defines the source byte array
  34372. * @param color defines the output color
  34373. */
  34374. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34375. /**
  34376. * Interpolates between a and b via alpha
  34377. * @param a The lower value (returned when alpha = 0)
  34378. * @param b The upper value (returned when alpha = 1)
  34379. * @param alpha The interpolation-factor
  34380. * @return The mixed value
  34381. */
  34382. static Mix(a: number, b: number, alpha: number): number;
  34383. /**
  34384. * Tries to instantiate a new object from a given class name
  34385. * @param className defines the class name to instantiate
  34386. * @returns the new object or null if the system was not able to do the instantiation
  34387. */
  34388. static Instantiate(className: string): any;
  34389. /**
  34390. * Provides a slice function that will work even on IE
  34391. * @param data defines the array to slice
  34392. * @param start defines the start of the data (optional)
  34393. * @param end defines the end of the data (optional)
  34394. * @returns the new sliced array
  34395. */
  34396. static Slice<T>(data: T, start?: number, end?: number): T;
  34397. /**
  34398. * Polyfill for setImmediate
  34399. * @param action defines the action to execute after the current execution block
  34400. */
  34401. static SetImmediate(action: () => void): void;
  34402. /**
  34403. * Function indicating if a number is an exponent of 2
  34404. * @param value defines the value to test
  34405. * @returns true if the value is an exponent of 2
  34406. */
  34407. static IsExponentOfTwo(value: number): boolean;
  34408. private static _tmpFloatArray;
  34409. /**
  34410. * Returns the nearest 32-bit single precision float representation of a Number
  34411. * @param value A Number. If the parameter is of a different type, it will get converted
  34412. * to a number or to NaN if it cannot be converted
  34413. * @returns number
  34414. */
  34415. static FloatRound(value: number): number;
  34416. /**
  34417. * Extracts the filename from a path
  34418. * @param path defines the path to use
  34419. * @returns the filename
  34420. */
  34421. static GetFilename(path: string): string;
  34422. /**
  34423. * Extracts the "folder" part of a path (everything before the filename).
  34424. * @param uri The URI to extract the info from
  34425. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34426. * @returns The "folder" part of the path
  34427. */
  34428. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34429. /**
  34430. * Extracts text content from a DOM element hierarchy
  34431. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34432. */
  34433. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34434. /**
  34435. * Convert an angle in radians to degrees
  34436. * @param angle defines the angle to convert
  34437. * @returns the angle in degrees
  34438. */
  34439. static ToDegrees(angle: number): number;
  34440. /**
  34441. * Convert an angle in degrees to radians
  34442. * @param angle defines the angle to convert
  34443. * @returns the angle in radians
  34444. */
  34445. static ToRadians(angle: number): number;
  34446. /**
  34447. * Returns an array if obj is not an array
  34448. * @param obj defines the object to evaluate as an array
  34449. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34450. * @returns either obj directly if obj is an array or a new array containing obj
  34451. */
  34452. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34453. /**
  34454. * Gets the pointer prefix to use
  34455. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34456. */
  34457. static GetPointerPrefix(): string;
  34458. /**
  34459. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34460. * @param url define the url we are trying
  34461. * @param element define the dom element where to configure the cors policy
  34462. */
  34463. static SetCorsBehavior(url: string | string[], element: {
  34464. crossOrigin: string | null;
  34465. }): void;
  34466. /**
  34467. * Removes unwanted characters from an url
  34468. * @param url defines the url to clean
  34469. * @returns the cleaned url
  34470. */
  34471. static CleanUrl(url: string): string;
  34472. /**
  34473. * Gets or sets a function used to pre-process url before using them to load assets
  34474. */
  34475. static get PreprocessUrl(): (url: string) => string;
  34476. static set PreprocessUrl(processor: (url: string) => string);
  34477. /**
  34478. * Loads an image as an HTMLImageElement.
  34479. * @param input url string, ArrayBuffer, or Blob to load
  34480. * @param onLoad callback called when the image successfully loads
  34481. * @param onError callback called when the image fails to load
  34482. * @param offlineProvider offline provider for caching
  34483. * @param mimeType optional mime type
  34484. * @returns the HTMLImageElement of the loaded image
  34485. */
  34486. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34487. /**
  34488. * Loads a file from a url
  34489. * @param url url string, ArrayBuffer, or Blob to load
  34490. * @param onSuccess callback called when the file successfully loads
  34491. * @param onProgress callback called while file is loading (if the server supports this mode)
  34492. * @param offlineProvider defines the offline provider for caching
  34493. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34494. * @param onError callback called when the file fails to load
  34495. * @returns a file request object
  34496. */
  34497. 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;
  34498. /**
  34499. * Loads a file from a url
  34500. * @param url the file url to load
  34501. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34502. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34503. */
  34504. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34505. /**
  34506. * Load a script (identified by an url). When the url returns, the
  34507. * content of this file is added into a new script element, attached to the DOM (body element)
  34508. * @param scriptUrl defines the url of the script to laod
  34509. * @param onSuccess defines the callback called when the script is loaded
  34510. * @param onError defines the callback to call if an error occurs
  34511. * @param scriptId defines the id of the script element
  34512. */
  34513. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34514. /**
  34515. * Load an asynchronous script (identified by an url). When the url returns, the
  34516. * content of this file is added into a new script element, attached to the DOM (body element)
  34517. * @param scriptUrl defines the url of the script to laod
  34518. * @param scriptId defines the id of the script element
  34519. * @returns a promise request object
  34520. */
  34521. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34522. /**
  34523. * Loads a file from a blob
  34524. * @param fileToLoad defines the blob to use
  34525. * @param callback defines the callback to call when data is loaded
  34526. * @param progressCallback defines the callback to call during loading process
  34527. * @returns a file request object
  34528. */
  34529. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34530. /**
  34531. * Reads a file from a File object
  34532. * @param file defines the file to load
  34533. * @param onSuccess defines the callback to call when data is loaded
  34534. * @param onProgress defines the callback to call during loading process
  34535. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34536. * @param onError defines the callback to call when an error occurs
  34537. * @returns a file request object
  34538. */
  34539. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34540. /**
  34541. * Creates a data url from a given string content
  34542. * @param content defines the content to convert
  34543. * @returns the new data url link
  34544. */
  34545. static FileAsURL(content: string): string;
  34546. /**
  34547. * Format the given number to a specific decimal format
  34548. * @param value defines the number to format
  34549. * @param decimals defines the number of decimals to use
  34550. * @returns the formatted string
  34551. */
  34552. static Format(value: number, decimals?: number): string;
  34553. /**
  34554. * Tries to copy an object by duplicating every property
  34555. * @param source defines the source object
  34556. * @param destination defines the target object
  34557. * @param doNotCopyList defines a list of properties to avoid
  34558. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34559. */
  34560. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34561. /**
  34562. * Gets a boolean indicating if the given object has no own property
  34563. * @param obj defines the object to test
  34564. * @returns true if object has no own property
  34565. */
  34566. static IsEmpty(obj: any): boolean;
  34567. /**
  34568. * Function used to register events at window level
  34569. * @param windowElement defines the Window object to use
  34570. * @param events defines the events to register
  34571. */
  34572. static RegisterTopRootEvents(windowElement: Window, events: {
  34573. name: string;
  34574. handler: Nullable<(e: FocusEvent) => any>;
  34575. }[]): void;
  34576. /**
  34577. * Function used to unregister events from window level
  34578. * @param windowElement defines the Window object to use
  34579. * @param events defines the events to unregister
  34580. */
  34581. static UnregisterTopRootEvents(windowElement: Window, events: {
  34582. name: string;
  34583. handler: Nullable<(e: FocusEvent) => any>;
  34584. }[]): void;
  34585. /**
  34586. * @ignore
  34587. */
  34588. static _ScreenshotCanvas: HTMLCanvasElement;
  34589. /**
  34590. * Dumps the current bound framebuffer
  34591. * @param width defines the rendering width
  34592. * @param height defines the rendering height
  34593. * @param engine defines the hosting engine
  34594. * @param successCallback defines the callback triggered once the data are available
  34595. * @param mimeType defines the mime type of the result
  34596. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34597. */
  34598. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34599. /**
  34600. * Converts the canvas data to blob.
  34601. * This acts as a polyfill for browsers not supporting the to blob function.
  34602. * @param canvas Defines the canvas to extract the data from
  34603. * @param successCallback Defines the callback triggered once the data are available
  34604. * @param mimeType Defines the mime type of the result
  34605. */
  34606. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34607. /**
  34608. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34609. * @param successCallback defines the callback triggered once the data are available
  34610. * @param mimeType defines the mime type of the result
  34611. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34612. */
  34613. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34614. /**
  34615. * Downloads a blob in the browser
  34616. * @param blob defines the blob to download
  34617. * @param fileName defines the name of the downloaded file
  34618. */
  34619. static Download(blob: Blob, fileName: string): void;
  34620. /**
  34621. * Captures a screenshot of the current rendering
  34622. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34623. * @param engine defines the rendering engine
  34624. * @param camera defines the source camera
  34625. * @param size This parameter can be set to a single number or to an object with the
  34626. * following (optional) properties: precision, width, height. If a single number is passed,
  34627. * it will be used for both width and height. If an object is passed, the screenshot size
  34628. * will be derived from the parameters. The precision property is a multiplier allowing
  34629. * rendering at a higher or lower resolution
  34630. * @param successCallback defines the callback receives a single parameter which contains the
  34631. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34632. * src parameter of an <img> to display it
  34633. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34634. * Check your browser for supported MIME types
  34635. */
  34636. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34637. /**
  34638. * Captures a screenshot of the current rendering
  34639. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34640. * @param engine defines the rendering engine
  34641. * @param camera defines the source camera
  34642. * @param size This parameter can be set to a single number or to an object with the
  34643. * following (optional) properties: precision, width, height. If a single number is passed,
  34644. * it will be used for both width and height. If an object is passed, the screenshot size
  34645. * will be derived from the parameters. The precision property is a multiplier allowing
  34646. * rendering at a higher or lower resolution
  34647. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34648. * Check your browser for supported MIME types
  34649. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34650. * to the src parameter of an <img> to display it
  34651. */
  34652. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34653. /**
  34654. * Generates an image screenshot from the specified camera.
  34655. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34656. * @param engine The engine to use for rendering
  34657. * @param camera The camera to use for rendering
  34658. * @param size This parameter can be set to a single number or to an object with the
  34659. * following (optional) properties: precision, width, height. If a single number is passed,
  34660. * it will be used for both width and height. If an object is passed, the screenshot size
  34661. * will be derived from the parameters. The precision property is a multiplier allowing
  34662. * rendering at a higher or lower resolution
  34663. * @param successCallback The callback receives a single parameter which contains the
  34664. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34665. * src parameter of an <img> to display it
  34666. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34667. * Check your browser for supported MIME types
  34668. * @param samples Texture samples (default: 1)
  34669. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34670. * @param fileName A name for for the downloaded file.
  34671. */
  34672. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34673. /**
  34674. * Generates an image screenshot from the specified camera.
  34675. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34676. * @param engine The engine to use for rendering
  34677. * @param camera The camera to use for rendering
  34678. * @param size This parameter can be set to a single number or to an object with the
  34679. * following (optional) properties: precision, width, height. If a single number is passed,
  34680. * it will be used for both width and height. If an object is passed, the screenshot size
  34681. * will be derived from the parameters. The precision property is a multiplier allowing
  34682. * rendering at a higher or lower resolution
  34683. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34684. * Check your browser for supported MIME types
  34685. * @param samples Texture samples (default: 1)
  34686. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34687. * @param fileName A name for for the downloaded file.
  34688. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34689. * to the src parameter of an <img> to display it
  34690. */
  34691. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34692. /**
  34693. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34694. * Be aware Math.random() could cause collisions, but:
  34695. * "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"
  34696. * @returns a pseudo random id
  34697. */
  34698. static RandomId(): string;
  34699. /**
  34700. * Test if the given uri is a base64 string
  34701. * @param uri The uri to test
  34702. * @return True if the uri is a base64 string or false otherwise
  34703. */
  34704. static IsBase64(uri: string): boolean;
  34705. /**
  34706. * Decode the given base64 uri.
  34707. * @param uri The uri to decode
  34708. * @return The decoded base64 data.
  34709. */
  34710. static DecodeBase64(uri: string): ArrayBuffer;
  34711. /**
  34712. * Gets the absolute url.
  34713. * @param url the input url
  34714. * @return the absolute url
  34715. */
  34716. static GetAbsoluteUrl(url: string): string;
  34717. /**
  34718. * No log
  34719. */
  34720. static readonly NoneLogLevel: number;
  34721. /**
  34722. * Only message logs
  34723. */
  34724. static readonly MessageLogLevel: number;
  34725. /**
  34726. * Only warning logs
  34727. */
  34728. static readonly WarningLogLevel: number;
  34729. /**
  34730. * Only error logs
  34731. */
  34732. static readonly ErrorLogLevel: number;
  34733. /**
  34734. * All logs
  34735. */
  34736. static readonly AllLogLevel: number;
  34737. /**
  34738. * Gets a value indicating the number of loading errors
  34739. * @ignorenaming
  34740. */
  34741. static get errorsCount(): number;
  34742. /**
  34743. * Callback called when a new log is added
  34744. */
  34745. static OnNewCacheEntry: (entry: string) => void;
  34746. /**
  34747. * Log a message to the console
  34748. * @param message defines the message to log
  34749. */
  34750. static Log(message: string): void;
  34751. /**
  34752. * Write a warning message to the console
  34753. * @param message defines the message to log
  34754. */
  34755. static Warn(message: string): void;
  34756. /**
  34757. * Write an error message to the console
  34758. * @param message defines the message to log
  34759. */
  34760. static Error(message: string): void;
  34761. /**
  34762. * Gets current log cache (list of logs)
  34763. */
  34764. static get LogCache(): string;
  34765. /**
  34766. * Clears the log cache
  34767. */
  34768. static ClearLogCache(): void;
  34769. /**
  34770. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34771. */
  34772. static set LogLevels(level: number);
  34773. /**
  34774. * Checks if the window object exists
  34775. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34776. */
  34777. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34778. /**
  34779. * No performance log
  34780. */
  34781. static readonly PerformanceNoneLogLevel: number;
  34782. /**
  34783. * Use user marks to log performance
  34784. */
  34785. static readonly PerformanceUserMarkLogLevel: number;
  34786. /**
  34787. * Log performance to the console
  34788. */
  34789. static readonly PerformanceConsoleLogLevel: number;
  34790. private static _performance;
  34791. /**
  34792. * Sets the current performance log level
  34793. */
  34794. static set PerformanceLogLevel(level: number);
  34795. private static _StartPerformanceCounterDisabled;
  34796. private static _EndPerformanceCounterDisabled;
  34797. private static _StartUserMark;
  34798. private static _EndUserMark;
  34799. private static _StartPerformanceConsole;
  34800. private static _EndPerformanceConsole;
  34801. /**
  34802. * Starts a performance counter
  34803. */
  34804. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34805. /**
  34806. * Ends a specific performance coutner
  34807. */
  34808. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34809. /**
  34810. * Gets either window.performance.now() if supported or Date.now() else
  34811. */
  34812. static get Now(): number;
  34813. /**
  34814. * This method will return the name of the class used to create the instance of the given object.
  34815. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34816. * @param object the object to get the class name from
  34817. * @param isType defines if the object is actually a type
  34818. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34819. */
  34820. static GetClassName(object: any, isType?: boolean): string;
  34821. /**
  34822. * Gets the first element of an array satisfying a given predicate
  34823. * @param array defines the array to browse
  34824. * @param predicate defines the predicate to use
  34825. * @returns null if not found or the element
  34826. */
  34827. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34828. /**
  34829. * This method will return the name of the full name of the class, including its owning module (if any).
  34830. * 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).
  34831. * @param object the object to get the class name from
  34832. * @param isType defines if the object is actually a type
  34833. * @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.
  34834. * @ignorenaming
  34835. */
  34836. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34837. /**
  34838. * Returns a promise that resolves after the given amount of time.
  34839. * @param delay Number of milliseconds to delay
  34840. * @returns Promise that resolves after the given amount of time
  34841. */
  34842. static DelayAsync(delay: number): Promise<void>;
  34843. /**
  34844. * Utility function to detect if the current user agent is Safari
  34845. * @returns whether or not the current user agent is safari
  34846. */
  34847. static IsSafari(): boolean;
  34848. }
  34849. /**
  34850. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34851. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34852. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34853. * @param name The name of the class, case should be preserved
  34854. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34855. */
  34856. export function className(name: string, module?: string): (target: Object) => void;
  34857. /**
  34858. * An implementation of a loop for asynchronous functions.
  34859. */
  34860. export class AsyncLoop {
  34861. /**
  34862. * Defines the number of iterations for the loop
  34863. */
  34864. iterations: number;
  34865. /**
  34866. * Defines the current index of the loop.
  34867. */
  34868. index: number;
  34869. private _done;
  34870. private _fn;
  34871. private _successCallback;
  34872. /**
  34873. * Constructor.
  34874. * @param iterations the number of iterations.
  34875. * @param func the function to run each iteration
  34876. * @param successCallback the callback that will be called upon succesful execution
  34877. * @param offset starting offset.
  34878. */
  34879. constructor(
  34880. /**
  34881. * Defines the number of iterations for the loop
  34882. */
  34883. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34884. /**
  34885. * Execute the next iteration. Must be called after the last iteration was finished.
  34886. */
  34887. executeNext(): void;
  34888. /**
  34889. * Break the loop and run the success callback.
  34890. */
  34891. breakLoop(): void;
  34892. /**
  34893. * Create and run an async loop.
  34894. * @param iterations the number of iterations.
  34895. * @param fn the function to run each iteration
  34896. * @param successCallback the callback that will be called upon succesful execution
  34897. * @param offset starting offset.
  34898. * @returns the created async loop object
  34899. */
  34900. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34901. /**
  34902. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34903. * @param iterations total number of iterations
  34904. * @param syncedIterations number of synchronous iterations in each async iteration.
  34905. * @param fn the function to call each iteration.
  34906. * @param callback a success call back that will be called when iterating stops.
  34907. * @param breakFunction a break condition (optional)
  34908. * @param timeout timeout settings for the setTimeout function. default - 0.
  34909. * @returns the created async loop object
  34910. */
  34911. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34912. }
  34913. }
  34914. declare module BABYLON {
  34915. /**
  34916. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34917. * The underlying implementation relies on an associative array to ensure the best performances.
  34918. * The value can be anything including 'null' but except 'undefined'
  34919. */
  34920. export class StringDictionary<T> {
  34921. /**
  34922. * This will clear this dictionary and copy the content from the 'source' one.
  34923. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34924. * @param source the dictionary to take the content from and copy to this dictionary
  34925. */
  34926. copyFrom(source: StringDictionary<T>): void;
  34927. /**
  34928. * Get a value based from its key
  34929. * @param key the given key to get the matching value from
  34930. * @return the value if found, otherwise undefined is returned
  34931. */
  34932. get(key: string): T | undefined;
  34933. /**
  34934. * Get a value from its key or add it if it doesn't exist.
  34935. * This method will ensure you that a given key/data will be present in the dictionary.
  34936. * @param key the given key to get the matching value from
  34937. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34938. * The factory will only be invoked if there's no data for the given key.
  34939. * @return the value corresponding to the key.
  34940. */
  34941. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34942. /**
  34943. * Get a value from its key if present in the dictionary otherwise add it
  34944. * @param key the key to get the value from
  34945. * @param val if there's no such key/value pair in the dictionary add it with this value
  34946. * @return the value corresponding to the key
  34947. */
  34948. getOrAdd(key: string, val: T): T;
  34949. /**
  34950. * Check if there's a given key in the dictionary
  34951. * @param key the key to check for
  34952. * @return true if the key is present, false otherwise
  34953. */
  34954. contains(key: string): boolean;
  34955. /**
  34956. * Add a new key and its corresponding value
  34957. * @param key the key to add
  34958. * @param value the value corresponding to the key
  34959. * @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
  34960. */
  34961. add(key: string, value: T): boolean;
  34962. /**
  34963. * Update a specific value associated to a key
  34964. * @param key defines the key to use
  34965. * @param value defines the value to store
  34966. * @returns true if the value was updated (or false if the key was not found)
  34967. */
  34968. set(key: string, value: T): boolean;
  34969. /**
  34970. * Get the element of the given key and remove it from the dictionary
  34971. * @param key defines the key to search
  34972. * @returns the value associated with the key or null if not found
  34973. */
  34974. getAndRemove(key: string): Nullable<T>;
  34975. /**
  34976. * Remove a key/value from the dictionary.
  34977. * @param key the key to remove
  34978. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34979. */
  34980. remove(key: string): boolean;
  34981. /**
  34982. * Clear the whole content of the dictionary
  34983. */
  34984. clear(): void;
  34985. /**
  34986. * Gets the current count
  34987. */
  34988. get count(): number;
  34989. /**
  34990. * Execute a callback on each key/val of the dictionary.
  34991. * Note that you can remove any element in this dictionary in the callback implementation
  34992. * @param callback the callback to execute on a given key/value pair
  34993. */
  34994. forEach(callback: (key: string, val: T) => void): void;
  34995. /**
  34996. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34997. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34998. * Note that you can remove any element in this dictionary in the callback implementation
  34999. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35000. * @returns the first item
  35001. */
  35002. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35003. private _count;
  35004. private _data;
  35005. }
  35006. }
  35007. declare module BABYLON {
  35008. /** @hidden */
  35009. export interface ICollisionCoordinator {
  35010. createCollider(): Collider;
  35011. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35012. init(scene: Scene): void;
  35013. }
  35014. /** @hidden */
  35015. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35016. private _scene;
  35017. private _scaledPosition;
  35018. private _scaledVelocity;
  35019. private _finalPosition;
  35020. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35021. createCollider(): Collider;
  35022. init(scene: Scene): void;
  35023. private _collideWithWorld;
  35024. }
  35025. }
  35026. declare module BABYLON {
  35027. /**
  35028. * Class used to manage all inputs for the scene.
  35029. */
  35030. export class InputManager {
  35031. /** The distance in pixel that you have to move to prevent some events */
  35032. static DragMovementThreshold: number;
  35033. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35034. static LongPressDelay: number;
  35035. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35036. static DoubleClickDelay: number;
  35037. /** If you need to check double click without raising a single click at first click, enable this flag */
  35038. static ExclusiveDoubleClickMode: boolean;
  35039. private _wheelEventName;
  35040. private _onPointerMove;
  35041. private _onPointerDown;
  35042. private _onPointerUp;
  35043. private _initClickEvent;
  35044. private _initActionManager;
  35045. private _delayedSimpleClick;
  35046. private _delayedSimpleClickTimeout;
  35047. private _previousDelayedSimpleClickTimeout;
  35048. private _meshPickProceed;
  35049. private _previousButtonPressed;
  35050. private _currentPickResult;
  35051. private _previousPickResult;
  35052. private _totalPointersPressed;
  35053. private _doubleClickOccured;
  35054. private _pointerOverMesh;
  35055. private _pickedDownMesh;
  35056. private _pickedUpMesh;
  35057. private _pointerX;
  35058. private _pointerY;
  35059. private _unTranslatedPointerX;
  35060. private _unTranslatedPointerY;
  35061. private _startingPointerPosition;
  35062. private _previousStartingPointerPosition;
  35063. private _startingPointerTime;
  35064. private _previousStartingPointerTime;
  35065. private _pointerCaptures;
  35066. private _onKeyDown;
  35067. private _onKeyUp;
  35068. private _onCanvasFocusObserver;
  35069. private _onCanvasBlurObserver;
  35070. private _scene;
  35071. /**
  35072. * Creates a new InputManager
  35073. * @param scene defines the hosting scene
  35074. */
  35075. constructor(scene: Scene);
  35076. /**
  35077. * Gets the mesh that is currently under the pointer
  35078. */
  35079. get meshUnderPointer(): Nullable<AbstractMesh>;
  35080. /**
  35081. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35082. */
  35083. get unTranslatedPointer(): Vector2;
  35084. /**
  35085. * Gets or sets the current on-screen X position of the pointer
  35086. */
  35087. get pointerX(): number;
  35088. set pointerX(value: number);
  35089. /**
  35090. * Gets or sets the current on-screen Y position of the pointer
  35091. */
  35092. get pointerY(): number;
  35093. set pointerY(value: number);
  35094. private _updatePointerPosition;
  35095. private _processPointerMove;
  35096. private _setRayOnPointerInfo;
  35097. private _checkPrePointerObservable;
  35098. /**
  35099. * Use this method to simulate a pointer move on a mesh
  35100. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35101. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35102. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35103. */
  35104. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35105. /**
  35106. * Use this method to simulate a pointer down 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. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35112. private _processPointerDown;
  35113. /** @hidden */
  35114. _isPointerSwiping(): boolean;
  35115. /**
  35116. * Use this method to simulate a pointer up on a mesh
  35117. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35118. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35119. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35120. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35121. */
  35122. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35123. private _processPointerUp;
  35124. /**
  35125. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35126. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35127. * @returns true if the pointer was captured
  35128. */
  35129. isPointerCaptured(pointerId?: number): boolean;
  35130. /**
  35131. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35132. * @param attachUp defines if you want to attach events to pointerup
  35133. * @param attachDown defines if you want to attach events to pointerdown
  35134. * @param attachMove defines if you want to attach events to pointermove
  35135. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35136. */
  35137. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35138. /**
  35139. * Detaches all event handlers
  35140. */
  35141. detachControl(): void;
  35142. /**
  35143. * Force the value of meshUnderPointer
  35144. * @param mesh defines the mesh to use
  35145. */
  35146. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35147. /**
  35148. * Gets the mesh under the pointer
  35149. * @returns a Mesh or null if no mesh is under the pointer
  35150. */
  35151. getPointerOverMesh(): Nullable<AbstractMesh>;
  35152. }
  35153. }
  35154. declare module BABYLON {
  35155. /**
  35156. * Helper class used to generate session unique ID
  35157. */
  35158. export class UniqueIdGenerator {
  35159. private static _UniqueIdCounter;
  35160. /**
  35161. * Gets an unique (relatively to the current scene) Id
  35162. */
  35163. static get UniqueId(): number;
  35164. }
  35165. }
  35166. declare module BABYLON {
  35167. /**
  35168. * This class defines the direct association between an animation and a target
  35169. */
  35170. export class TargetedAnimation {
  35171. /**
  35172. * Animation to perform
  35173. */
  35174. animation: Animation;
  35175. /**
  35176. * Target to animate
  35177. */
  35178. target: any;
  35179. /**
  35180. * Serialize the object
  35181. * @returns the JSON object representing the current entity
  35182. */
  35183. serialize(): any;
  35184. }
  35185. /**
  35186. * Use this class to create coordinated animations on multiple targets
  35187. */
  35188. export class AnimationGroup implements IDisposable {
  35189. /** The name of the animation group */
  35190. name: string;
  35191. private _scene;
  35192. private _targetedAnimations;
  35193. private _animatables;
  35194. private _from;
  35195. private _to;
  35196. private _isStarted;
  35197. private _isPaused;
  35198. private _speedRatio;
  35199. private _loopAnimation;
  35200. private _isAdditive;
  35201. /**
  35202. * Gets or sets the unique id of the node
  35203. */
  35204. uniqueId: number;
  35205. /**
  35206. * This observable will notify when one animation have ended
  35207. */
  35208. onAnimationEndObservable: Observable<TargetedAnimation>;
  35209. /**
  35210. * Observer raised when one animation loops
  35211. */
  35212. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35213. /**
  35214. * Observer raised when all animations have looped
  35215. */
  35216. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35217. /**
  35218. * This observable will notify when all animations have ended.
  35219. */
  35220. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35221. /**
  35222. * This observable will notify when all animations have paused.
  35223. */
  35224. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35225. /**
  35226. * This observable will notify when all animations are playing.
  35227. */
  35228. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35229. /**
  35230. * Gets the first frame
  35231. */
  35232. get from(): number;
  35233. /**
  35234. * Gets the last frame
  35235. */
  35236. get to(): number;
  35237. /**
  35238. * Define if the animations are started
  35239. */
  35240. get isStarted(): boolean;
  35241. /**
  35242. * Gets a value indicating that the current group is playing
  35243. */
  35244. get isPlaying(): boolean;
  35245. /**
  35246. * Gets or sets the speed ratio to use for all animations
  35247. */
  35248. get speedRatio(): number;
  35249. /**
  35250. * Gets or sets the speed ratio to use for all animations
  35251. */
  35252. set speedRatio(value: number);
  35253. /**
  35254. * Gets or sets if all animations should loop or not
  35255. */
  35256. get loopAnimation(): boolean;
  35257. set loopAnimation(value: boolean);
  35258. /**
  35259. * Gets or sets if all animations should be evaluated additively
  35260. */
  35261. get isAdditive(): boolean;
  35262. set isAdditive(value: boolean);
  35263. /**
  35264. * Gets the targeted animations for this animation group
  35265. */
  35266. get targetedAnimations(): Array<TargetedAnimation>;
  35267. /**
  35268. * returning the list of animatables controlled by this animation group.
  35269. */
  35270. get animatables(): Array<Animatable>;
  35271. /**
  35272. * Instantiates a new Animation Group.
  35273. * This helps managing several animations at once.
  35274. * @see http://doc.babylonjs.com/how_to/group
  35275. * @param name Defines the name of the group
  35276. * @param scene Defines the scene the group belongs to
  35277. */
  35278. constructor(
  35279. /** The name of the animation group */
  35280. name: string, scene?: Nullable<Scene>);
  35281. /**
  35282. * Add an animation (with its target) in the group
  35283. * @param animation defines the animation we want to add
  35284. * @param target defines the target of the animation
  35285. * @returns the TargetedAnimation object
  35286. */
  35287. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35288. /**
  35289. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35290. * It can add constant keys at begin or end
  35291. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35292. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35293. * @returns the animation group
  35294. */
  35295. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35296. private _animationLoopCount;
  35297. private _animationLoopFlags;
  35298. private _processLoop;
  35299. /**
  35300. * Start all animations on given targets
  35301. * @param loop defines if animations must loop
  35302. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35303. * @param from defines the from key (optional)
  35304. * @param to defines the to key (optional)
  35305. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35306. * @returns the current animation group
  35307. */
  35308. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35309. /**
  35310. * Pause all animations
  35311. * @returns the animation group
  35312. */
  35313. pause(): AnimationGroup;
  35314. /**
  35315. * Play all animations to initial state
  35316. * This function will start() the animations if they were not started or will restart() them if they were paused
  35317. * @param loop defines if animations must loop
  35318. * @returns the animation group
  35319. */
  35320. play(loop?: boolean): AnimationGroup;
  35321. /**
  35322. * Reset all animations to initial state
  35323. * @returns the animation group
  35324. */
  35325. reset(): AnimationGroup;
  35326. /**
  35327. * Restart animations from key 0
  35328. * @returns the animation group
  35329. */
  35330. restart(): AnimationGroup;
  35331. /**
  35332. * Stop all animations
  35333. * @returns the animation group
  35334. */
  35335. stop(): AnimationGroup;
  35336. /**
  35337. * Set animation weight for all animatables
  35338. * @param weight defines the weight to use
  35339. * @return the animationGroup
  35340. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35341. */
  35342. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35343. /**
  35344. * Synchronize and normalize all animatables with a source animatable
  35345. * @param root defines the root animatable to synchronize with
  35346. * @return the animationGroup
  35347. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35348. */
  35349. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35350. /**
  35351. * Goes to a specific frame in this animation group
  35352. * @param frame the frame number to go to
  35353. * @return the animationGroup
  35354. */
  35355. goToFrame(frame: number): AnimationGroup;
  35356. /**
  35357. * Dispose all associated resources
  35358. */
  35359. dispose(): void;
  35360. private _checkAnimationGroupEnded;
  35361. /**
  35362. * Clone the current animation group and returns a copy
  35363. * @param newName defines the name of the new group
  35364. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35365. * @returns the new aniamtion group
  35366. */
  35367. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35368. /**
  35369. * Serializes the animationGroup to an object
  35370. * @returns Serialized object
  35371. */
  35372. serialize(): any;
  35373. /**
  35374. * Returns a new AnimationGroup object parsed from the source provided.
  35375. * @param parsedAnimationGroup defines the source
  35376. * @param scene defines the scene that will receive the animationGroup
  35377. * @returns a new AnimationGroup
  35378. */
  35379. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35380. /**
  35381. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35382. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35383. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35384. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35385. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35386. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35387. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35388. */
  35389. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35390. /**
  35391. * Returns the string "AnimationGroup"
  35392. * @returns "AnimationGroup"
  35393. */
  35394. getClassName(): string;
  35395. /**
  35396. * Creates a detailled string about the object
  35397. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35398. * @returns a string representing the object
  35399. */
  35400. toString(fullDetails?: boolean): string;
  35401. }
  35402. }
  35403. declare module BABYLON {
  35404. /**
  35405. * Define an interface for all classes that will hold resources
  35406. */
  35407. export interface IDisposable {
  35408. /**
  35409. * Releases all held resources
  35410. */
  35411. dispose(): void;
  35412. }
  35413. /** Interface defining initialization parameters for Scene class */
  35414. export interface SceneOptions {
  35415. /**
  35416. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35417. * It will improve performance when the number of geometries becomes important.
  35418. */
  35419. useGeometryUniqueIdsMap?: boolean;
  35420. /**
  35421. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35422. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35423. */
  35424. useMaterialMeshMap?: boolean;
  35425. /**
  35426. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35427. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35428. */
  35429. useClonedMeshMap?: boolean;
  35430. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35431. virtual?: boolean;
  35432. }
  35433. /**
  35434. * Represents a scene to be rendered by the engine.
  35435. * @see http://doc.babylonjs.com/features/scene
  35436. */
  35437. export class Scene extends AbstractScene implements IAnimatable {
  35438. /** The fog is deactivated */
  35439. static readonly FOGMODE_NONE: number;
  35440. /** The fog density is following an exponential function */
  35441. static readonly FOGMODE_EXP: number;
  35442. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35443. static readonly FOGMODE_EXP2: number;
  35444. /** The fog density is following a linear function. */
  35445. static readonly FOGMODE_LINEAR: number;
  35446. /**
  35447. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35448. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35449. */
  35450. static MinDeltaTime: number;
  35451. /**
  35452. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35453. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35454. */
  35455. static MaxDeltaTime: number;
  35456. /**
  35457. * Factory used to create the default material.
  35458. * @param name The name of the material to create
  35459. * @param scene The scene to create the material for
  35460. * @returns The default material
  35461. */
  35462. static DefaultMaterialFactory(scene: Scene): Material;
  35463. /**
  35464. * Factory used to create the a collision coordinator.
  35465. * @returns The collision coordinator
  35466. */
  35467. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35468. /** @hidden */
  35469. _inputManager: InputManager;
  35470. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35471. cameraToUseForPointers: Nullable<Camera>;
  35472. /** @hidden */
  35473. readonly _isScene: boolean;
  35474. /** @hidden */
  35475. _blockEntityCollection: boolean;
  35476. /**
  35477. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35478. */
  35479. autoClear: boolean;
  35480. /**
  35481. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35482. */
  35483. autoClearDepthAndStencil: boolean;
  35484. /**
  35485. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35486. */
  35487. clearColor: Color4;
  35488. /**
  35489. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35490. */
  35491. ambientColor: Color3;
  35492. /**
  35493. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35494. * It should only be one of the following (if not the default embedded one):
  35495. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35496. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35497. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35498. * The material properties need to be setup according to the type of texture in use.
  35499. */
  35500. environmentBRDFTexture: BaseTexture;
  35501. /** @hidden */
  35502. protected _environmentTexture: Nullable<BaseTexture>;
  35503. /**
  35504. * Texture used in all pbr material as the reflection texture.
  35505. * As in the majority of the scene they are the same (exception for multi room and so on),
  35506. * this is easier to reference from here than from all the materials.
  35507. */
  35508. get environmentTexture(): Nullable<BaseTexture>;
  35509. /**
  35510. * Texture used in all pbr material as the reflection texture.
  35511. * As in the majority of the scene they are the same (exception for multi room and so on),
  35512. * this is easier to set here than in all the materials.
  35513. */
  35514. set environmentTexture(value: Nullable<BaseTexture>);
  35515. /** @hidden */
  35516. protected _environmentIntensity: number;
  35517. /**
  35518. * Intensity of the environment in all pbr material.
  35519. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35520. * As in the majority of the scene they are the same (exception for multi room and so on),
  35521. * this is easier to reference from here than from all the materials.
  35522. */
  35523. get 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 set here than in all the materials.
  35529. */
  35530. set environmentIntensity(value: number);
  35531. /** @hidden */
  35532. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35533. /**
  35534. * Default image processing configuration used either in the rendering
  35535. * Forward main pass or through the imageProcessingPostProcess if present.
  35536. * As in the majority of the scene they are the same (exception for multi camera),
  35537. * this is easier to reference from here than from all the materials and post process.
  35538. *
  35539. * No setter as we it is a shared configuration, you can set the values instead.
  35540. */
  35541. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35542. private _forceWireframe;
  35543. /**
  35544. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35545. */
  35546. set forceWireframe(value: boolean);
  35547. get forceWireframe(): boolean;
  35548. private _skipFrustumClipping;
  35549. /**
  35550. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35551. */
  35552. set skipFrustumClipping(value: boolean);
  35553. get skipFrustumClipping(): boolean;
  35554. private _forcePointsCloud;
  35555. /**
  35556. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35557. */
  35558. set forcePointsCloud(value: boolean);
  35559. get forcePointsCloud(): boolean;
  35560. /**
  35561. * Gets or sets the active clipplane 1
  35562. */
  35563. clipPlane: Nullable<Plane>;
  35564. /**
  35565. * Gets or sets the active clipplane 2
  35566. */
  35567. clipPlane2: Nullable<Plane>;
  35568. /**
  35569. * Gets or sets the active clipplane 3
  35570. */
  35571. clipPlane3: Nullable<Plane>;
  35572. /**
  35573. * Gets or sets the active clipplane 4
  35574. */
  35575. clipPlane4: Nullable<Plane>;
  35576. /**
  35577. * Gets or sets the active clipplane 5
  35578. */
  35579. clipPlane5: Nullable<Plane>;
  35580. /**
  35581. * Gets or sets the active clipplane 6
  35582. */
  35583. clipPlane6: Nullable<Plane>;
  35584. /**
  35585. * Gets or sets a boolean indicating if animations are enabled
  35586. */
  35587. animationsEnabled: boolean;
  35588. private _animationPropertiesOverride;
  35589. /**
  35590. * Gets or sets the animation properties override
  35591. */
  35592. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35593. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35594. /**
  35595. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35596. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35597. */
  35598. useConstantAnimationDeltaTime: boolean;
  35599. /**
  35600. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35601. * Please note that it requires to run a ray cast through the scene on every frame
  35602. */
  35603. constantlyUpdateMeshUnderPointer: boolean;
  35604. /**
  35605. * Defines the HTML cursor to use when hovering over interactive elements
  35606. */
  35607. hoverCursor: string;
  35608. /**
  35609. * Defines the HTML default cursor to use (empty by default)
  35610. */
  35611. defaultCursor: string;
  35612. /**
  35613. * Defines whether cursors are handled by the scene.
  35614. */
  35615. doNotHandleCursors: boolean;
  35616. /**
  35617. * This is used to call preventDefault() on pointer down
  35618. * in order to block unwanted artifacts like system double clicks
  35619. */
  35620. preventDefaultOnPointerDown: boolean;
  35621. /**
  35622. * This is used to call preventDefault() on pointer up
  35623. * in order to block unwanted artifacts like system double clicks
  35624. */
  35625. preventDefaultOnPointerUp: boolean;
  35626. /**
  35627. * Gets or sets user defined metadata
  35628. */
  35629. metadata: any;
  35630. /**
  35631. * For internal use only. Please do not use.
  35632. */
  35633. reservedDataStore: any;
  35634. /**
  35635. * Gets the name of the plugin used to load this scene (null by default)
  35636. */
  35637. loadingPluginName: string;
  35638. /**
  35639. * Use this array to add regular expressions used to disable offline support for specific urls
  35640. */
  35641. disableOfflineSupportExceptionRules: RegExp[];
  35642. /**
  35643. * An event triggered when the scene is disposed.
  35644. */
  35645. onDisposeObservable: Observable<Scene>;
  35646. private _onDisposeObserver;
  35647. /** Sets a function to be executed when this scene is disposed. */
  35648. set onDispose(callback: () => void);
  35649. /**
  35650. * An event triggered before rendering the scene (right after animations and physics)
  35651. */
  35652. onBeforeRenderObservable: Observable<Scene>;
  35653. private _onBeforeRenderObserver;
  35654. /** Sets a function to be executed before rendering this scene */
  35655. set beforeRender(callback: Nullable<() => void>);
  35656. /**
  35657. * An event triggered after rendering the scene
  35658. */
  35659. onAfterRenderObservable: Observable<Scene>;
  35660. /**
  35661. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35662. */
  35663. onAfterRenderCameraObservable: Observable<Camera>;
  35664. private _onAfterRenderObserver;
  35665. /** Sets a function to be executed after rendering this scene */
  35666. set afterRender(callback: Nullable<() => void>);
  35667. /**
  35668. * An event triggered before animating the scene
  35669. */
  35670. onBeforeAnimationsObservable: Observable<Scene>;
  35671. /**
  35672. * An event triggered after animations processing
  35673. */
  35674. onAfterAnimationsObservable: Observable<Scene>;
  35675. /**
  35676. * An event triggered before draw calls are ready to be sent
  35677. */
  35678. onBeforeDrawPhaseObservable: Observable<Scene>;
  35679. /**
  35680. * An event triggered after draw calls have been sent
  35681. */
  35682. onAfterDrawPhaseObservable: Observable<Scene>;
  35683. /**
  35684. * An event triggered when the scene is ready
  35685. */
  35686. onReadyObservable: Observable<Scene>;
  35687. /**
  35688. * An event triggered before rendering a camera
  35689. */
  35690. onBeforeCameraRenderObservable: Observable<Camera>;
  35691. private _onBeforeCameraRenderObserver;
  35692. /** Sets a function to be executed before rendering a camera*/
  35693. set beforeCameraRender(callback: () => void);
  35694. /**
  35695. * An event triggered after rendering a camera
  35696. */
  35697. onAfterCameraRenderObservable: Observable<Camera>;
  35698. private _onAfterCameraRenderObserver;
  35699. /** Sets a function to be executed after rendering a camera*/
  35700. set afterCameraRender(callback: () => void);
  35701. /**
  35702. * An event triggered when active meshes evaluation is about to start
  35703. */
  35704. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35705. /**
  35706. * An event triggered when active meshes evaluation is done
  35707. */
  35708. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35709. /**
  35710. * An event triggered when particles rendering is about to start
  35711. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35712. */
  35713. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35714. /**
  35715. * An event triggered when particles rendering is done
  35716. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35717. */
  35718. onAfterParticlesRenderingObservable: Observable<Scene>;
  35719. /**
  35720. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35721. */
  35722. onDataLoadedObservable: Observable<Scene>;
  35723. /**
  35724. * An event triggered when a camera is created
  35725. */
  35726. onNewCameraAddedObservable: Observable<Camera>;
  35727. /**
  35728. * An event triggered when a camera is removed
  35729. */
  35730. onCameraRemovedObservable: Observable<Camera>;
  35731. /**
  35732. * An event triggered when a light is created
  35733. */
  35734. onNewLightAddedObservable: Observable<Light>;
  35735. /**
  35736. * An event triggered when a light is removed
  35737. */
  35738. onLightRemovedObservable: Observable<Light>;
  35739. /**
  35740. * An event triggered when a geometry is created
  35741. */
  35742. onNewGeometryAddedObservable: Observable<Geometry>;
  35743. /**
  35744. * An event triggered when a geometry is removed
  35745. */
  35746. onGeometryRemovedObservable: Observable<Geometry>;
  35747. /**
  35748. * An event triggered when a transform node is created
  35749. */
  35750. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35751. /**
  35752. * An event triggered when a transform node is removed
  35753. */
  35754. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35755. /**
  35756. * An event triggered when a mesh is created
  35757. */
  35758. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35759. /**
  35760. * An event triggered when a mesh is removed
  35761. */
  35762. onMeshRemovedObservable: Observable<AbstractMesh>;
  35763. /**
  35764. * An event triggered when a skeleton is created
  35765. */
  35766. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35767. /**
  35768. * An event triggered when a skeleton is removed
  35769. */
  35770. onSkeletonRemovedObservable: Observable<Skeleton>;
  35771. /**
  35772. * An event triggered when a material is created
  35773. */
  35774. onNewMaterialAddedObservable: Observable<Material>;
  35775. /**
  35776. * An event triggered when a material is removed
  35777. */
  35778. onMaterialRemovedObservable: Observable<Material>;
  35779. /**
  35780. * An event triggered when a texture is created
  35781. */
  35782. onNewTextureAddedObservable: Observable<BaseTexture>;
  35783. /**
  35784. * An event triggered when a texture is removed
  35785. */
  35786. onTextureRemovedObservable: Observable<BaseTexture>;
  35787. /**
  35788. * An event triggered when render targets are about to be rendered
  35789. * Can happen multiple times per frame.
  35790. */
  35791. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35792. /**
  35793. * An event triggered when render targets were rendered.
  35794. * Can happen multiple times per frame.
  35795. */
  35796. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35797. /**
  35798. * An event triggered before calculating deterministic simulation step
  35799. */
  35800. onBeforeStepObservable: Observable<Scene>;
  35801. /**
  35802. * An event triggered after calculating deterministic simulation step
  35803. */
  35804. onAfterStepObservable: Observable<Scene>;
  35805. /**
  35806. * An event triggered when the activeCamera property is updated
  35807. */
  35808. onActiveCameraChanged: Observable<Scene>;
  35809. /**
  35810. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35811. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35812. * 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)
  35813. */
  35814. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35815. /**
  35816. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35817. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35818. * 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)
  35819. */
  35820. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35821. /**
  35822. * This Observable will when a mesh has been imported into the scene.
  35823. */
  35824. onMeshImportedObservable: Observable<AbstractMesh>;
  35825. /**
  35826. * This Observable will when an animation file has been imported into the scene.
  35827. */
  35828. onAnimationFileImportedObservable: Observable<Scene>;
  35829. /**
  35830. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35831. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35832. */
  35833. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35834. /** @hidden */
  35835. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35836. /**
  35837. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35838. */
  35839. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35840. /**
  35841. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35842. */
  35843. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35844. /**
  35845. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35846. */
  35847. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35848. /** Callback called when a pointer move is detected */
  35849. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35850. /** Callback called when a pointer down is detected */
  35851. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35852. /** Callback called when a pointer up is detected */
  35853. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35854. /** Callback called when a pointer pick is detected */
  35855. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35856. /**
  35857. * 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).
  35858. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35859. */
  35860. onPrePointerObservable: Observable<PointerInfoPre>;
  35861. /**
  35862. * Observable event triggered each time an input event is received from the rendering canvas
  35863. */
  35864. onPointerObservable: Observable<PointerInfo>;
  35865. /**
  35866. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35867. */
  35868. get unTranslatedPointer(): Vector2;
  35869. /**
  35870. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35871. */
  35872. static get DragMovementThreshold(): number;
  35873. static set DragMovementThreshold(value: number);
  35874. /**
  35875. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35876. */
  35877. static get LongPressDelay(): number;
  35878. static set LongPressDelay(value: number);
  35879. /**
  35880. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35881. */
  35882. static get DoubleClickDelay(): number;
  35883. static set DoubleClickDelay(value: number);
  35884. /** If you need to check double click without raising a single click at first click, enable this flag */
  35885. static get ExclusiveDoubleClickMode(): boolean;
  35886. static set ExclusiveDoubleClickMode(value: boolean);
  35887. /** @hidden */
  35888. _mirroredCameraPosition: Nullable<Vector3>;
  35889. /**
  35890. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35891. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35892. */
  35893. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35894. /**
  35895. * Observable event triggered each time an keyboard event is received from the hosting window
  35896. */
  35897. onKeyboardObservable: Observable<KeyboardInfo>;
  35898. private _useRightHandedSystem;
  35899. /**
  35900. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35901. */
  35902. set useRightHandedSystem(value: boolean);
  35903. get useRightHandedSystem(): boolean;
  35904. private _timeAccumulator;
  35905. private _currentStepId;
  35906. private _currentInternalStep;
  35907. /**
  35908. * Sets the step Id used by deterministic lock step
  35909. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35910. * @param newStepId defines the step Id
  35911. */
  35912. setStepId(newStepId: number): void;
  35913. /**
  35914. * Gets the step Id used by deterministic lock step
  35915. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35916. * @returns the step Id
  35917. */
  35918. getStepId(): number;
  35919. /**
  35920. * Gets the internal step used by deterministic lock step
  35921. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35922. * @returns the internal step
  35923. */
  35924. getInternalStep(): number;
  35925. private _fogEnabled;
  35926. /**
  35927. * Gets or sets a boolean indicating if fog is enabled on this scene
  35928. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35929. * (Default is true)
  35930. */
  35931. set fogEnabled(value: boolean);
  35932. get fogEnabled(): boolean;
  35933. private _fogMode;
  35934. /**
  35935. * Gets or sets the fog mode to use
  35936. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35937. * | mode | value |
  35938. * | --- | --- |
  35939. * | FOGMODE_NONE | 0 |
  35940. * | FOGMODE_EXP | 1 |
  35941. * | FOGMODE_EXP2 | 2 |
  35942. * | FOGMODE_LINEAR | 3 |
  35943. */
  35944. set fogMode(value: number);
  35945. get fogMode(): number;
  35946. /**
  35947. * Gets or sets the fog color to use
  35948. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35949. * (Default is Color3(0.2, 0.2, 0.3))
  35950. */
  35951. fogColor: Color3;
  35952. /**
  35953. * Gets or sets the fog density to use
  35954. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35955. * (Default is 0.1)
  35956. */
  35957. fogDensity: number;
  35958. /**
  35959. * Gets or sets the fog start distance to use
  35960. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35961. * (Default is 0)
  35962. */
  35963. fogStart: number;
  35964. /**
  35965. * Gets or sets the fog end distance to use
  35966. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35967. * (Default is 1000)
  35968. */
  35969. fogEnd: number;
  35970. private _shadowsEnabled;
  35971. /**
  35972. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35973. */
  35974. set shadowsEnabled(value: boolean);
  35975. get shadowsEnabled(): boolean;
  35976. private _lightsEnabled;
  35977. /**
  35978. * Gets or sets a boolean indicating if lights are enabled on this scene
  35979. */
  35980. set lightsEnabled(value: boolean);
  35981. get lightsEnabled(): boolean;
  35982. /** All of the active cameras added to this scene. */
  35983. activeCameras: Camera[];
  35984. /** @hidden */
  35985. _activeCamera: Nullable<Camera>;
  35986. /** Gets or sets the current active camera */
  35987. get activeCamera(): Nullable<Camera>;
  35988. set activeCamera(value: Nullable<Camera>);
  35989. private _defaultMaterial;
  35990. /** The default material used on meshes when no material is affected */
  35991. get defaultMaterial(): Material;
  35992. /** The default material used on meshes when no material is affected */
  35993. set defaultMaterial(value: Material);
  35994. private _texturesEnabled;
  35995. /**
  35996. * Gets or sets a boolean indicating if textures are enabled on this scene
  35997. */
  35998. set texturesEnabled(value: boolean);
  35999. get texturesEnabled(): boolean;
  36000. /**
  36001. * Gets or sets a boolean indicating if particles are enabled on this scene
  36002. */
  36003. particlesEnabled: boolean;
  36004. /**
  36005. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36006. */
  36007. spritesEnabled: boolean;
  36008. private _skeletonsEnabled;
  36009. /**
  36010. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36011. */
  36012. set skeletonsEnabled(value: boolean);
  36013. get skeletonsEnabled(): boolean;
  36014. /**
  36015. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36016. */
  36017. lensFlaresEnabled: boolean;
  36018. /**
  36019. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36020. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36021. */
  36022. collisionsEnabled: boolean;
  36023. private _collisionCoordinator;
  36024. /** @hidden */
  36025. get collisionCoordinator(): ICollisionCoordinator;
  36026. /**
  36027. * Defines the gravity applied to this scene (used only for collisions)
  36028. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36029. */
  36030. gravity: Vector3;
  36031. /**
  36032. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36033. */
  36034. postProcessesEnabled: boolean;
  36035. /**
  36036. * The list of postprocesses added to the scene
  36037. */
  36038. postProcesses: PostProcess[];
  36039. /**
  36040. * Gets the current postprocess manager
  36041. */
  36042. postProcessManager: PostProcessManager;
  36043. /**
  36044. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36045. */
  36046. renderTargetsEnabled: boolean;
  36047. /**
  36048. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36049. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36050. */
  36051. dumpNextRenderTargets: boolean;
  36052. /**
  36053. * The list of user defined render targets added to the scene
  36054. */
  36055. customRenderTargets: RenderTargetTexture[];
  36056. /**
  36057. * Defines if texture loading must be delayed
  36058. * If true, textures will only be loaded when they need to be rendered
  36059. */
  36060. useDelayedTextureLoading: boolean;
  36061. /**
  36062. * Gets the list of meshes imported to the scene through SceneLoader
  36063. */
  36064. importedMeshesFiles: String[];
  36065. /**
  36066. * Gets or sets a boolean indicating if probes are enabled on this scene
  36067. */
  36068. probesEnabled: boolean;
  36069. /**
  36070. * Gets or sets the current offline provider to use to store scene data
  36071. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36072. */
  36073. offlineProvider: IOfflineProvider;
  36074. /**
  36075. * Gets or sets the action manager associated with the scene
  36076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36077. */
  36078. actionManager: AbstractActionManager;
  36079. private _meshesForIntersections;
  36080. /**
  36081. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36082. */
  36083. proceduralTexturesEnabled: boolean;
  36084. private _engine;
  36085. private _totalVertices;
  36086. /** @hidden */
  36087. _activeIndices: PerfCounter;
  36088. /** @hidden */
  36089. _activeParticles: PerfCounter;
  36090. /** @hidden */
  36091. _activeBones: PerfCounter;
  36092. private _animationRatio;
  36093. /** @hidden */
  36094. _animationTimeLast: number;
  36095. /** @hidden */
  36096. _animationTime: number;
  36097. /**
  36098. * Gets or sets a general scale for animation speed
  36099. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36100. */
  36101. animationTimeScale: number;
  36102. /** @hidden */
  36103. _cachedMaterial: Nullable<Material>;
  36104. /** @hidden */
  36105. _cachedEffect: Nullable<Effect>;
  36106. /** @hidden */
  36107. _cachedVisibility: Nullable<number>;
  36108. private _renderId;
  36109. private _frameId;
  36110. private _executeWhenReadyTimeoutId;
  36111. private _intermediateRendering;
  36112. private _viewUpdateFlag;
  36113. private _projectionUpdateFlag;
  36114. /** @hidden */
  36115. _toBeDisposed: Nullable<IDisposable>[];
  36116. private _activeRequests;
  36117. /** @hidden */
  36118. _pendingData: any[];
  36119. private _isDisposed;
  36120. /**
  36121. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36122. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36123. */
  36124. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36125. private _activeMeshes;
  36126. private _processedMaterials;
  36127. private _renderTargets;
  36128. /** @hidden */
  36129. _activeParticleSystems: SmartArray<IParticleSystem>;
  36130. private _activeSkeletons;
  36131. private _softwareSkinnedMeshes;
  36132. private _renderingManager;
  36133. /** @hidden */
  36134. _activeAnimatables: Animatable[];
  36135. private _transformMatrix;
  36136. private _sceneUbo;
  36137. /** @hidden */
  36138. _viewMatrix: Matrix;
  36139. private _projectionMatrix;
  36140. /** @hidden */
  36141. _forcedViewPosition: Nullable<Vector3>;
  36142. /** @hidden */
  36143. _frustumPlanes: Plane[];
  36144. /**
  36145. * Gets the list of frustum planes (built from the active camera)
  36146. */
  36147. get frustumPlanes(): Plane[];
  36148. /**
  36149. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36150. * This is useful if there are more lights that the maximum simulteanous authorized
  36151. */
  36152. requireLightSorting: boolean;
  36153. /** @hidden */
  36154. readonly useMaterialMeshMap: boolean;
  36155. /** @hidden */
  36156. readonly useClonedMeshMap: boolean;
  36157. private _externalData;
  36158. private _uid;
  36159. /**
  36160. * @hidden
  36161. * Backing store of defined scene components.
  36162. */
  36163. _components: ISceneComponent[];
  36164. /**
  36165. * @hidden
  36166. * Backing store of defined scene components.
  36167. */
  36168. _serializableComponents: ISceneSerializableComponent[];
  36169. /**
  36170. * List of components to register on the next registration step.
  36171. */
  36172. private _transientComponents;
  36173. /**
  36174. * Registers the transient components if needed.
  36175. */
  36176. private _registerTransientComponents;
  36177. /**
  36178. * @hidden
  36179. * Add a component to the scene.
  36180. * Note that the ccomponent could be registered on th next frame if this is called after
  36181. * the register component stage.
  36182. * @param component Defines the component to add to the scene
  36183. */
  36184. _addComponent(component: ISceneComponent): void;
  36185. /**
  36186. * @hidden
  36187. * Gets a component from the scene.
  36188. * @param name defines the name of the component to retrieve
  36189. * @returns the component or null if not present
  36190. */
  36191. _getComponent(name: string): Nullable<ISceneComponent>;
  36192. /**
  36193. * @hidden
  36194. * Defines the actions happening before camera updates.
  36195. */
  36196. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36197. /**
  36198. * @hidden
  36199. * Defines the actions happening before clear the canvas.
  36200. */
  36201. _beforeClearStage: Stage<SimpleStageAction>;
  36202. /**
  36203. * @hidden
  36204. * Defines the actions when collecting render targets for the frame.
  36205. */
  36206. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36207. /**
  36208. * @hidden
  36209. * Defines the actions happening for one camera in the frame.
  36210. */
  36211. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36212. /**
  36213. * @hidden
  36214. * Defines the actions happening during the per mesh ready checks.
  36215. */
  36216. _isReadyForMeshStage: Stage<MeshStageAction>;
  36217. /**
  36218. * @hidden
  36219. * Defines the actions happening before evaluate active mesh checks.
  36220. */
  36221. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36222. /**
  36223. * @hidden
  36224. * Defines the actions happening during the evaluate sub mesh checks.
  36225. */
  36226. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36227. /**
  36228. * @hidden
  36229. * Defines the actions happening during the active mesh stage.
  36230. */
  36231. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36232. /**
  36233. * @hidden
  36234. * Defines the actions happening during the per camera render target step.
  36235. */
  36236. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36237. /**
  36238. * @hidden
  36239. * Defines the actions happening just before the active camera is drawing.
  36240. */
  36241. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36242. /**
  36243. * @hidden
  36244. * Defines the actions happening just before a render target is drawing.
  36245. */
  36246. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36247. /**
  36248. * @hidden
  36249. * Defines the actions happening just before a rendering group is drawing.
  36250. */
  36251. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36252. /**
  36253. * @hidden
  36254. * Defines the actions happening just before a mesh is drawing.
  36255. */
  36256. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36257. /**
  36258. * @hidden
  36259. * Defines the actions happening just after a mesh has been drawn.
  36260. */
  36261. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36262. /**
  36263. * @hidden
  36264. * Defines the actions happening just after a rendering group has been drawn.
  36265. */
  36266. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36267. /**
  36268. * @hidden
  36269. * Defines the actions happening just after the active camera has been drawn.
  36270. */
  36271. _afterCameraDrawStage: Stage<CameraStageAction>;
  36272. /**
  36273. * @hidden
  36274. * Defines the actions happening just after a render target has been drawn.
  36275. */
  36276. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36277. /**
  36278. * @hidden
  36279. * Defines the actions happening just after rendering all cameras and computing intersections.
  36280. */
  36281. _afterRenderStage: Stage<SimpleStageAction>;
  36282. /**
  36283. * @hidden
  36284. * Defines the actions happening when a pointer move event happens.
  36285. */
  36286. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36287. /**
  36288. * @hidden
  36289. * Defines the actions happening when a pointer down event happens.
  36290. */
  36291. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36292. /**
  36293. * @hidden
  36294. * Defines the actions happening when a pointer up event happens.
  36295. */
  36296. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36297. /**
  36298. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36299. */
  36300. private geometriesByUniqueId;
  36301. /**
  36302. * Creates a new Scene
  36303. * @param engine defines the engine to use to render this scene
  36304. * @param options defines the scene options
  36305. */
  36306. constructor(engine: Engine, options?: SceneOptions);
  36307. /**
  36308. * Gets a string idenfifying the name of the class
  36309. * @returns "Scene" string
  36310. */
  36311. getClassName(): string;
  36312. private _defaultMeshCandidates;
  36313. /**
  36314. * @hidden
  36315. */
  36316. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36317. private _defaultSubMeshCandidates;
  36318. /**
  36319. * @hidden
  36320. */
  36321. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36322. /**
  36323. * Sets the default candidate providers for the scene.
  36324. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36325. * and getCollidingSubMeshCandidates to their default function
  36326. */
  36327. setDefaultCandidateProviders(): void;
  36328. /**
  36329. * Gets the mesh that is currently under the pointer
  36330. */
  36331. get meshUnderPointer(): Nullable<AbstractMesh>;
  36332. /**
  36333. * Gets or sets the current on-screen X position of the pointer
  36334. */
  36335. get pointerX(): number;
  36336. set pointerX(value: number);
  36337. /**
  36338. * Gets or sets the current on-screen Y position of the pointer
  36339. */
  36340. get pointerY(): number;
  36341. set pointerY(value: number);
  36342. /**
  36343. * Gets the cached material (ie. the latest rendered one)
  36344. * @returns the cached material
  36345. */
  36346. getCachedMaterial(): Nullable<Material>;
  36347. /**
  36348. * Gets the cached effect (ie. the latest rendered one)
  36349. * @returns the cached effect
  36350. */
  36351. getCachedEffect(): Nullable<Effect>;
  36352. /**
  36353. * Gets the cached visibility state (ie. the latest rendered one)
  36354. * @returns the cached visibility state
  36355. */
  36356. getCachedVisibility(): Nullable<number>;
  36357. /**
  36358. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36359. * @param material defines the current material
  36360. * @param effect defines the current effect
  36361. * @param visibility defines the current visibility state
  36362. * @returns true if one parameter is not cached
  36363. */
  36364. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36365. /**
  36366. * Gets the engine associated with the scene
  36367. * @returns an Engine
  36368. */
  36369. getEngine(): Engine;
  36370. /**
  36371. * Gets the total number of vertices rendered per frame
  36372. * @returns the total number of vertices rendered per frame
  36373. */
  36374. getTotalVertices(): number;
  36375. /**
  36376. * Gets the performance counter for total vertices
  36377. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36378. */
  36379. get totalVerticesPerfCounter(): PerfCounter;
  36380. /**
  36381. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36382. * @returns the total number of active indices rendered per frame
  36383. */
  36384. getActiveIndices(): number;
  36385. /**
  36386. * Gets the performance counter for active indices
  36387. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36388. */
  36389. get totalActiveIndicesPerfCounter(): PerfCounter;
  36390. /**
  36391. * Gets the total number of active particles rendered per frame
  36392. * @returns the total number of active particles rendered per frame
  36393. */
  36394. getActiveParticles(): number;
  36395. /**
  36396. * Gets the performance counter for active particles
  36397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36398. */
  36399. get activeParticlesPerfCounter(): PerfCounter;
  36400. /**
  36401. * Gets the total number of active bones rendered per frame
  36402. * @returns the total number of active bones rendered per frame
  36403. */
  36404. getActiveBones(): number;
  36405. /**
  36406. * Gets the performance counter for active bones
  36407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36408. */
  36409. get activeBonesPerfCounter(): PerfCounter;
  36410. /**
  36411. * Gets the array of active meshes
  36412. * @returns an array of AbstractMesh
  36413. */
  36414. getActiveMeshes(): SmartArray<AbstractMesh>;
  36415. /**
  36416. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36417. * @returns a number
  36418. */
  36419. getAnimationRatio(): number;
  36420. /**
  36421. * Gets an unique Id for the current render phase
  36422. * @returns a number
  36423. */
  36424. getRenderId(): number;
  36425. /**
  36426. * Gets an unique Id for the current frame
  36427. * @returns a number
  36428. */
  36429. getFrameId(): number;
  36430. /** Call this function if you want to manually increment the render Id*/
  36431. incrementRenderId(): void;
  36432. private _createUbo;
  36433. /**
  36434. * Use this method to simulate a pointer move on a mesh
  36435. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36436. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36437. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36438. * @returns the current scene
  36439. */
  36440. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36441. /**
  36442. * Use this method to simulate a pointer down on a mesh
  36443. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36444. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36445. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36446. * @returns the current scene
  36447. */
  36448. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36449. /**
  36450. * Use this method to simulate a pointer up on a mesh
  36451. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36452. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36453. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36454. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36455. * @returns the current scene
  36456. */
  36457. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36458. /**
  36459. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36460. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36461. * @returns true if the pointer was captured
  36462. */
  36463. isPointerCaptured(pointerId?: number): boolean;
  36464. /**
  36465. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36466. * @param attachUp defines if you want to attach events to pointerup
  36467. * @param attachDown defines if you want to attach events to pointerdown
  36468. * @param attachMove defines if you want to attach events to pointermove
  36469. */
  36470. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36471. /** Detaches all event handlers*/
  36472. detachControl(): void;
  36473. /**
  36474. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36475. * Delay loaded resources are not taking in account
  36476. * @return true if all required resources are ready
  36477. */
  36478. isReady(): boolean;
  36479. /** Resets all cached information relative to material (including effect and visibility) */
  36480. resetCachedMaterial(): void;
  36481. /**
  36482. * Registers a function to be called before every frame render
  36483. * @param func defines the function to register
  36484. */
  36485. registerBeforeRender(func: () => void): void;
  36486. /**
  36487. * Unregisters a function called before every frame render
  36488. * @param func defines the function to unregister
  36489. */
  36490. unregisterBeforeRender(func: () => void): void;
  36491. /**
  36492. * Registers a function to be called after every frame render
  36493. * @param func defines the function to register
  36494. */
  36495. registerAfterRender(func: () => void): void;
  36496. /**
  36497. * Unregisters a function called after every frame render
  36498. * @param func defines the function to unregister
  36499. */
  36500. unregisterAfterRender(func: () => void): void;
  36501. private _executeOnceBeforeRender;
  36502. /**
  36503. * The provided function will run before render once and will be disposed afterwards.
  36504. * A timeout delay can be provided so that the function will be executed in N ms.
  36505. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36506. * @param func The function to be executed.
  36507. * @param timeout optional delay in ms
  36508. */
  36509. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36510. /** @hidden */
  36511. _addPendingData(data: any): void;
  36512. /** @hidden */
  36513. _removePendingData(data: any): void;
  36514. /**
  36515. * Returns the number of items waiting to be loaded
  36516. * @returns the number of items waiting to be loaded
  36517. */
  36518. getWaitingItemsCount(): number;
  36519. /**
  36520. * Returns a boolean indicating if the scene is still loading data
  36521. */
  36522. get isLoading(): boolean;
  36523. /**
  36524. * Registers a function to be executed when the scene is ready
  36525. * @param {Function} func - the function to be executed
  36526. */
  36527. executeWhenReady(func: () => void): void;
  36528. /**
  36529. * Returns a promise that resolves when the scene is ready
  36530. * @returns A promise that resolves when the scene is ready
  36531. */
  36532. whenReadyAsync(): Promise<void>;
  36533. /** @hidden */
  36534. _checkIsReady(): void;
  36535. /**
  36536. * Gets all animatable attached to the scene
  36537. */
  36538. get animatables(): Animatable[];
  36539. /**
  36540. * Resets the last animation time frame.
  36541. * Useful to override when animations start running when loading a scene for the first time.
  36542. */
  36543. resetLastAnimationTimeFrame(): void;
  36544. /**
  36545. * Gets the current view matrix
  36546. * @returns a Matrix
  36547. */
  36548. getViewMatrix(): Matrix;
  36549. /**
  36550. * Gets the current projection matrix
  36551. * @returns a Matrix
  36552. */
  36553. getProjectionMatrix(): Matrix;
  36554. /**
  36555. * Gets the current transform matrix
  36556. * @returns a Matrix made of View * Projection
  36557. */
  36558. getTransformMatrix(): Matrix;
  36559. /**
  36560. * Sets the current transform matrix
  36561. * @param viewL defines the View matrix to use
  36562. * @param projectionL defines the Projection matrix to use
  36563. * @param viewR defines the right View matrix to use (if provided)
  36564. * @param projectionR defines the right Projection matrix to use (if provided)
  36565. */
  36566. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36567. /**
  36568. * Gets the uniform buffer used to store scene data
  36569. * @returns a UniformBuffer
  36570. */
  36571. getSceneUniformBuffer(): UniformBuffer;
  36572. /**
  36573. * Gets an unique (relatively to the current scene) Id
  36574. * @returns an unique number for the scene
  36575. */
  36576. getUniqueId(): number;
  36577. /**
  36578. * Add a mesh to the list of scene's meshes
  36579. * @param newMesh defines the mesh to add
  36580. * @param recursive if all child meshes should also be added to the scene
  36581. */
  36582. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36583. /**
  36584. * Remove a mesh for the list of scene's meshes
  36585. * @param toRemove defines the mesh to remove
  36586. * @param recursive if all child meshes should also be removed from the scene
  36587. * @returns the index where the mesh was in the mesh list
  36588. */
  36589. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36590. /**
  36591. * Add a transform node to the list of scene's transform nodes
  36592. * @param newTransformNode defines the transform node to add
  36593. */
  36594. addTransformNode(newTransformNode: TransformNode): void;
  36595. /**
  36596. * Remove a transform node for the list of scene's transform nodes
  36597. * @param toRemove defines the transform node to remove
  36598. * @returns the index where the transform node was in the transform node list
  36599. */
  36600. removeTransformNode(toRemove: TransformNode): number;
  36601. /**
  36602. * Remove a skeleton for the list of scene's skeletons
  36603. * @param toRemove defines the skeleton to remove
  36604. * @returns the index where the skeleton was in the skeleton list
  36605. */
  36606. removeSkeleton(toRemove: Skeleton): number;
  36607. /**
  36608. * Remove a morph target for the list of scene's morph targets
  36609. * @param toRemove defines the morph target to remove
  36610. * @returns the index where the morph target was in the morph target list
  36611. */
  36612. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36613. /**
  36614. * Remove a light for the list of scene's lights
  36615. * @param toRemove defines the light to remove
  36616. * @returns the index where the light was in the light list
  36617. */
  36618. removeLight(toRemove: Light): number;
  36619. /**
  36620. * Remove a camera for the list of scene's cameras
  36621. * @param toRemove defines the camera to remove
  36622. * @returns the index where the camera was in the camera list
  36623. */
  36624. removeCamera(toRemove: Camera): number;
  36625. /**
  36626. * Remove a particle system for the list of scene's particle systems
  36627. * @param toRemove defines the particle system to remove
  36628. * @returns the index where the particle system was in the particle system list
  36629. */
  36630. removeParticleSystem(toRemove: IParticleSystem): number;
  36631. /**
  36632. * Remove a animation for the list of scene's animations
  36633. * @param toRemove defines the animation to remove
  36634. * @returns the index where the animation was in the animation list
  36635. */
  36636. removeAnimation(toRemove: Animation): number;
  36637. /**
  36638. * Will stop the animation of the given target
  36639. * @param target - the target
  36640. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36641. * @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)
  36642. */
  36643. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36644. /**
  36645. * Removes the given animation group from this scene.
  36646. * @param toRemove The animation group to remove
  36647. * @returns The index of the removed animation group
  36648. */
  36649. removeAnimationGroup(toRemove: AnimationGroup): number;
  36650. /**
  36651. * Removes the given multi-material from this scene.
  36652. * @param toRemove The multi-material to remove
  36653. * @returns The index of the removed multi-material
  36654. */
  36655. removeMultiMaterial(toRemove: MultiMaterial): number;
  36656. /**
  36657. * Removes the given material from this scene.
  36658. * @param toRemove The material to remove
  36659. * @returns The index of the removed material
  36660. */
  36661. removeMaterial(toRemove: Material): number;
  36662. /**
  36663. * Removes the given action manager from this scene.
  36664. * @param toRemove The action manager to remove
  36665. * @returns The index of the removed action manager
  36666. */
  36667. removeActionManager(toRemove: AbstractActionManager): number;
  36668. /**
  36669. * Removes the given texture from this scene.
  36670. * @param toRemove The texture to remove
  36671. * @returns The index of the removed texture
  36672. */
  36673. removeTexture(toRemove: BaseTexture): number;
  36674. /**
  36675. * Adds the given light to this scene
  36676. * @param newLight The light to add
  36677. */
  36678. addLight(newLight: Light): void;
  36679. /**
  36680. * Sorts the list list based on light priorities
  36681. */
  36682. sortLightsByPriority(): void;
  36683. /**
  36684. * Adds the given camera to this scene
  36685. * @param newCamera The camera to add
  36686. */
  36687. addCamera(newCamera: Camera): void;
  36688. /**
  36689. * Adds the given skeleton to this scene
  36690. * @param newSkeleton The skeleton to add
  36691. */
  36692. addSkeleton(newSkeleton: Skeleton): void;
  36693. /**
  36694. * Adds the given particle system to this scene
  36695. * @param newParticleSystem The particle system to add
  36696. */
  36697. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36698. /**
  36699. * Adds the given animation to this scene
  36700. * @param newAnimation The animation to add
  36701. */
  36702. addAnimation(newAnimation: Animation): void;
  36703. /**
  36704. * Adds the given animation group to this scene.
  36705. * @param newAnimationGroup The animation group to add
  36706. */
  36707. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36708. /**
  36709. * Adds the given multi-material to this scene
  36710. * @param newMultiMaterial The multi-material to add
  36711. */
  36712. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36713. /**
  36714. * Adds the given material to this scene
  36715. * @param newMaterial The material to add
  36716. */
  36717. addMaterial(newMaterial: Material): void;
  36718. /**
  36719. * Adds the given morph target to this scene
  36720. * @param newMorphTargetManager The morph target to add
  36721. */
  36722. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36723. /**
  36724. * Adds the given geometry to this scene
  36725. * @param newGeometry The geometry to add
  36726. */
  36727. addGeometry(newGeometry: Geometry): void;
  36728. /**
  36729. * Adds the given action manager to this scene
  36730. * @param newActionManager The action manager to add
  36731. */
  36732. addActionManager(newActionManager: AbstractActionManager): void;
  36733. /**
  36734. * Adds the given texture to this scene.
  36735. * @param newTexture The texture to add
  36736. */
  36737. addTexture(newTexture: BaseTexture): void;
  36738. /**
  36739. * Switch active camera
  36740. * @param newCamera defines the new active camera
  36741. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36742. */
  36743. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36744. /**
  36745. * sets the active camera of the scene using its ID
  36746. * @param id defines the camera's ID
  36747. * @return the new active camera or null if none found.
  36748. */
  36749. setActiveCameraByID(id: string): Nullable<Camera>;
  36750. /**
  36751. * sets the active camera of the scene using its name
  36752. * @param name defines the camera's name
  36753. * @returns the new active camera or null if none found.
  36754. */
  36755. setActiveCameraByName(name: string): Nullable<Camera>;
  36756. /**
  36757. * get an animation group using its name
  36758. * @param name defines the material's name
  36759. * @return the animation group or null if none found.
  36760. */
  36761. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36762. /**
  36763. * Get a material using its unique id
  36764. * @param uniqueId defines the material's unique id
  36765. * @return the material or null if none found.
  36766. */
  36767. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36768. /**
  36769. * get a material using its id
  36770. * @param id defines the material's ID
  36771. * @return the material or null if none found.
  36772. */
  36773. getMaterialByID(id: string): Nullable<Material>;
  36774. /**
  36775. * Gets a the last added material using a given id
  36776. * @param id defines the material's ID
  36777. * @return the last material with the given id or null if none found.
  36778. */
  36779. getLastMaterialByID(id: string): Nullable<Material>;
  36780. /**
  36781. * Gets a material using its name
  36782. * @param name defines the material's name
  36783. * @return the material or null if none found.
  36784. */
  36785. getMaterialByName(name: string): Nullable<Material>;
  36786. /**
  36787. * Get a texture using its unique id
  36788. * @param uniqueId defines the texture's unique id
  36789. * @return the texture or null if none found.
  36790. */
  36791. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36792. /**
  36793. * Gets a camera using its id
  36794. * @param id defines the id to look for
  36795. * @returns the camera or null if not found
  36796. */
  36797. getCameraByID(id: string): Nullable<Camera>;
  36798. /**
  36799. * Gets a camera using its unique id
  36800. * @param uniqueId defines the unique id to look for
  36801. * @returns the camera or null if not found
  36802. */
  36803. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36804. /**
  36805. * Gets a camera using its name
  36806. * @param name defines the camera's name
  36807. * @return the camera or null if none found.
  36808. */
  36809. getCameraByName(name: string): Nullable<Camera>;
  36810. /**
  36811. * Gets a bone using its id
  36812. * @param id defines the bone's id
  36813. * @return the bone or null if not found
  36814. */
  36815. getBoneByID(id: string): Nullable<Bone>;
  36816. /**
  36817. * Gets a bone using its id
  36818. * @param name defines the bone's name
  36819. * @return the bone or null if not found
  36820. */
  36821. getBoneByName(name: string): Nullable<Bone>;
  36822. /**
  36823. * Gets a light node using its name
  36824. * @param name defines the the light's name
  36825. * @return the light or null if none found.
  36826. */
  36827. getLightByName(name: string): Nullable<Light>;
  36828. /**
  36829. * Gets a light node using its id
  36830. * @param id defines the light's id
  36831. * @return the light or null if none found.
  36832. */
  36833. getLightByID(id: string): Nullable<Light>;
  36834. /**
  36835. * Gets a light node using its scene-generated unique ID
  36836. * @param uniqueId defines the light's unique id
  36837. * @return the light or null if none found.
  36838. */
  36839. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36840. /**
  36841. * Gets a particle system by id
  36842. * @param id defines the particle system id
  36843. * @return the corresponding system or null if none found
  36844. */
  36845. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36846. /**
  36847. * Gets a geometry using its ID
  36848. * @param id defines the geometry's id
  36849. * @return the geometry or null if none found.
  36850. */
  36851. getGeometryByID(id: string): Nullable<Geometry>;
  36852. private _getGeometryByUniqueID;
  36853. /**
  36854. * Add a new geometry to this scene
  36855. * @param geometry defines the geometry to be added to the scene.
  36856. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36857. * @return a boolean defining if the geometry was added or not
  36858. */
  36859. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36860. /**
  36861. * Removes an existing geometry
  36862. * @param geometry defines the geometry to be removed from the scene
  36863. * @return a boolean defining if the geometry was removed or not
  36864. */
  36865. removeGeometry(geometry: Geometry): boolean;
  36866. /**
  36867. * Gets the list of geometries attached to the scene
  36868. * @returns an array of Geometry
  36869. */
  36870. getGeometries(): Geometry[];
  36871. /**
  36872. * Gets the first added mesh found of a given ID
  36873. * @param id defines the id to search for
  36874. * @return the mesh found or null if not found at all
  36875. */
  36876. getMeshByID(id: string): Nullable<AbstractMesh>;
  36877. /**
  36878. * Gets a list of meshes using their id
  36879. * @param id defines the id to search for
  36880. * @returns a list of meshes
  36881. */
  36882. getMeshesByID(id: string): Array<AbstractMesh>;
  36883. /**
  36884. * Gets the first added transform node found of a given ID
  36885. * @param id defines the id to search for
  36886. * @return the found transform node or null if not found at all.
  36887. */
  36888. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36889. /**
  36890. * Gets a transform node with its auto-generated unique id
  36891. * @param uniqueId efines the unique id to search for
  36892. * @return the found transform node or null if not found at all.
  36893. */
  36894. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36895. /**
  36896. * Gets a list of transform nodes using their id
  36897. * @param id defines the id to search for
  36898. * @returns a list of transform nodes
  36899. */
  36900. getTransformNodesByID(id: string): Array<TransformNode>;
  36901. /**
  36902. * Gets a mesh with its auto-generated unique id
  36903. * @param uniqueId defines the unique id to search for
  36904. * @return the found mesh or null if not found at all.
  36905. */
  36906. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36907. /**
  36908. * Gets a the last added mesh using a given id
  36909. * @param id defines the id to search for
  36910. * @return the found mesh or null if not found at all.
  36911. */
  36912. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36913. /**
  36914. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36915. * @param id defines the id to search for
  36916. * @return the found node or null if not found at all
  36917. */
  36918. getLastEntryByID(id: string): Nullable<Node>;
  36919. /**
  36920. * Gets a node (Mesh, Camera, Light) using a given id
  36921. * @param id defines the id to search for
  36922. * @return the found node or null if not found at all
  36923. */
  36924. getNodeByID(id: string): Nullable<Node>;
  36925. /**
  36926. * Gets a node (Mesh, Camera, Light) using a given name
  36927. * @param name defines the name to search for
  36928. * @return the found node or null if not found at all.
  36929. */
  36930. getNodeByName(name: string): Nullable<Node>;
  36931. /**
  36932. * Gets a mesh using a given name
  36933. * @param name defines the name to search for
  36934. * @return the found mesh or null if not found at all.
  36935. */
  36936. getMeshByName(name: string): Nullable<AbstractMesh>;
  36937. /**
  36938. * Gets a transform node using a given name
  36939. * @param name defines the name to search for
  36940. * @return the found transform node or null if not found at all.
  36941. */
  36942. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36943. /**
  36944. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36945. * @param id defines the id to search for
  36946. * @return the found skeleton or null if not found at all.
  36947. */
  36948. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36949. /**
  36950. * Gets a skeleton using a given auto generated unique id
  36951. * @param uniqueId defines the unique id to search for
  36952. * @return the found skeleton or null if not found at all.
  36953. */
  36954. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36955. /**
  36956. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36957. * @param id defines the id to search for
  36958. * @return the found skeleton or null if not found at all.
  36959. */
  36960. getSkeletonById(id: string): Nullable<Skeleton>;
  36961. /**
  36962. * Gets a skeleton using a given name
  36963. * @param name defines the name to search for
  36964. * @return the found skeleton or null if not found at all.
  36965. */
  36966. getSkeletonByName(name: string): Nullable<Skeleton>;
  36967. /**
  36968. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36969. * @param id defines the id to search for
  36970. * @return the found morph target manager or null if not found at all.
  36971. */
  36972. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36973. /**
  36974. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36975. * @param id defines the id to search for
  36976. * @return the found morph target or null if not found at all.
  36977. */
  36978. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36979. /**
  36980. * Gets a boolean indicating if the given mesh is active
  36981. * @param mesh defines the mesh to look for
  36982. * @returns true if the mesh is in the active list
  36983. */
  36984. isActiveMesh(mesh: AbstractMesh): boolean;
  36985. /**
  36986. * Return a unique id as a string which can serve as an identifier for the scene
  36987. */
  36988. get uid(): string;
  36989. /**
  36990. * Add an externaly attached data from its key.
  36991. * This method call will fail and return false, if such key already exists.
  36992. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36993. * @param key the unique key that identifies the data
  36994. * @param data the data object to associate to the key for this Engine instance
  36995. * @return true if no such key were already present and the data was added successfully, false otherwise
  36996. */
  36997. addExternalData<T>(key: string, data: T): boolean;
  36998. /**
  36999. * Get an externaly attached data from its key
  37000. * @param key the unique key that identifies the data
  37001. * @return the associated data, if present (can be null), or undefined if not present
  37002. */
  37003. getExternalData<T>(key: string): Nullable<T>;
  37004. /**
  37005. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37006. * @param key the unique key that identifies the data
  37007. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37008. * @return the associated data, can be null if the factory returned null.
  37009. */
  37010. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37011. /**
  37012. * Remove an externaly attached data from the Engine instance
  37013. * @param key the unique key that identifies the data
  37014. * @return true if the data was successfully removed, false if it doesn't exist
  37015. */
  37016. removeExternalData(key: string): boolean;
  37017. private _evaluateSubMesh;
  37018. /**
  37019. * Clear the processed materials smart array preventing retention point in material dispose.
  37020. */
  37021. freeProcessedMaterials(): void;
  37022. private _preventFreeActiveMeshesAndRenderingGroups;
  37023. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37024. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37025. * when disposing several meshes in a row or a hierarchy of meshes.
  37026. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37027. */
  37028. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37029. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37030. /**
  37031. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37032. */
  37033. freeActiveMeshes(): void;
  37034. /**
  37035. * Clear the info related to rendering groups preventing retention points during dispose.
  37036. */
  37037. freeRenderingGroups(): void;
  37038. /** @hidden */
  37039. _isInIntermediateRendering(): boolean;
  37040. /**
  37041. * Lambda returning the list of potentially active meshes.
  37042. */
  37043. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37044. /**
  37045. * Lambda returning the list of potentially active sub meshes.
  37046. */
  37047. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37048. /**
  37049. * Lambda returning the list of potentially intersecting sub meshes.
  37050. */
  37051. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37052. /**
  37053. * Lambda returning the list of potentially colliding sub meshes.
  37054. */
  37055. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37056. private _activeMeshesFrozen;
  37057. private _skipEvaluateActiveMeshesCompletely;
  37058. /**
  37059. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37060. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37061. * @returns the current scene
  37062. */
  37063. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37064. /**
  37065. * Use this function to restart evaluating active meshes on every frame
  37066. * @returns the current scene
  37067. */
  37068. unfreezeActiveMeshes(): Scene;
  37069. private _evaluateActiveMeshes;
  37070. private _activeMesh;
  37071. /**
  37072. * Update the transform matrix to update from the current active camera
  37073. * @param force defines a boolean used to force the update even if cache is up to date
  37074. */
  37075. updateTransformMatrix(force?: boolean): void;
  37076. private _bindFrameBuffer;
  37077. /** @hidden */
  37078. _allowPostProcessClearColor: boolean;
  37079. /** @hidden */
  37080. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37081. private _processSubCameras;
  37082. private _checkIntersections;
  37083. /** @hidden */
  37084. _advancePhysicsEngineStep(step: number): void;
  37085. /**
  37086. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37087. */
  37088. getDeterministicFrameTime: () => number;
  37089. /** @hidden */
  37090. _animate(): void;
  37091. /** Execute all animations (for a frame) */
  37092. animate(): void;
  37093. /**
  37094. * Render the scene
  37095. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37096. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37097. */
  37098. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37099. /**
  37100. * Freeze all materials
  37101. * A frozen material will not be updatable but should be faster to render
  37102. */
  37103. freezeMaterials(): void;
  37104. /**
  37105. * Unfreeze all materials
  37106. * A frozen material will not be updatable but should be faster to render
  37107. */
  37108. unfreezeMaterials(): void;
  37109. /**
  37110. * Releases all held ressources
  37111. */
  37112. dispose(): void;
  37113. /**
  37114. * Gets if the scene is already disposed
  37115. */
  37116. get isDisposed(): boolean;
  37117. /**
  37118. * Call this function to reduce memory footprint of the scene.
  37119. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37120. */
  37121. clearCachedVertexData(): void;
  37122. /**
  37123. * This function will remove the local cached buffer data from texture.
  37124. * It will save memory but will prevent the texture from being rebuilt
  37125. */
  37126. cleanCachedTextureBuffer(): void;
  37127. /**
  37128. * Get the world extend vectors with an optional filter
  37129. *
  37130. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37131. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37132. */
  37133. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37134. min: Vector3;
  37135. max: Vector3;
  37136. };
  37137. /**
  37138. * Creates a ray that can be used to pick in the scene
  37139. * @param x defines the x coordinate of the origin (on-screen)
  37140. * @param y defines the y coordinate of the origin (on-screen)
  37141. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37142. * @param camera defines the camera to use for the picking
  37143. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37144. * @returns a Ray
  37145. */
  37146. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37147. /**
  37148. * Creates a ray that can be used to pick in the scene
  37149. * @param x defines the x coordinate of the origin (on-screen)
  37150. * @param y defines the y coordinate of the origin (on-screen)
  37151. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37152. * @param result defines the ray where to store the picking ray
  37153. * @param camera defines the camera to use for the picking
  37154. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37155. * @returns the current scene
  37156. */
  37157. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37158. /**
  37159. * Creates a ray that can be used to pick in the scene
  37160. * @param x defines the x coordinate of the origin (on-screen)
  37161. * @param y defines the y coordinate of the origin (on-screen)
  37162. * @param camera defines the camera to use for the picking
  37163. * @returns a Ray
  37164. */
  37165. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37166. /**
  37167. * Creates a ray that can be used to pick in the scene
  37168. * @param x defines the x coordinate of the origin (on-screen)
  37169. * @param y defines the y coordinate of the origin (on-screen)
  37170. * @param result defines the ray where to store the picking ray
  37171. * @param camera defines the camera to use for the picking
  37172. * @returns the current scene
  37173. */
  37174. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37175. /** Launch a ray to try to pick a mesh in the scene
  37176. * @param x position on screen
  37177. * @param y position on screen
  37178. * @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
  37179. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37180. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37181. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37182. * @returns a PickingInfo
  37183. */
  37184. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37185. /** Use the given ray to pick a mesh in the scene
  37186. * @param ray The ray to use to pick meshes
  37187. * @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
  37188. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37189. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37190. * @returns a PickingInfo
  37191. */
  37192. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37193. /**
  37194. * Launch a ray to try to pick a mesh in the scene
  37195. * @param x X position on screen
  37196. * @param y Y position on screen
  37197. * @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
  37198. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37199. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37200. * @returns an array of PickingInfo
  37201. */
  37202. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37203. /**
  37204. * Launch a ray to try to pick a mesh in the scene
  37205. * @param ray Ray to use
  37206. * @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
  37207. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37208. * @returns an array of PickingInfo
  37209. */
  37210. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37211. /**
  37212. * Force the value of meshUnderPointer
  37213. * @param mesh defines the mesh to use
  37214. */
  37215. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37216. /**
  37217. * Gets the mesh under the pointer
  37218. * @returns a Mesh or null if no mesh is under the pointer
  37219. */
  37220. getPointerOverMesh(): Nullable<AbstractMesh>;
  37221. /** @hidden */
  37222. _rebuildGeometries(): void;
  37223. /** @hidden */
  37224. _rebuildTextures(): void;
  37225. private _getByTags;
  37226. /**
  37227. * Get a list of meshes by tags
  37228. * @param tagsQuery defines the tags query to use
  37229. * @param forEach defines a predicate used to filter results
  37230. * @returns an array of Mesh
  37231. */
  37232. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37233. /**
  37234. * Get a list of cameras 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 Camera
  37238. */
  37239. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37240. /**
  37241. * Get a list of lights 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 Light
  37245. */
  37246. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37247. /**
  37248. * Get a list of materials 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 Material
  37252. */
  37253. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37254. /**
  37255. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37256. * This allowed control for front to back rendering or reversly depending of the special needs.
  37257. *
  37258. * @param renderingGroupId The rendering group id corresponding to its index
  37259. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37260. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37261. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37262. */
  37263. 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;
  37264. /**
  37265. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37266. *
  37267. * @param renderingGroupId The rendering group id corresponding to its index
  37268. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37269. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37270. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37271. */
  37272. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37273. /**
  37274. * Gets the current auto clear configuration for one rendering group of the rendering
  37275. * manager.
  37276. * @param index the rendering group index to get the information for
  37277. * @returns The auto clear setup for the requested rendering group
  37278. */
  37279. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37280. private _blockMaterialDirtyMechanism;
  37281. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37282. get blockMaterialDirtyMechanism(): boolean;
  37283. set blockMaterialDirtyMechanism(value: boolean);
  37284. /**
  37285. * Will flag all materials as dirty to trigger new shader compilation
  37286. * @param flag defines the flag used to specify which material part must be marked as dirty
  37287. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37288. */
  37289. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37290. /** @hidden */
  37291. _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;
  37292. /** @hidden */
  37293. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37294. /** @hidden */
  37295. _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;
  37296. /** @hidden */
  37297. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37298. /** @hidden */
  37299. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37300. /** @hidden */
  37301. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37302. }
  37303. }
  37304. declare module BABYLON {
  37305. /**
  37306. * Set of assets to keep when moving a scene into an asset container.
  37307. */
  37308. export class KeepAssets extends AbstractScene {
  37309. }
  37310. /**
  37311. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37312. */
  37313. export class InstantiatedEntries {
  37314. /**
  37315. * List of new root nodes (eg. nodes with no parent)
  37316. */
  37317. rootNodes: TransformNode[];
  37318. /**
  37319. * List of new skeletons
  37320. */
  37321. skeletons: Skeleton[];
  37322. /**
  37323. * List of new animation groups
  37324. */
  37325. animationGroups: AnimationGroup[];
  37326. }
  37327. /**
  37328. * Container with a set of assets that can be added or removed from a scene.
  37329. */
  37330. export class AssetContainer extends AbstractScene {
  37331. private _wasAddedToScene;
  37332. /**
  37333. * The scene the AssetContainer belongs to.
  37334. */
  37335. scene: Scene;
  37336. /**
  37337. * Instantiates an AssetContainer.
  37338. * @param scene The scene the AssetContainer belongs to.
  37339. */
  37340. constructor(scene: Scene);
  37341. /**
  37342. * Instantiate or clone all meshes and add the new ones to the scene.
  37343. * Skeletons and animation groups will all be cloned
  37344. * @param nameFunction defines an optional function used to get new names for clones
  37345. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37346. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37347. */
  37348. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37349. /**
  37350. * Adds all the assets from the container to the scene.
  37351. */
  37352. addAllToScene(): void;
  37353. /**
  37354. * Removes all the assets in the container from the scene
  37355. */
  37356. removeAllFromScene(): void;
  37357. /**
  37358. * Disposes all the assets in the container
  37359. */
  37360. dispose(): void;
  37361. private _moveAssets;
  37362. /**
  37363. * Removes all the assets contained in the scene and adds them to the container.
  37364. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37365. */
  37366. moveAllFromScene(keepAssets?: KeepAssets): void;
  37367. /**
  37368. * 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.
  37369. * @returns the root mesh
  37370. */
  37371. createRootMesh(): Mesh;
  37372. /**
  37373. * Merge animations from this asset container into a scene
  37374. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37375. * @param animatables set of animatables to retarget to a node from the scene
  37376. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37377. */
  37378. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37379. }
  37380. }
  37381. declare module BABYLON {
  37382. /**
  37383. * Defines how the parser contract is defined.
  37384. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37385. */
  37386. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37387. /**
  37388. * Defines how the individual parser contract is defined.
  37389. * These parser can parse an individual asset
  37390. */
  37391. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37392. /**
  37393. * Base class of the scene acting as a container for the different elements composing a scene.
  37394. * This class is dynamically extended by the different components of the scene increasing
  37395. * flexibility and reducing coupling
  37396. */
  37397. export abstract class AbstractScene {
  37398. /**
  37399. * Stores the list of available parsers in the application.
  37400. */
  37401. private static _BabylonFileParsers;
  37402. /**
  37403. * Stores the list of available individual parsers in the application.
  37404. */
  37405. private static _IndividualBabylonFileParsers;
  37406. /**
  37407. * Adds a parser in the list of available ones
  37408. * @param name Defines the name of the parser
  37409. * @param parser Defines the parser to add
  37410. */
  37411. static AddParser(name: string, parser: BabylonFileParser): void;
  37412. /**
  37413. * Gets a general parser from the list of avaialble ones
  37414. * @param name Defines the name of the parser
  37415. * @returns the requested parser or null
  37416. */
  37417. static GetParser(name: string): Nullable<BabylonFileParser>;
  37418. /**
  37419. * Adds n individual parser in the list of available ones
  37420. * @param name Defines the name of the parser
  37421. * @param parser Defines the parser to add
  37422. */
  37423. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37424. /**
  37425. * Gets an individual parser from the list of avaialble ones
  37426. * @param name Defines the name of the parser
  37427. * @returns the requested parser or null
  37428. */
  37429. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37430. /**
  37431. * Parser json data and populate both a scene and its associated container object
  37432. * @param jsonData Defines the data to parse
  37433. * @param scene Defines the scene to parse the data for
  37434. * @param container Defines the container attached to the parsing sequence
  37435. * @param rootUrl Defines the root url of the data
  37436. */
  37437. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37438. /**
  37439. * Gets the list of root nodes (ie. nodes with no parent)
  37440. */
  37441. rootNodes: Node[];
  37442. /** All of the cameras added to this scene
  37443. * @see http://doc.babylonjs.com/babylon101/cameras
  37444. */
  37445. cameras: Camera[];
  37446. /**
  37447. * All of the lights added to this scene
  37448. * @see http://doc.babylonjs.com/babylon101/lights
  37449. */
  37450. lights: Light[];
  37451. /**
  37452. * All of the (abstract) meshes added to this scene
  37453. */
  37454. meshes: AbstractMesh[];
  37455. /**
  37456. * The list of skeletons added to the scene
  37457. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37458. */
  37459. skeletons: Skeleton[];
  37460. /**
  37461. * All of the particle systems added to this scene
  37462. * @see http://doc.babylonjs.com/babylon101/particles
  37463. */
  37464. particleSystems: IParticleSystem[];
  37465. /**
  37466. * Gets a list of Animations associated with the scene
  37467. */
  37468. animations: Animation[];
  37469. /**
  37470. * All of the animation groups added to this scene
  37471. * @see http://doc.babylonjs.com/how_to/group
  37472. */
  37473. animationGroups: AnimationGroup[];
  37474. /**
  37475. * All of the multi-materials added to this scene
  37476. * @see http://doc.babylonjs.com/how_to/multi_materials
  37477. */
  37478. multiMaterials: MultiMaterial[];
  37479. /**
  37480. * All of the materials added to this scene
  37481. * In the context of a Scene, it is not supposed to be modified manually.
  37482. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37483. * Note also that the order of the Material within the array is not significant and might change.
  37484. * @see http://doc.babylonjs.com/babylon101/materials
  37485. */
  37486. materials: Material[];
  37487. /**
  37488. * The list of morph target managers added to the scene
  37489. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37490. */
  37491. morphTargetManagers: MorphTargetManager[];
  37492. /**
  37493. * The list of geometries used in the scene.
  37494. */
  37495. geometries: Geometry[];
  37496. /**
  37497. * All of the tranform nodes added to this scene
  37498. * In the context of a Scene, it is not supposed to be modified manually.
  37499. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37500. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37501. * @see http://doc.babylonjs.com/how_to/transformnode
  37502. */
  37503. transformNodes: TransformNode[];
  37504. /**
  37505. * ActionManagers available on the scene.
  37506. */
  37507. actionManagers: AbstractActionManager[];
  37508. /**
  37509. * Textures to keep.
  37510. */
  37511. textures: BaseTexture[];
  37512. /**
  37513. * Environment texture for the scene
  37514. */
  37515. environmentTexture: Nullable<BaseTexture>;
  37516. /**
  37517. * @returns all meshes, lights, cameras, transformNodes and bones
  37518. */
  37519. getNodes(): Array<Node>;
  37520. }
  37521. }
  37522. declare module BABYLON {
  37523. /**
  37524. * Interface used to define options for Sound class
  37525. */
  37526. export interface ISoundOptions {
  37527. /**
  37528. * Does the sound autoplay once loaded.
  37529. */
  37530. autoplay?: boolean;
  37531. /**
  37532. * Does the sound loop after it finishes playing once.
  37533. */
  37534. loop?: boolean;
  37535. /**
  37536. * Sound's volume
  37537. */
  37538. volume?: number;
  37539. /**
  37540. * Is it a spatial sound?
  37541. */
  37542. spatialSound?: boolean;
  37543. /**
  37544. * Maximum distance to hear that sound
  37545. */
  37546. maxDistance?: number;
  37547. /**
  37548. * Uses user defined attenuation function
  37549. */
  37550. useCustomAttenuation?: boolean;
  37551. /**
  37552. * Define the roll off factor of spatial sounds.
  37553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37554. */
  37555. rolloffFactor?: number;
  37556. /**
  37557. * Define the reference distance the sound should be heard perfectly.
  37558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37559. */
  37560. refDistance?: number;
  37561. /**
  37562. * Define the distance attenuation model the sound will follow.
  37563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37564. */
  37565. distanceModel?: string;
  37566. /**
  37567. * Defines the playback speed (1 by default)
  37568. */
  37569. playbackRate?: number;
  37570. /**
  37571. * Defines if the sound is from a streaming source
  37572. */
  37573. streaming?: boolean;
  37574. /**
  37575. * Defines an optional length (in seconds) inside the sound file
  37576. */
  37577. length?: number;
  37578. /**
  37579. * Defines an optional offset (in seconds) inside the sound file
  37580. */
  37581. offset?: number;
  37582. /**
  37583. * If true, URLs will not be required to state the audio file codec to use.
  37584. */
  37585. skipCodecCheck?: boolean;
  37586. }
  37587. /**
  37588. * Defines a sound that can be played in the application.
  37589. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37591. */
  37592. export class Sound {
  37593. /**
  37594. * The name of the sound in the scene.
  37595. */
  37596. name: string;
  37597. /**
  37598. * Does the sound autoplay once loaded.
  37599. */
  37600. autoplay: boolean;
  37601. /**
  37602. * Does the sound loop after it finishes playing once.
  37603. */
  37604. loop: boolean;
  37605. /**
  37606. * Does the sound use a custom attenuation curve to simulate the falloff
  37607. * happening when the source gets further away from the camera.
  37608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37609. */
  37610. useCustomAttenuation: boolean;
  37611. /**
  37612. * The sound track id this sound belongs to.
  37613. */
  37614. soundTrackId: number;
  37615. /**
  37616. * Is this sound currently played.
  37617. */
  37618. isPlaying: boolean;
  37619. /**
  37620. * Is this sound currently paused.
  37621. */
  37622. isPaused: boolean;
  37623. /**
  37624. * Does this sound enables spatial sound.
  37625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37626. */
  37627. spatialSound: boolean;
  37628. /**
  37629. * Define the reference distance the sound should be heard perfectly.
  37630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37631. */
  37632. refDistance: number;
  37633. /**
  37634. * Define the roll off factor of spatial sounds.
  37635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37636. */
  37637. rolloffFactor: number;
  37638. /**
  37639. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37641. */
  37642. maxDistance: number;
  37643. /**
  37644. * Define the distance attenuation model the sound will follow.
  37645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37646. */
  37647. distanceModel: string;
  37648. /**
  37649. * @hidden
  37650. * Back Compat
  37651. **/
  37652. onended: () => any;
  37653. /**
  37654. * Observable event when the current playing sound finishes.
  37655. */
  37656. onEndedObservable: Observable<Sound>;
  37657. private _panningModel;
  37658. private _playbackRate;
  37659. private _streaming;
  37660. private _startTime;
  37661. private _startOffset;
  37662. private _position;
  37663. /** @hidden */
  37664. _positionInEmitterSpace: boolean;
  37665. private _localDirection;
  37666. private _volume;
  37667. private _isReadyToPlay;
  37668. private _isDirectional;
  37669. private _readyToPlayCallback;
  37670. private _audioBuffer;
  37671. private _soundSource;
  37672. private _streamingSource;
  37673. private _soundPanner;
  37674. private _soundGain;
  37675. private _inputAudioNode;
  37676. private _outputAudioNode;
  37677. private _coneInnerAngle;
  37678. private _coneOuterAngle;
  37679. private _coneOuterGain;
  37680. private _scene;
  37681. private _connectedTransformNode;
  37682. private _customAttenuationFunction;
  37683. private _registerFunc;
  37684. private _isOutputConnected;
  37685. private _htmlAudioElement;
  37686. private _urlType;
  37687. private _length?;
  37688. private _offset?;
  37689. /** @hidden */
  37690. static _SceneComponentInitialization: (scene: Scene) => void;
  37691. /**
  37692. * Create a sound and attach it to a scene
  37693. * @param name Name of your sound
  37694. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37695. * @param scene defines the scene the sound belongs to
  37696. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37697. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37698. */
  37699. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37700. /**
  37701. * Release the sound and its associated resources
  37702. */
  37703. dispose(): void;
  37704. /**
  37705. * Gets if the sounds is ready to be played or not.
  37706. * @returns true if ready, otherwise false
  37707. */
  37708. isReady(): boolean;
  37709. private _soundLoaded;
  37710. /**
  37711. * Sets the data of the sound from an audiobuffer
  37712. * @param audioBuffer The audioBuffer containing the data
  37713. */
  37714. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37715. /**
  37716. * Updates the current sounds options such as maxdistance, loop...
  37717. * @param options A JSON object containing values named as the object properties
  37718. */
  37719. updateOptions(options: ISoundOptions): void;
  37720. private _createSpatialParameters;
  37721. private _updateSpatialParameters;
  37722. /**
  37723. * Switch the panning model to HRTF:
  37724. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37726. */
  37727. switchPanningModelToHRTF(): void;
  37728. /**
  37729. * Switch the panning model to Equal Power:
  37730. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37732. */
  37733. switchPanningModelToEqualPower(): void;
  37734. private _switchPanningModel;
  37735. /**
  37736. * Connect this sound to a sound track audio node like gain...
  37737. * @param soundTrackAudioNode the sound track audio node to connect to
  37738. */
  37739. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37740. /**
  37741. * Transform this sound into a directional source
  37742. * @param coneInnerAngle Size of the inner cone in degree
  37743. * @param coneOuterAngle Size of the outer cone in degree
  37744. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37745. */
  37746. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37747. /**
  37748. * Gets or sets the inner angle for the directional cone.
  37749. */
  37750. get directionalConeInnerAngle(): number;
  37751. /**
  37752. * Gets or sets the inner angle for the directional cone.
  37753. */
  37754. set directionalConeInnerAngle(value: number);
  37755. /**
  37756. * Gets or sets the outer angle for the directional cone.
  37757. */
  37758. get directionalConeOuterAngle(): number;
  37759. /**
  37760. * Gets or sets the outer angle for the directional cone.
  37761. */
  37762. set directionalConeOuterAngle(value: number);
  37763. /**
  37764. * Sets the position of the emitter if spatial sound is enabled
  37765. * @param newPosition Defines the new posisiton
  37766. */
  37767. setPosition(newPosition: Vector3): void;
  37768. /**
  37769. * Sets the local direction of the emitter if spatial sound is enabled
  37770. * @param newLocalDirection Defines the new local direction
  37771. */
  37772. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37773. private _updateDirection;
  37774. /** @hidden */
  37775. updateDistanceFromListener(): void;
  37776. /**
  37777. * Sets a new custom attenuation function for the sound.
  37778. * @param callback Defines the function used for the attenuation
  37779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37780. */
  37781. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37782. /**
  37783. * Play the sound
  37784. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37785. * @param offset (optional) Start the sound at a specific time in seconds
  37786. * @param length (optional) Sound duration (in seconds)
  37787. */
  37788. play(time?: number, offset?: number, length?: number): void;
  37789. private _onended;
  37790. /**
  37791. * Stop the sound
  37792. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37793. */
  37794. stop(time?: number): void;
  37795. /**
  37796. * Put the sound in pause
  37797. */
  37798. pause(): void;
  37799. /**
  37800. * Sets a dedicated volume for this sounds
  37801. * @param newVolume Define the new volume of the sound
  37802. * @param time Define time for gradual change to new volume
  37803. */
  37804. setVolume(newVolume: number, time?: number): void;
  37805. /**
  37806. * Set the sound play back rate
  37807. * @param newPlaybackRate Define the playback rate the sound should be played at
  37808. */
  37809. setPlaybackRate(newPlaybackRate: number): void;
  37810. /**
  37811. * Gets the volume of the sound.
  37812. * @returns the volume of the sound
  37813. */
  37814. getVolume(): number;
  37815. /**
  37816. * Attach the sound to a dedicated mesh
  37817. * @param transformNode The transform node to connect the sound with
  37818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37819. */
  37820. attachToMesh(transformNode: TransformNode): void;
  37821. /**
  37822. * Detach the sound from the previously attached mesh
  37823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37824. */
  37825. detachFromMesh(): void;
  37826. private _onRegisterAfterWorldMatrixUpdate;
  37827. /**
  37828. * Clone the current sound in the scene.
  37829. * @returns the new sound clone
  37830. */
  37831. clone(): Nullable<Sound>;
  37832. /**
  37833. * Gets the current underlying audio buffer containing the data
  37834. * @returns the audio buffer
  37835. */
  37836. getAudioBuffer(): Nullable<AudioBuffer>;
  37837. /**
  37838. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37839. * @returns the source node
  37840. */
  37841. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37842. /**
  37843. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37844. * @returns the gain node
  37845. */
  37846. getSoundGain(): Nullable<GainNode>;
  37847. /**
  37848. * Serializes the Sound in a JSON representation
  37849. * @returns the JSON representation of the sound
  37850. */
  37851. serialize(): any;
  37852. /**
  37853. * Parse a JSON representation of a sound to innstantiate in a given scene
  37854. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37855. * @param scene Define the scene the new parsed sound should be created in
  37856. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37857. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37858. * @returns the newly parsed sound
  37859. */
  37860. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37861. }
  37862. }
  37863. declare module BABYLON {
  37864. /**
  37865. * This defines an action helpful to play a defined sound on a triggered action.
  37866. */
  37867. export class PlaySoundAction extends Action {
  37868. private _sound;
  37869. /**
  37870. * Instantiate the action
  37871. * @param triggerOptions defines the trigger options
  37872. * @param sound defines the sound to play
  37873. * @param condition defines the trigger related conditions
  37874. */
  37875. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37876. /** @hidden */
  37877. _prepare(): void;
  37878. /**
  37879. * Execute the action and play the sound.
  37880. */
  37881. execute(): void;
  37882. /**
  37883. * Serializes the actions and its related information.
  37884. * @param parent defines the object to serialize in
  37885. * @returns the serialized object
  37886. */
  37887. serialize(parent: any): any;
  37888. }
  37889. /**
  37890. * This defines an action helpful to stop a defined sound on a triggered action.
  37891. */
  37892. export class StopSoundAction extends Action {
  37893. private _sound;
  37894. /**
  37895. * Instantiate the action
  37896. * @param triggerOptions defines the trigger options
  37897. * @param sound defines the sound to stop
  37898. * @param condition defines the trigger related conditions
  37899. */
  37900. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37901. /** @hidden */
  37902. _prepare(): void;
  37903. /**
  37904. * Execute the action and stop the sound.
  37905. */
  37906. execute(): void;
  37907. /**
  37908. * Serializes the actions and its related information.
  37909. * @param parent defines the object to serialize in
  37910. * @returns the serialized object
  37911. */
  37912. serialize(parent: any): any;
  37913. }
  37914. }
  37915. declare module BABYLON {
  37916. /**
  37917. * This defines an action responsible to change the value of a property
  37918. * by interpolating between its current value and the newly set one once triggered.
  37919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37920. */
  37921. export class InterpolateValueAction extends Action {
  37922. /**
  37923. * Defines the path of the property where the value should be interpolated
  37924. */
  37925. propertyPath: string;
  37926. /**
  37927. * Defines the target value at the end of the interpolation.
  37928. */
  37929. value: any;
  37930. /**
  37931. * Defines the time it will take for the property to interpolate to the value.
  37932. */
  37933. duration: number;
  37934. /**
  37935. * Defines if the other scene animations should be stopped when the action has been triggered
  37936. */
  37937. stopOtherAnimations?: boolean;
  37938. /**
  37939. * Defines a callback raised once the interpolation animation has been done.
  37940. */
  37941. onInterpolationDone?: () => void;
  37942. /**
  37943. * Observable triggered once the interpolation animation has been done.
  37944. */
  37945. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37946. private _target;
  37947. private _effectiveTarget;
  37948. private _property;
  37949. /**
  37950. * Instantiate the action
  37951. * @param triggerOptions defines the trigger options
  37952. * @param target defines the object containing the value to interpolate
  37953. * @param propertyPath defines the path to the property in the target object
  37954. * @param value defines the target value at the end of the interpolation
  37955. * @param duration deines the time it will take for the property to interpolate to the value.
  37956. * @param condition defines the trigger related conditions
  37957. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37958. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37959. */
  37960. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37961. /** @hidden */
  37962. _prepare(): void;
  37963. /**
  37964. * Execute the action starts the value interpolation.
  37965. */
  37966. execute(): void;
  37967. /**
  37968. * Serializes the actions and its related information.
  37969. * @param parent defines the object to serialize in
  37970. * @returns the serialized object
  37971. */
  37972. serialize(parent: any): any;
  37973. }
  37974. }
  37975. declare module BABYLON {
  37976. /**
  37977. * Options allowed during the creation of a sound track.
  37978. */
  37979. export interface ISoundTrackOptions {
  37980. /**
  37981. * The volume the sound track should take during creation
  37982. */
  37983. volume?: number;
  37984. /**
  37985. * Define if the sound track is the main sound track of the scene
  37986. */
  37987. mainTrack?: boolean;
  37988. }
  37989. /**
  37990. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37991. * It will be also used in a future release to apply effects on a specific track.
  37992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37993. */
  37994. export class SoundTrack {
  37995. /**
  37996. * The unique identifier of the sound track in the scene.
  37997. */
  37998. id: number;
  37999. /**
  38000. * The list of sounds included in the sound track.
  38001. */
  38002. soundCollection: Array<Sound>;
  38003. private _outputAudioNode;
  38004. private _scene;
  38005. private _connectedAnalyser;
  38006. private _options;
  38007. private _isInitialized;
  38008. /**
  38009. * Creates a new sound track.
  38010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38011. * @param scene Define the scene the sound track belongs to
  38012. * @param options
  38013. */
  38014. constructor(scene: Scene, options?: ISoundTrackOptions);
  38015. private _initializeSoundTrackAudioGraph;
  38016. /**
  38017. * Release the sound track and its associated resources
  38018. */
  38019. dispose(): void;
  38020. /**
  38021. * Adds a sound to this sound track
  38022. * @param sound define the cound to add
  38023. * @ignoreNaming
  38024. */
  38025. AddSound(sound: Sound): void;
  38026. /**
  38027. * Removes a sound to this sound track
  38028. * @param sound define the cound to remove
  38029. * @ignoreNaming
  38030. */
  38031. RemoveSound(sound: Sound): void;
  38032. /**
  38033. * Set a global volume for the full sound track.
  38034. * @param newVolume Define the new volume of the sound track
  38035. */
  38036. setVolume(newVolume: number): void;
  38037. /**
  38038. * Switch the panning model to HRTF:
  38039. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38041. */
  38042. switchPanningModelToHRTF(): void;
  38043. /**
  38044. * Switch the panning model to Equal Power:
  38045. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38047. */
  38048. switchPanningModelToEqualPower(): void;
  38049. /**
  38050. * Connect the sound track to an audio analyser allowing some amazing
  38051. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38053. * @param analyser The analyser to connect to the engine
  38054. */
  38055. connectToAnalyser(analyser: Analyser): void;
  38056. }
  38057. }
  38058. declare module BABYLON {
  38059. interface AbstractScene {
  38060. /**
  38061. * The list of sounds used in the scene.
  38062. */
  38063. sounds: Nullable<Array<Sound>>;
  38064. }
  38065. interface Scene {
  38066. /**
  38067. * @hidden
  38068. * Backing field
  38069. */
  38070. _mainSoundTrack: SoundTrack;
  38071. /**
  38072. * The main sound track played by the scene.
  38073. * It cotains your primary collection of sounds.
  38074. */
  38075. mainSoundTrack: SoundTrack;
  38076. /**
  38077. * The list of sound tracks added to the scene
  38078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38079. */
  38080. soundTracks: Nullable<Array<SoundTrack>>;
  38081. /**
  38082. * Gets a sound using a given name
  38083. * @param name defines the name to search for
  38084. * @return the found sound or null if not found at all.
  38085. */
  38086. getSoundByName(name: string): Nullable<Sound>;
  38087. /**
  38088. * Gets or sets if audio support is enabled
  38089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38090. */
  38091. audioEnabled: boolean;
  38092. /**
  38093. * Gets or sets if audio will be output to headphones
  38094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38095. */
  38096. headphone: boolean;
  38097. /**
  38098. * Gets or sets custom audio listener position provider
  38099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38100. */
  38101. audioListenerPositionProvider: Nullable<() => Vector3>;
  38102. /**
  38103. * Gets or sets a refresh rate when using 3D audio positioning
  38104. */
  38105. audioPositioningRefreshRate: number;
  38106. }
  38107. /**
  38108. * Defines the sound scene component responsible to manage any sounds
  38109. * in a given scene.
  38110. */
  38111. export class AudioSceneComponent implements ISceneSerializableComponent {
  38112. /**
  38113. * The component name helpfull to identify the component in the list of scene components.
  38114. */
  38115. readonly name: string;
  38116. /**
  38117. * The scene the component belongs to.
  38118. */
  38119. scene: Scene;
  38120. private _audioEnabled;
  38121. /**
  38122. * Gets whether audio is enabled or not.
  38123. * Please use related enable/disable method to switch state.
  38124. */
  38125. get audioEnabled(): boolean;
  38126. private _headphone;
  38127. /**
  38128. * Gets whether audio is outputing to headphone or not.
  38129. * Please use the according Switch methods to change output.
  38130. */
  38131. get headphone(): boolean;
  38132. /**
  38133. * Gets or sets a refresh rate when using 3D audio positioning
  38134. */
  38135. audioPositioningRefreshRate: number;
  38136. private _audioListenerPositionProvider;
  38137. /**
  38138. * Gets the current audio listener position provider
  38139. */
  38140. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38141. /**
  38142. * Sets a custom listener position for all sounds in the scene
  38143. * By default, this is the position of the first active camera
  38144. */
  38145. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38146. /**
  38147. * Creates a new instance of the component for the given scene
  38148. * @param scene Defines the scene to register the component in
  38149. */
  38150. constructor(scene: Scene);
  38151. /**
  38152. * Registers the component in a given scene
  38153. */
  38154. register(): void;
  38155. /**
  38156. * Rebuilds the elements related to this component in case of
  38157. * context lost for instance.
  38158. */
  38159. rebuild(): void;
  38160. /**
  38161. * Serializes the component data to the specified json object
  38162. * @param serializationObject The object to serialize to
  38163. */
  38164. serialize(serializationObject: any): void;
  38165. /**
  38166. * Adds all the elements from the container to the scene
  38167. * @param container the container holding the elements
  38168. */
  38169. addFromContainer(container: AbstractScene): void;
  38170. /**
  38171. * Removes all the elements in the container from the scene
  38172. * @param container contains the elements to remove
  38173. * @param dispose if the removed element should be disposed (default: false)
  38174. */
  38175. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38176. /**
  38177. * Disposes the component and the associated ressources.
  38178. */
  38179. dispose(): void;
  38180. /**
  38181. * Disables audio in the associated scene.
  38182. */
  38183. disableAudio(): void;
  38184. /**
  38185. * Enables audio in the associated scene.
  38186. */
  38187. enableAudio(): void;
  38188. /**
  38189. * Switch audio to headphone output.
  38190. */
  38191. switchAudioModeForHeadphones(): void;
  38192. /**
  38193. * Switch audio to normal speakers.
  38194. */
  38195. switchAudioModeForNormalSpeakers(): void;
  38196. private _cachedCameraDirection;
  38197. private _cachedCameraPosition;
  38198. private _lastCheck;
  38199. private _afterRender;
  38200. }
  38201. }
  38202. declare module BABYLON {
  38203. /**
  38204. * Wraps one or more Sound objects and selects one with random weight for playback.
  38205. */
  38206. export class WeightedSound {
  38207. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38208. loop: boolean;
  38209. private _coneInnerAngle;
  38210. private _coneOuterAngle;
  38211. private _volume;
  38212. /** A Sound is currently playing. */
  38213. isPlaying: boolean;
  38214. /** A Sound is currently paused. */
  38215. isPaused: boolean;
  38216. private _sounds;
  38217. private _weights;
  38218. private _currentIndex?;
  38219. /**
  38220. * Creates a new WeightedSound from the list of sounds given.
  38221. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38222. * @param sounds Array of Sounds that will be selected from.
  38223. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38224. */
  38225. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38226. /**
  38227. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38228. */
  38229. get directionalConeInnerAngle(): number;
  38230. /**
  38231. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38232. */
  38233. set directionalConeInnerAngle(value: number);
  38234. /**
  38235. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38236. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38237. */
  38238. get directionalConeOuterAngle(): number;
  38239. /**
  38240. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38241. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38242. */
  38243. set directionalConeOuterAngle(value: number);
  38244. /**
  38245. * Playback volume.
  38246. */
  38247. get volume(): number;
  38248. /**
  38249. * Playback volume.
  38250. */
  38251. set volume(value: number);
  38252. private _onended;
  38253. /**
  38254. * Suspend playback
  38255. */
  38256. pause(): void;
  38257. /**
  38258. * Stop playback
  38259. */
  38260. stop(): void;
  38261. /**
  38262. * Start playback.
  38263. * @param startOffset Position the clip head at a specific time in seconds.
  38264. */
  38265. play(startOffset?: number): void;
  38266. }
  38267. }
  38268. declare module BABYLON {
  38269. /**
  38270. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38271. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38272. */
  38273. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38274. /**
  38275. * Gets the name of the behavior.
  38276. */
  38277. get name(): string;
  38278. /**
  38279. * The easing function used by animations
  38280. */
  38281. static EasingFunction: BackEase;
  38282. /**
  38283. * The easing mode used by animations
  38284. */
  38285. static EasingMode: number;
  38286. /**
  38287. * The duration of the animation, in milliseconds
  38288. */
  38289. transitionDuration: number;
  38290. /**
  38291. * Length of the distance animated by the transition when lower radius is reached
  38292. */
  38293. lowerRadiusTransitionRange: number;
  38294. /**
  38295. * Length of the distance animated by the transition when upper radius is reached
  38296. */
  38297. upperRadiusTransitionRange: number;
  38298. private _autoTransitionRange;
  38299. /**
  38300. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38301. */
  38302. get autoTransitionRange(): boolean;
  38303. /**
  38304. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38305. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38306. */
  38307. set autoTransitionRange(value: boolean);
  38308. private _attachedCamera;
  38309. private _onAfterCheckInputsObserver;
  38310. private _onMeshTargetChangedObserver;
  38311. /**
  38312. * Initializes the behavior.
  38313. */
  38314. init(): void;
  38315. /**
  38316. * Attaches the behavior to its arc rotate camera.
  38317. * @param camera Defines the camera to attach the behavior to
  38318. */
  38319. attach(camera: ArcRotateCamera): void;
  38320. /**
  38321. * Detaches the behavior from its current arc rotate camera.
  38322. */
  38323. detach(): void;
  38324. private _radiusIsAnimating;
  38325. private _radiusBounceTransition;
  38326. private _animatables;
  38327. private _cachedWheelPrecision;
  38328. /**
  38329. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38330. * @param radiusLimit The limit to check against.
  38331. * @return Bool to indicate if at limit.
  38332. */
  38333. private _isRadiusAtLimit;
  38334. /**
  38335. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38336. * @param radiusDelta The delta by which to animate to. Can be negative.
  38337. */
  38338. private _applyBoundRadiusAnimation;
  38339. /**
  38340. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38341. */
  38342. protected _clearAnimationLocks(): void;
  38343. /**
  38344. * Stops and removes all animations that have been applied to the camera
  38345. */
  38346. stopAllAnimations(): void;
  38347. }
  38348. }
  38349. declare module BABYLON {
  38350. /**
  38351. * 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.
  38352. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38353. */
  38354. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38355. /**
  38356. * Gets the name of the behavior.
  38357. */
  38358. get name(): string;
  38359. private _mode;
  38360. private _radiusScale;
  38361. private _positionScale;
  38362. private _defaultElevation;
  38363. private _elevationReturnTime;
  38364. private _elevationReturnWaitTime;
  38365. private _zoomStopsAnimation;
  38366. private _framingTime;
  38367. /**
  38368. * The easing function used by animations
  38369. */
  38370. static EasingFunction: ExponentialEase;
  38371. /**
  38372. * The easing mode used by animations
  38373. */
  38374. static EasingMode: number;
  38375. /**
  38376. * Sets the current mode used by the behavior
  38377. */
  38378. set mode(mode: number);
  38379. /**
  38380. * Gets current mode used by the behavior.
  38381. */
  38382. get mode(): number;
  38383. /**
  38384. * Sets the scale applied to the radius (1 by default)
  38385. */
  38386. set radiusScale(radius: number);
  38387. /**
  38388. * Gets the scale applied to the radius
  38389. */
  38390. get radiusScale(): number;
  38391. /**
  38392. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38393. */
  38394. set positionScale(scale: number);
  38395. /**
  38396. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38397. */
  38398. get positionScale(): number;
  38399. /**
  38400. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38401. * behaviour is triggered, in radians.
  38402. */
  38403. set defaultElevation(elevation: number);
  38404. /**
  38405. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38406. * behaviour is triggered, in radians.
  38407. */
  38408. get defaultElevation(): number;
  38409. /**
  38410. * Sets the time (in milliseconds) taken to return to the default beta position.
  38411. * Negative value indicates camera should not return to default.
  38412. */
  38413. set elevationReturnTime(speed: number);
  38414. /**
  38415. * Gets the time (in milliseconds) taken to return to the default beta position.
  38416. * Negative value indicates camera should not return to default.
  38417. */
  38418. get elevationReturnTime(): number;
  38419. /**
  38420. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38421. */
  38422. set elevationReturnWaitTime(time: number);
  38423. /**
  38424. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38425. */
  38426. get elevationReturnWaitTime(): number;
  38427. /**
  38428. * Sets the flag that indicates if user zooming should stop animation.
  38429. */
  38430. set zoomStopsAnimation(flag: boolean);
  38431. /**
  38432. * Gets the flag that indicates if user zooming should stop animation.
  38433. */
  38434. get zoomStopsAnimation(): boolean;
  38435. /**
  38436. * Sets the transition time when framing the mesh, in milliseconds
  38437. */
  38438. set framingTime(time: number);
  38439. /**
  38440. * Gets the transition time when framing the mesh, in milliseconds
  38441. */
  38442. get framingTime(): number;
  38443. /**
  38444. * Define if the behavior should automatically change the configured
  38445. * camera limits and sensibilities.
  38446. */
  38447. autoCorrectCameraLimitsAndSensibility: boolean;
  38448. private _onPrePointerObservableObserver;
  38449. private _onAfterCheckInputsObserver;
  38450. private _onMeshTargetChangedObserver;
  38451. private _attachedCamera;
  38452. private _isPointerDown;
  38453. private _lastInteractionTime;
  38454. /**
  38455. * Initializes the behavior.
  38456. */
  38457. init(): void;
  38458. /**
  38459. * Attaches the behavior to its arc rotate camera.
  38460. * @param camera Defines the camera to attach the behavior to
  38461. */
  38462. attach(camera: ArcRotateCamera): void;
  38463. /**
  38464. * Detaches the behavior from its current arc rotate camera.
  38465. */
  38466. detach(): void;
  38467. private _animatables;
  38468. private _betaIsAnimating;
  38469. private _betaTransition;
  38470. private _radiusTransition;
  38471. private _vectorTransition;
  38472. /**
  38473. * Targets the given mesh and updates zoom level accordingly.
  38474. * @param mesh The mesh to target.
  38475. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38476. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38477. */
  38478. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38479. /**
  38480. * Targets the given mesh with its children 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. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38486. /**
  38487. * Targets the given meshes with their children and updates zoom level accordingly.
  38488. * @param meshes 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. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38493. /**
  38494. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38495. * @param minimumWorld Determines the smaller position of the bounding box extend
  38496. * @param maximumWorld Determines the bigger position of the bounding box extend
  38497. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38498. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38499. */
  38500. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38501. /**
  38502. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38503. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38504. * frustum width.
  38505. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38506. * to fully enclose the mesh in the viewing frustum.
  38507. */
  38508. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38509. /**
  38510. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38511. * is automatically returned to its default position (expected to be above ground plane).
  38512. */
  38513. private _maintainCameraAboveGround;
  38514. /**
  38515. * Returns the frustum slope based on the canvas ratio and camera FOV
  38516. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38517. */
  38518. private _getFrustumSlope;
  38519. /**
  38520. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38521. */
  38522. private _clearAnimationLocks;
  38523. /**
  38524. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38525. */
  38526. private _applyUserInteraction;
  38527. /**
  38528. * Stops and removes all animations that have been applied to the camera
  38529. */
  38530. stopAllAnimations(): void;
  38531. /**
  38532. * Gets a value indicating if the user is moving the camera
  38533. */
  38534. get isUserIsMoving(): boolean;
  38535. /**
  38536. * The camera can move all the way towards the mesh.
  38537. */
  38538. static IgnoreBoundsSizeMode: number;
  38539. /**
  38540. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38541. */
  38542. static FitFrustumSidesMode: number;
  38543. }
  38544. }
  38545. declare module BABYLON {
  38546. /**
  38547. * Base class for Camera Pointer Inputs.
  38548. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38549. * for example usage.
  38550. */
  38551. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38552. /**
  38553. * Defines the camera the input is attached to.
  38554. */
  38555. abstract camera: Camera;
  38556. /**
  38557. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38558. */
  38559. protected _altKey: boolean;
  38560. protected _ctrlKey: boolean;
  38561. protected _metaKey: boolean;
  38562. protected _shiftKey: boolean;
  38563. /**
  38564. * Which mouse buttons were pressed at time of last mouse event.
  38565. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38566. */
  38567. protected _buttonsPressed: number;
  38568. /**
  38569. * Defines the buttons associated with the input to handle camera move.
  38570. */
  38571. buttons: number[];
  38572. /**
  38573. * Attach the input controls to a specific dom element to get the input from.
  38574. * @param element Defines the element the controls should be listened from
  38575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38576. */
  38577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38578. /**
  38579. * Detach the current controls from the specified dom element.
  38580. * @param element Defines the element to stop listening the inputs from
  38581. */
  38582. detachControl(element: Nullable<HTMLElement>): void;
  38583. /**
  38584. * Gets the class name of the current input.
  38585. * @returns the class name
  38586. */
  38587. getClassName(): string;
  38588. /**
  38589. * Get the friendly name associated with the input class.
  38590. * @returns the input friendly name
  38591. */
  38592. getSimpleName(): string;
  38593. /**
  38594. * Called on pointer POINTERDOUBLETAP event.
  38595. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38596. */
  38597. protected onDoubleTap(type: string): void;
  38598. /**
  38599. * Called on pointer POINTERMOVE event if only a single touch is active.
  38600. * Override this method to provide functionality.
  38601. */
  38602. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38603. /**
  38604. * Called on pointer POINTERMOVE event if multiple touches are active.
  38605. * Override this method to provide functionality.
  38606. */
  38607. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38608. /**
  38609. * Called on JS contextmenu event.
  38610. * Override this method to provide functionality.
  38611. */
  38612. protected onContextMenu(evt: PointerEvent): void;
  38613. /**
  38614. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38615. * press.
  38616. * Override this method to provide functionality.
  38617. */
  38618. protected onButtonDown(evt: PointerEvent): void;
  38619. /**
  38620. * Called each time a new POINTERUP event occurs. Ie, for each button
  38621. * release.
  38622. * Override this method to provide functionality.
  38623. */
  38624. protected onButtonUp(evt: PointerEvent): void;
  38625. /**
  38626. * Called when window becomes inactive.
  38627. * Override this method to provide functionality.
  38628. */
  38629. protected onLostFocus(): void;
  38630. private _pointerInput;
  38631. private _observer;
  38632. private _onLostFocus;
  38633. private pointA;
  38634. private pointB;
  38635. }
  38636. }
  38637. declare module BABYLON {
  38638. /**
  38639. * Manage the pointers inputs to control an arc rotate camera.
  38640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38641. */
  38642. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38643. /**
  38644. * Defines the camera the input is attached to.
  38645. */
  38646. camera: ArcRotateCamera;
  38647. /**
  38648. * Gets the class name of the current input.
  38649. * @returns the class name
  38650. */
  38651. getClassName(): string;
  38652. /**
  38653. * Defines the buttons associated with the input to handle camera move.
  38654. */
  38655. buttons: number[];
  38656. /**
  38657. * Defines the pointer angular sensibility along the X axis or how fast is
  38658. * the camera rotating.
  38659. */
  38660. angularSensibilityX: number;
  38661. /**
  38662. * Defines the pointer angular sensibility along the Y axis or how fast is
  38663. * the camera rotating.
  38664. */
  38665. angularSensibilityY: number;
  38666. /**
  38667. * Defines the pointer pinch precision or how fast is the camera zooming.
  38668. */
  38669. pinchPrecision: number;
  38670. /**
  38671. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38672. * from 0.
  38673. * It defines the percentage of current camera.radius to use as delta when
  38674. * pinch zoom is used.
  38675. */
  38676. pinchDeltaPercentage: number;
  38677. /**
  38678. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38679. * that any object in the plane at the camera's target point will scale
  38680. * perfectly with finger motion.
  38681. * Overrides pinchDeltaPercentage and pinchPrecision.
  38682. */
  38683. useNaturalPinchZoom: boolean;
  38684. /**
  38685. * Defines the pointer panning sensibility or how fast is the camera moving.
  38686. */
  38687. panningSensibility: number;
  38688. /**
  38689. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38690. */
  38691. multiTouchPanning: boolean;
  38692. /**
  38693. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38694. * zoom (pinch) through multitouch.
  38695. */
  38696. multiTouchPanAndZoom: boolean;
  38697. /**
  38698. * Revers pinch action direction.
  38699. */
  38700. pinchInwards: boolean;
  38701. private _isPanClick;
  38702. private _twoFingerActivityCount;
  38703. private _isPinching;
  38704. /**
  38705. * Called on pointer POINTERMOVE event if only a single touch is active.
  38706. */
  38707. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38708. /**
  38709. * Called on pointer POINTERDOUBLETAP event.
  38710. */
  38711. protected onDoubleTap(type: string): void;
  38712. /**
  38713. * Called on pointer POINTERMOVE event if multiple touches are active.
  38714. */
  38715. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38716. /**
  38717. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38718. * press.
  38719. */
  38720. protected onButtonDown(evt: PointerEvent): void;
  38721. /**
  38722. * Called each time a new POINTERUP event occurs. Ie, for each button
  38723. * release.
  38724. */
  38725. protected onButtonUp(evt: PointerEvent): void;
  38726. /**
  38727. * Called when window becomes inactive.
  38728. */
  38729. protected onLostFocus(): void;
  38730. }
  38731. }
  38732. declare module BABYLON {
  38733. /**
  38734. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38736. */
  38737. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38738. /**
  38739. * Defines the camera the input is attached to.
  38740. */
  38741. camera: ArcRotateCamera;
  38742. /**
  38743. * Defines the list of key codes associated with the up action (increase alpha)
  38744. */
  38745. keysUp: number[];
  38746. /**
  38747. * Defines the list of key codes associated with the down action (decrease alpha)
  38748. */
  38749. keysDown: number[];
  38750. /**
  38751. * Defines the list of key codes associated with the left action (increase beta)
  38752. */
  38753. keysLeft: number[];
  38754. /**
  38755. * Defines the list of key codes associated with the right action (decrease beta)
  38756. */
  38757. keysRight: number[];
  38758. /**
  38759. * Defines the list of key codes associated with the reset action.
  38760. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38761. */
  38762. keysReset: number[];
  38763. /**
  38764. * Defines the panning sensibility of the inputs.
  38765. * (How fast is the camera panning)
  38766. */
  38767. panningSensibility: number;
  38768. /**
  38769. * Defines the zooming sensibility of the inputs.
  38770. * (How fast is the camera zooming)
  38771. */
  38772. zoomingSensibility: number;
  38773. /**
  38774. * Defines whether maintaining the alt key down switch the movement mode from
  38775. * orientation to zoom.
  38776. */
  38777. useAltToZoom: boolean;
  38778. /**
  38779. * Rotation speed of the camera
  38780. */
  38781. angularSpeed: number;
  38782. private _keys;
  38783. private _ctrlPressed;
  38784. private _altPressed;
  38785. private _onCanvasBlurObserver;
  38786. private _onKeyboardObserver;
  38787. private _engine;
  38788. private _scene;
  38789. /**
  38790. * Attach the input controls to a specific dom element to get the input from.
  38791. * @param element Defines the element the controls should be listened from
  38792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38793. */
  38794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38795. /**
  38796. * Detach the current controls from the specified dom element.
  38797. * @param element Defines the element to stop listening the inputs from
  38798. */
  38799. detachControl(element: Nullable<HTMLElement>): void;
  38800. /**
  38801. * Update the current camera state depending on the inputs that have been used this frame.
  38802. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38803. */
  38804. checkInputs(): void;
  38805. /**
  38806. * Gets the class name of the current intput.
  38807. * @returns the class name
  38808. */
  38809. getClassName(): string;
  38810. /**
  38811. * Get the friendly name associated with the input class.
  38812. * @returns the input friendly name
  38813. */
  38814. getSimpleName(): string;
  38815. }
  38816. }
  38817. declare module BABYLON {
  38818. /**
  38819. * Manage the mouse wheel inputs to control an arc rotate camera.
  38820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38821. */
  38822. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38823. /**
  38824. * Defines the camera the input is attached to.
  38825. */
  38826. camera: ArcRotateCamera;
  38827. /**
  38828. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38829. */
  38830. wheelPrecision: number;
  38831. /**
  38832. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38833. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38834. */
  38835. wheelDeltaPercentage: number;
  38836. private _wheel;
  38837. private _observer;
  38838. private computeDeltaFromMouseWheelLegacyEvent;
  38839. /**
  38840. * Attach the input controls to a specific dom element to get the input from.
  38841. * @param element Defines the element the controls should be listened from
  38842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38843. */
  38844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38845. /**
  38846. * Detach the current controls from the specified dom element.
  38847. * @param element Defines the element to stop listening the inputs from
  38848. */
  38849. detachControl(element: Nullable<HTMLElement>): void;
  38850. /**
  38851. * Gets the class name of the current intput.
  38852. * @returns the class name
  38853. */
  38854. getClassName(): string;
  38855. /**
  38856. * Get the friendly name associated with the input class.
  38857. * @returns the input friendly name
  38858. */
  38859. getSimpleName(): string;
  38860. }
  38861. }
  38862. declare module BABYLON {
  38863. /**
  38864. * Default Inputs manager for the ArcRotateCamera.
  38865. * It groups all the default supported inputs for ease of use.
  38866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38867. */
  38868. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38869. /**
  38870. * Instantiates a new ArcRotateCameraInputsManager.
  38871. * @param camera Defines the camera the inputs belong to
  38872. */
  38873. constructor(camera: ArcRotateCamera);
  38874. /**
  38875. * Add mouse wheel input support to the input manager.
  38876. * @returns the current input manager
  38877. */
  38878. addMouseWheel(): ArcRotateCameraInputsManager;
  38879. /**
  38880. * Add pointers input support to the input manager.
  38881. * @returns the current input manager
  38882. */
  38883. addPointers(): ArcRotateCameraInputsManager;
  38884. /**
  38885. * Add keyboard input support to the input manager.
  38886. * @returns the current input manager
  38887. */
  38888. addKeyboard(): ArcRotateCameraInputsManager;
  38889. }
  38890. }
  38891. declare module BABYLON {
  38892. /**
  38893. * This represents an orbital type of camera.
  38894. *
  38895. * 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.
  38896. * 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.
  38897. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38898. */
  38899. export class ArcRotateCamera extends TargetCamera {
  38900. /**
  38901. * Defines the rotation angle of the camera along the longitudinal axis.
  38902. */
  38903. alpha: number;
  38904. /**
  38905. * Defines the rotation angle of the camera along the latitudinal axis.
  38906. */
  38907. beta: number;
  38908. /**
  38909. * Defines the radius of the camera from it s target point.
  38910. */
  38911. radius: number;
  38912. protected _target: Vector3;
  38913. protected _targetHost: Nullable<AbstractMesh>;
  38914. /**
  38915. * Defines the target point of the camera.
  38916. * The camera looks towards it form the radius distance.
  38917. */
  38918. get target(): Vector3;
  38919. set target(value: Vector3);
  38920. /**
  38921. * Define the current local position of the camera in the scene
  38922. */
  38923. get position(): Vector3;
  38924. set position(newPosition: Vector3);
  38925. protected _upVector: Vector3;
  38926. protected _upToYMatrix: Matrix;
  38927. protected _YToUpMatrix: Matrix;
  38928. /**
  38929. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38930. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38931. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38932. */
  38933. set upVector(vec: Vector3);
  38934. get upVector(): Vector3;
  38935. /**
  38936. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38937. */
  38938. setMatUp(): void;
  38939. /**
  38940. * Current inertia value on the longitudinal axis.
  38941. * The bigger this number the longer it will take for the camera to stop.
  38942. */
  38943. inertialAlphaOffset: number;
  38944. /**
  38945. * Current inertia value on the latitudinal axis.
  38946. * The bigger this number the longer it will take for the camera to stop.
  38947. */
  38948. inertialBetaOffset: number;
  38949. /**
  38950. * Current inertia value on the radius axis.
  38951. * The bigger this number the longer it will take for the camera to stop.
  38952. */
  38953. inertialRadiusOffset: number;
  38954. /**
  38955. * Minimum allowed angle on the longitudinal axis.
  38956. * This can help limiting how the Camera is able to move in the scene.
  38957. */
  38958. lowerAlphaLimit: Nullable<number>;
  38959. /**
  38960. * Maximum allowed angle on the longitudinal axis.
  38961. * This can help limiting how the Camera is able to move in the scene.
  38962. */
  38963. upperAlphaLimit: Nullable<number>;
  38964. /**
  38965. * Minimum allowed angle on the latitudinal axis.
  38966. * This can help limiting how the Camera is able to move in the scene.
  38967. */
  38968. lowerBetaLimit: number;
  38969. /**
  38970. * Maximum allowed angle on the latitudinal axis.
  38971. * This can help limiting how the Camera is able to move in the scene.
  38972. */
  38973. upperBetaLimit: number;
  38974. /**
  38975. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38976. * This can help limiting how the Camera is able to move in the scene.
  38977. */
  38978. lowerRadiusLimit: Nullable<number>;
  38979. /**
  38980. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38981. * This can help limiting how the Camera is able to move in the scene.
  38982. */
  38983. upperRadiusLimit: Nullable<number>;
  38984. /**
  38985. * Defines the current inertia value used during panning of the camera along the X axis.
  38986. */
  38987. inertialPanningX: number;
  38988. /**
  38989. * Defines the current inertia value used during panning of the camera along the Y axis.
  38990. */
  38991. inertialPanningY: number;
  38992. /**
  38993. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38994. * Basically if your fingers moves away from more than this distance you will be considered
  38995. * in pinch mode.
  38996. */
  38997. pinchToPanMaxDistance: number;
  38998. /**
  38999. * Defines the maximum distance the camera can pan.
  39000. * This could help keeping the cammera always in your scene.
  39001. */
  39002. panningDistanceLimit: Nullable<number>;
  39003. /**
  39004. * Defines the target of the camera before paning.
  39005. */
  39006. panningOriginTarget: Vector3;
  39007. /**
  39008. * Defines the value of the inertia used during panning.
  39009. * 0 would mean stop inertia and one would mean no decelleration at all.
  39010. */
  39011. panningInertia: number;
  39012. /**
  39013. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39014. */
  39015. get angularSensibilityX(): number;
  39016. set angularSensibilityX(value: number);
  39017. /**
  39018. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39019. */
  39020. get angularSensibilityY(): number;
  39021. set angularSensibilityY(value: number);
  39022. /**
  39023. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39024. */
  39025. get pinchPrecision(): number;
  39026. set pinchPrecision(value: number);
  39027. /**
  39028. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39029. * It will be used instead of pinchDeltaPrecision if different from 0.
  39030. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39031. */
  39032. get pinchDeltaPercentage(): number;
  39033. set pinchDeltaPercentage(value: number);
  39034. /**
  39035. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39036. * and pinch delta percentage.
  39037. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39038. * that any object in the plane at the camera's target point will scale
  39039. * perfectly with finger motion.
  39040. */
  39041. get useNaturalPinchZoom(): boolean;
  39042. set useNaturalPinchZoom(value: boolean);
  39043. /**
  39044. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39045. */
  39046. get panningSensibility(): number;
  39047. set panningSensibility(value: number);
  39048. /**
  39049. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39050. */
  39051. get keysUp(): number[];
  39052. set keysUp(value: number[]);
  39053. /**
  39054. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39055. */
  39056. get keysDown(): number[];
  39057. set keysDown(value: number[]);
  39058. /**
  39059. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39060. */
  39061. get keysLeft(): number[];
  39062. set keysLeft(value: number[]);
  39063. /**
  39064. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39065. */
  39066. get keysRight(): number[];
  39067. set keysRight(value: number[]);
  39068. /**
  39069. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39070. */
  39071. get wheelPrecision(): number;
  39072. set wheelPrecision(value: number);
  39073. /**
  39074. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39075. * It will be used instead of pinchDeltaPrecision if different from 0.
  39076. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39077. */
  39078. get wheelDeltaPercentage(): number;
  39079. set wheelDeltaPercentage(value: number);
  39080. /**
  39081. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39082. */
  39083. zoomOnFactor: number;
  39084. /**
  39085. * Defines a screen offset for the camera position.
  39086. */
  39087. targetScreenOffset: Vector2;
  39088. /**
  39089. * Allows the camera to be completely reversed.
  39090. * If false the camera can not arrive upside down.
  39091. */
  39092. allowUpsideDown: boolean;
  39093. /**
  39094. * Define if double tap/click is used to restore the previously saved state of the camera.
  39095. */
  39096. useInputToRestoreState: boolean;
  39097. /** @hidden */
  39098. _viewMatrix: Matrix;
  39099. /** @hidden */
  39100. _useCtrlForPanning: boolean;
  39101. /** @hidden */
  39102. _panningMouseButton: number;
  39103. /**
  39104. * Defines the input associated to the camera.
  39105. */
  39106. inputs: ArcRotateCameraInputsManager;
  39107. /** @hidden */
  39108. _reset: () => void;
  39109. /**
  39110. * Defines the allowed panning axis.
  39111. */
  39112. panningAxis: Vector3;
  39113. protected _localDirection: Vector3;
  39114. protected _transformedDirection: Vector3;
  39115. private _bouncingBehavior;
  39116. /**
  39117. * Gets the bouncing behavior of the camera if it has been enabled.
  39118. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39119. */
  39120. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39121. /**
  39122. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39123. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39124. */
  39125. get useBouncingBehavior(): boolean;
  39126. set useBouncingBehavior(value: boolean);
  39127. private _framingBehavior;
  39128. /**
  39129. * Gets the framing behavior of the camera if it has been enabled.
  39130. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39131. */
  39132. get framingBehavior(): Nullable<FramingBehavior>;
  39133. /**
  39134. * Defines if the framing behavior of the camera is enabled on the camera.
  39135. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39136. */
  39137. get useFramingBehavior(): boolean;
  39138. set useFramingBehavior(value: boolean);
  39139. private _autoRotationBehavior;
  39140. /**
  39141. * Gets the auto rotation behavior of the camera if it has been enabled.
  39142. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39143. */
  39144. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39145. /**
  39146. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39147. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39148. */
  39149. get useAutoRotationBehavior(): boolean;
  39150. set useAutoRotationBehavior(value: boolean);
  39151. /**
  39152. * Observable triggered when the mesh target has been changed on the camera.
  39153. */
  39154. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39155. /**
  39156. * Event raised when the camera is colliding with a mesh.
  39157. */
  39158. onCollide: (collidedMesh: AbstractMesh) => void;
  39159. /**
  39160. * Defines whether the camera should check collision with the objects oh the scene.
  39161. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39162. */
  39163. checkCollisions: boolean;
  39164. /**
  39165. * Defines the collision radius of the camera.
  39166. * This simulates a sphere around the camera.
  39167. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39168. */
  39169. collisionRadius: Vector3;
  39170. protected _collider: Collider;
  39171. protected _previousPosition: Vector3;
  39172. protected _collisionVelocity: Vector3;
  39173. protected _newPosition: Vector3;
  39174. protected _previousAlpha: number;
  39175. protected _previousBeta: number;
  39176. protected _previousRadius: number;
  39177. protected _collisionTriggered: boolean;
  39178. protected _targetBoundingCenter: Nullable<Vector3>;
  39179. private _computationVector;
  39180. /**
  39181. * Instantiates a new ArcRotateCamera in a given scene
  39182. * @param name Defines the name of the camera
  39183. * @param alpha Defines the camera rotation along the logitudinal axis
  39184. * @param beta Defines the camera rotation along the latitudinal axis
  39185. * @param radius Defines the camera distance from its target
  39186. * @param target Defines the camera target
  39187. * @param scene Defines the scene the camera belongs to
  39188. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39189. */
  39190. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39191. /** @hidden */
  39192. _initCache(): void;
  39193. /** @hidden */
  39194. _updateCache(ignoreParentClass?: boolean): void;
  39195. protected _getTargetPosition(): Vector3;
  39196. private _storedAlpha;
  39197. private _storedBeta;
  39198. private _storedRadius;
  39199. private _storedTarget;
  39200. private _storedTargetScreenOffset;
  39201. /**
  39202. * Stores the current state of the camera (alpha, beta, radius and target)
  39203. * @returns the camera itself
  39204. */
  39205. storeState(): Camera;
  39206. /**
  39207. * @hidden
  39208. * Restored camera state. You must call storeState() first
  39209. */
  39210. _restoreStateValues(): boolean;
  39211. /** @hidden */
  39212. _isSynchronizedViewMatrix(): boolean;
  39213. /**
  39214. * Attached controls to the current camera.
  39215. * @param element Defines the element the controls should be listened from
  39216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39217. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39218. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39219. */
  39220. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39221. /**
  39222. * Detach the current controls from the camera.
  39223. * The camera will stop reacting to inputs.
  39224. * @param element Defines the element to stop listening the inputs from
  39225. */
  39226. detachControl(element: HTMLElement): void;
  39227. /** @hidden */
  39228. _checkInputs(): void;
  39229. protected _checkLimits(): void;
  39230. /**
  39231. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39232. */
  39233. rebuildAnglesAndRadius(): void;
  39234. /**
  39235. * Use a position to define the current camera related information like alpha, beta and radius
  39236. * @param position Defines the position to set the camera at
  39237. */
  39238. setPosition(position: Vector3): void;
  39239. /**
  39240. * Defines the target the camera should look at.
  39241. * This will automatically adapt alpha beta and radius to fit within the new target.
  39242. * @param target Defines the new target as a Vector or a mesh
  39243. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39244. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39245. */
  39246. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39247. /** @hidden */
  39248. _getViewMatrix(): Matrix;
  39249. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39250. /**
  39251. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39252. * @param meshes Defines the mesh to zoom on
  39253. * @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)
  39254. */
  39255. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39256. /**
  39257. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39258. * The target will be changed but the radius
  39259. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus 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. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39263. min: Vector3;
  39264. max: Vector3;
  39265. distance: number;
  39266. }, doNotUpdateMaxZ?: boolean): void;
  39267. /**
  39268. * @override
  39269. * Override Camera.createRigCamera
  39270. */
  39271. createRigCamera(name: string, cameraIndex: number): Camera;
  39272. /**
  39273. * @hidden
  39274. * @override
  39275. * Override Camera._updateRigCameras
  39276. */
  39277. _updateRigCameras(): void;
  39278. /**
  39279. * Destroy the camera and release the current resources hold by it.
  39280. */
  39281. dispose(): void;
  39282. /**
  39283. * Gets the current object class name.
  39284. * @return the class name
  39285. */
  39286. getClassName(): string;
  39287. }
  39288. }
  39289. declare module BABYLON {
  39290. /**
  39291. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39292. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39293. */
  39294. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39295. /**
  39296. * Gets the name of the behavior.
  39297. */
  39298. get name(): string;
  39299. private _zoomStopsAnimation;
  39300. private _idleRotationSpeed;
  39301. private _idleRotationWaitTime;
  39302. private _idleRotationSpinupTime;
  39303. /**
  39304. * Sets the flag that indicates if user zooming should stop animation.
  39305. */
  39306. set zoomStopsAnimation(flag: boolean);
  39307. /**
  39308. * Gets the flag that indicates if user zooming should stop animation.
  39309. */
  39310. get zoomStopsAnimation(): boolean;
  39311. /**
  39312. * Sets the default speed at which the camera rotates around the model.
  39313. */
  39314. set idleRotationSpeed(speed: number);
  39315. /**
  39316. * Gets the default speed at which the camera rotates around the model.
  39317. */
  39318. get idleRotationSpeed(): number;
  39319. /**
  39320. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39321. */
  39322. set idleRotationWaitTime(time: number);
  39323. /**
  39324. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39325. */
  39326. get idleRotationWaitTime(): number;
  39327. /**
  39328. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39329. */
  39330. set idleRotationSpinupTime(time: number);
  39331. /**
  39332. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39333. */
  39334. get idleRotationSpinupTime(): number;
  39335. /**
  39336. * Gets a value indicating if the camera is currently rotating because of this behavior
  39337. */
  39338. get rotationInProgress(): boolean;
  39339. private _onPrePointerObservableObserver;
  39340. private _onAfterCheckInputsObserver;
  39341. private _attachedCamera;
  39342. private _isPointerDown;
  39343. private _lastFrameTime;
  39344. private _lastInteractionTime;
  39345. private _cameraRotationSpeed;
  39346. /**
  39347. * Initializes the behavior.
  39348. */
  39349. init(): void;
  39350. /**
  39351. * Attaches the behavior to its arc rotate camera.
  39352. * @param camera Defines the camera to attach the behavior to
  39353. */
  39354. attach(camera: ArcRotateCamera): void;
  39355. /**
  39356. * Detaches the behavior from its current arc rotate camera.
  39357. */
  39358. detach(): void;
  39359. /**
  39360. * Returns true if user is scrolling.
  39361. * @return true if user is scrolling.
  39362. */
  39363. private _userIsZooming;
  39364. private _lastFrameRadius;
  39365. private _shouldAnimationStopForInteraction;
  39366. /**
  39367. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39368. */
  39369. private _applyUserInteraction;
  39370. private _userIsMoving;
  39371. }
  39372. }
  39373. declare module BABYLON {
  39374. /**
  39375. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39376. */
  39377. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39378. private ui;
  39379. /**
  39380. * The name of the behavior
  39381. */
  39382. name: string;
  39383. /**
  39384. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39385. */
  39386. distanceAwayFromFace: number;
  39387. /**
  39388. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39389. */
  39390. distanceAwayFromBottomOfFace: number;
  39391. private _faceVectors;
  39392. private _target;
  39393. private _scene;
  39394. private _onRenderObserver;
  39395. private _tmpMatrix;
  39396. private _tmpVector;
  39397. /**
  39398. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39399. * @param ui The transform node that should be attched to the mesh
  39400. */
  39401. constructor(ui: TransformNode);
  39402. /**
  39403. * Initializes the behavior
  39404. */
  39405. init(): void;
  39406. private _closestFace;
  39407. private _zeroVector;
  39408. private _lookAtTmpMatrix;
  39409. private _lookAtToRef;
  39410. /**
  39411. * Attaches the AttachToBoxBehavior to the passed in mesh
  39412. * @param target The mesh that the specified node will be attached to
  39413. */
  39414. attach(target: Mesh): void;
  39415. /**
  39416. * Detaches the behavior from the mesh
  39417. */
  39418. detach(): void;
  39419. }
  39420. }
  39421. declare module BABYLON {
  39422. /**
  39423. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39424. */
  39425. export class FadeInOutBehavior implements Behavior<Mesh> {
  39426. /**
  39427. * Time in milliseconds to delay before fading in (Default: 0)
  39428. */
  39429. delay: number;
  39430. /**
  39431. * Time in milliseconds for the mesh to fade in (Default: 300)
  39432. */
  39433. fadeInTime: number;
  39434. private _millisecondsPerFrame;
  39435. private _hovered;
  39436. private _hoverValue;
  39437. private _ownerNode;
  39438. /**
  39439. * Instatiates the FadeInOutBehavior
  39440. */
  39441. constructor();
  39442. /**
  39443. * The name of the behavior
  39444. */
  39445. get name(): string;
  39446. /**
  39447. * Initializes the behavior
  39448. */
  39449. init(): void;
  39450. /**
  39451. * Attaches the fade behavior on the passed in mesh
  39452. * @param ownerNode The mesh that will be faded in/out once attached
  39453. */
  39454. attach(ownerNode: Mesh): void;
  39455. /**
  39456. * Detaches the behavior from the mesh
  39457. */
  39458. detach(): void;
  39459. /**
  39460. * Triggers the mesh to begin fading in or out
  39461. * @param value if the object should fade in or out (true to fade in)
  39462. */
  39463. fadeIn(value: boolean): void;
  39464. private _update;
  39465. private _setAllVisibility;
  39466. }
  39467. }
  39468. declare module BABYLON {
  39469. /**
  39470. * Class containing a set of static utilities functions for managing Pivots
  39471. * @hidden
  39472. */
  39473. export class PivotTools {
  39474. private static _PivotCached;
  39475. private static _OldPivotPoint;
  39476. private static _PivotTranslation;
  39477. private static _PivotTmpVector;
  39478. /** @hidden */
  39479. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39480. /** @hidden */
  39481. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39482. }
  39483. }
  39484. declare module BABYLON {
  39485. /**
  39486. * Class containing static functions to help procedurally build meshes
  39487. */
  39488. export class PlaneBuilder {
  39489. /**
  39490. * Creates a plane mesh
  39491. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39492. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39493. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39495. * * 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
  39496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39497. * @param name defines the name of the mesh
  39498. * @param options defines the options used to create the mesh
  39499. * @param scene defines the hosting scene
  39500. * @returns the plane mesh
  39501. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39502. */
  39503. static CreatePlane(name: string, options: {
  39504. size?: number;
  39505. width?: number;
  39506. height?: number;
  39507. sideOrientation?: number;
  39508. frontUVs?: Vector4;
  39509. backUVs?: Vector4;
  39510. updatable?: boolean;
  39511. sourcePlane?: Plane;
  39512. }, scene?: Nullable<Scene>): Mesh;
  39513. }
  39514. }
  39515. declare module BABYLON {
  39516. /**
  39517. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39518. */
  39519. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39520. private static _AnyMouseID;
  39521. /**
  39522. * Abstract mesh the behavior is set on
  39523. */
  39524. attachedNode: AbstractMesh;
  39525. private _dragPlane;
  39526. private _scene;
  39527. private _pointerObserver;
  39528. private _beforeRenderObserver;
  39529. private static _planeScene;
  39530. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39531. /**
  39532. * 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)
  39533. */
  39534. maxDragAngle: number;
  39535. /**
  39536. * @hidden
  39537. */
  39538. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39539. /**
  39540. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39541. */
  39542. currentDraggingPointerID: number;
  39543. /**
  39544. * The last position where the pointer hit the drag plane in world space
  39545. */
  39546. lastDragPosition: Vector3;
  39547. /**
  39548. * If the behavior is currently in a dragging state
  39549. */
  39550. dragging: boolean;
  39551. /**
  39552. * 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)
  39553. */
  39554. dragDeltaRatio: number;
  39555. /**
  39556. * If the drag plane orientation should be updated during the dragging (Default: true)
  39557. */
  39558. updateDragPlane: boolean;
  39559. private _debugMode;
  39560. private _moving;
  39561. /**
  39562. * Fires each time the attached mesh is dragged with the pointer
  39563. * * delta between last drag position and current drag position in world space
  39564. * * dragDistance along the drag axis
  39565. * * dragPlaneNormal normal of the current drag plane used during the drag
  39566. * * dragPlanePoint in world space where the drag intersects the drag plane
  39567. */
  39568. onDragObservable: Observable<{
  39569. delta: Vector3;
  39570. dragPlanePoint: Vector3;
  39571. dragPlaneNormal: Vector3;
  39572. dragDistance: number;
  39573. pointerId: number;
  39574. }>;
  39575. /**
  39576. * Fires each time a drag begins (eg. mouse down on mesh)
  39577. */
  39578. onDragStartObservable: Observable<{
  39579. dragPlanePoint: Vector3;
  39580. pointerId: number;
  39581. }>;
  39582. /**
  39583. * Fires each time a drag ends (eg. mouse release after drag)
  39584. */
  39585. onDragEndObservable: Observable<{
  39586. dragPlanePoint: Vector3;
  39587. pointerId: number;
  39588. }>;
  39589. /**
  39590. * If the attached mesh should be moved when dragged
  39591. */
  39592. moveAttached: boolean;
  39593. /**
  39594. * If the drag behavior will react to drag events (Default: true)
  39595. */
  39596. enabled: boolean;
  39597. /**
  39598. * If pointer events should start and release the drag (Default: true)
  39599. */
  39600. startAndReleaseDragOnPointerEvents: boolean;
  39601. /**
  39602. * If camera controls should be detached during the drag
  39603. */
  39604. detachCameraControls: boolean;
  39605. /**
  39606. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39607. */
  39608. useObjectOrientationForDragging: boolean;
  39609. private _options;
  39610. /**
  39611. * Gets the options used by the behavior
  39612. */
  39613. get options(): {
  39614. dragAxis?: Vector3;
  39615. dragPlaneNormal?: Vector3;
  39616. };
  39617. /**
  39618. * Sets the options used by the behavior
  39619. */
  39620. set options(options: {
  39621. dragAxis?: Vector3;
  39622. dragPlaneNormal?: Vector3;
  39623. });
  39624. /**
  39625. * Creates a pointer drag behavior that can be attached to a mesh
  39626. * @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)
  39627. */
  39628. constructor(options?: {
  39629. dragAxis?: Vector3;
  39630. dragPlaneNormal?: Vector3;
  39631. });
  39632. /**
  39633. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39634. */
  39635. validateDrag: (targetPosition: Vector3) => boolean;
  39636. /**
  39637. * The name of the behavior
  39638. */
  39639. get name(): string;
  39640. /**
  39641. * Initializes the behavior
  39642. */
  39643. init(): void;
  39644. private _tmpVector;
  39645. private _alternatePickedPoint;
  39646. private _worldDragAxis;
  39647. private _targetPosition;
  39648. private _attachedElement;
  39649. /**
  39650. * Attaches the drag behavior the passed in mesh
  39651. * @param ownerNode The mesh that will be dragged around once attached
  39652. * @param predicate Predicate to use for pick filtering
  39653. */
  39654. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39655. /**
  39656. * Force relase the drag action by code.
  39657. */
  39658. releaseDrag(): void;
  39659. private _startDragRay;
  39660. private _lastPointerRay;
  39661. /**
  39662. * Simulates the start of a pointer drag event on the behavior
  39663. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39664. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39665. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39666. */
  39667. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39668. private _startDrag;
  39669. private _dragDelta;
  39670. private _moveDrag;
  39671. private _pickWithRayOnDragPlane;
  39672. private _pointA;
  39673. private _pointB;
  39674. private _pointC;
  39675. private _lineA;
  39676. private _lineB;
  39677. private _localAxis;
  39678. private _lookAt;
  39679. private _updateDragPlanePosition;
  39680. /**
  39681. * Detaches the behavior from the mesh
  39682. */
  39683. detach(): void;
  39684. }
  39685. }
  39686. declare module BABYLON {
  39687. /**
  39688. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39689. */
  39690. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39691. private _dragBehaviorA;
  39692. private _dragBehaviorB;
  39693. private _startDistance;
  39694. private _initialScale;
  39695. private _targetScale;
  39696. private _ownerNode;
  39697. private _sceneRenderObserver;
  39698. /**
  39699. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39700. */
  39701. constructor();
  39702. /**
  39703. * The name of the behavior
  39704. */
  39705. get name(): string;
  39706. /**
  39707. * Initializes the behavior
  39708. */
  39709. init(): void;
  39710. private _getCurrentDistance;
  39711. /**
  39712. * Attaches the scale behavior the passed in mesh
  39713. * @param ownerNode The mesh that will be scaled around once attached
  39714. */
  39715. attach(ownerNode: Mesh): void;
  39716. /**
  39717. * Detaches the behavior from the mesh
  39718. */
  39719. detach(): void;
  39720. }
  39721. }
  39722. declare module BABYLON {
  39723. /**
  39724. * 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
  39725. */
  39726. export class SixDofDragBehavior implements Behavior<Mesh> {
  39727. private static _virtualScene;
  39728. private _ownerNode;
  39729. private _sceneRenderObserver;
  39730. private _scene;
  39731. private _targetPosition;
  39732. private _virtualOriginMesh;
  39733. private _virtualDragMesh;
  39734. private _pointerObserver;
  39735. private _moving;
  39736. private _startingOrientation;
  39737. private _attachedElement;
  39738. /**
  39739. * 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)
  39740. */
  39741. private zDragFactor;
  39742. /**
  39743. * If the object should rotate to face the drag origin
  39744. */
  39745. rotateDraggedObject: boolean;
  39746. /**
  39747. * If the behavior is currently in a dragging state
  39748. */
  39749. dragging: boolean;
  39750. /**
  39751. * 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)
  39752. */
  39753. dragDeltaRatio: number;
  39754. /**
  39755. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39756. */
  39757. currentDraggingPointerID: number;
  39758. /**
  39759. * If camera controls should be detached during the drag
  39760. */
  39761. detachCameraControls: boolean;
  39762. /**
  39763. * Fires each time a drag starts
  39764. */
  39765. onDragStartObservable: Observable<{}>;
  39766. /**
  39767. * Fires each time a drag ends (eg. mouse release after drag)
  39768. */
  39769. onDragEndObservable: Observable<{}>;
  39770. /**
  39771. * 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
  39772. */
  39773. constructor();
  39774. /**
  39775. * The name of the behavior
  39776. */
  39777. get name(): string;
  39778. /**
  39779. * Initializes the behavior
  39780. */
  39781. init(): void;
  39782. /**
  39783. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39784. */
  39785. private get _pointerCamera();
  39786. /**
  39787. * Attaches the scale behavior the passed in mesh
  39788. * @param ownerNode The mesh that will be scaled around once attached
  39789. */
  39790. attach(ownerNode: Mesh): void;
  39791. /**
  39792. * Detaches the behavior from the mesh
  39793. */
  39794. detach(): void;
  39795. }
  39796. }
  39797. declare module BABYLON {
  39798. /**
  39799. * Class used to apply inverse kinematics to bones
  39800. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39801. */
  39802. export class BoneIKController {
  39803. private static _tmpVecs;
  39804. private static _tmpQuat;
  39805. private static _tmpMats;
  39806. /**
  39807. * Gets or sets the target mesh
  39808. */
  39809. targetMesh: AbstractMesh;
  39810. /** Gets or sets the mesh used as pole */
  39811. poleTargetMesh: AbstractMesh;
  39812. /**
  39813. * Gets or sets the bone used as pole
  39814. */
  39815. poleTargetBone: Nullable<Bone>;
  39816. /**
  39817. * Gets or sets the target position
  39818. */
  39819. targetPosition: Vector3;
  39820. /**
  39821. * Gets or sets the pole target position
  39822. */
  39823. poleTargetPosition: Vector3;
  39824. /**
  39825. * Gets or sets the pole target local offset
  39826. */
  39827. poleTargetLocalOffset: Vector3;
  39828. /**
  39829. * Gets or sets the pole angle
  39830. */
  39831. poleAngle: number;
  39832. /**
  39833. * Gets or sets the mesh associated with the controller
  39834. */
  39835. mesh: AbstractMesh;
  39836. /**
  39837. * 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)
  39838. */
  39839. slerpAmount: number;
  39840. private _bone1Quat;
  39841. private _bone1Mat;
  39842. private _bone2Ang;
  39843. private _bone1;
  39844. private _bone2;
  39845. private _bone1Length;
  39846. private _bone2Length;
  39847. private _maxAngle;
  39848. private _maxReach;
  39849. private _rightHandedSystem;
  39850. private _bendAxis;
  39851. private _slerping;
  39852. private _adjustRoll;
  39853. /**
  39854. * Gets or sets maximum allowed angle
  39855. */
  39856. get maxAngle(): number;
  39857. set maxAngle(value: number);
  39858. /**
  39859. * Creates a new BoneIKController
  39860. * @param mesh defines the mesh to control
  39861. * @param bone defines the bone to control
  39862. * @param options defines options to set up the controller
  39863. */
  39864. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39865. targetMesh?: AbstractMesh;
  39866. poleTargetMesh?: AbstractMesh;
  39867. poleTargetBone?: Bone;
  39868. poleTargetLocalOffset?: Vector3;
  39869. poleAngle?: number;
  39870. bendAxis?: Vector3;
  39871. maxAngle?: number;
  39872. slerpAmount?: number;
  39873. });
  39874. private _setMaxAngle;
  39875. /**
  39876. * Force the controller to update the bones
  39877. */
  39878. update(): void;
  39879. }
  39880. }
  39881. declare module BABYLON {
  39882. /**
  39883. * Class used to make a bone look toward a point in space
  39884. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39885. */
  39886. export class BoneLookController {
  39887. private static _tmpVecs;
  39888. private static _tmpQuat;
  39889. private static _tmpMats;
  39890. /**
  39891. * The target Vector3 that the bone will look at
  39892. */
  39893. target: Vector3;
  39894. /**
  39895. * The mesh that the bone is attached to
  39896. */
  39897. mesh: AbstractMesh;
  39898. /**
  39899. * The bone that will be looking to the target
  39900. */
  39901. bone: Bone;
  39902. /**
  39903. * The up axis of the coordinate system that is used when the bone is rotated
  39904. */
  39905. upAxis: Vector3;
  39906. /**
  39907. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39908. */
  39909. upAxisSpace: Space;
  39910. /**
  39911. * Used to make an adjustment to the yaw of the bone
  39912. */
  39913. adjustYaw: number;
  39914. /**
  39915. * Used to make an adjustment to the pitch of the bone
  39916. */
  39917. adjustPitch: number;
  39918. /**
  39919. * Used to make an adjustment to the roll of the bone
  39920. */
  39921. adjustRoll: number;
  39922. /**
  39923. * 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)
  39924. */
  39925. slerpAmount: number;
  39926. private _minYaw;
  39927. private _maxYaw;
  39928. private _minPitch;
  39929. private _maxPitch;
  39930. private _minYawSin;
  39931. private _minYawCos;
  39932. private _maxYawSin;
  39933. private _maxYawCos;
  39934. private _midYawConstraint;
  39935. private _minPitchTan;
  39936. private _maxPitchTan;
  39937. private _boneQuat;
  39938. private _slerping;
  39939. private _transformYawPitch;
  39940. private _transformYawPitchInv;
  39941. private _firstFrameSkipped;
  39942. private _yawRange;
  39943. private _fowardAxis;
  39944. /**
  39945. * Gets or sets the minimum yaw angle that the bone can look to
  39946. */
  39947. get minYaw(): number;
  39948. set minYaw(value: number);
  39949. /**
  39950. * Gets or sets the maximum yaw angle that the bone can look to
  39951. */
  39952. get maxYaw(): number;
  39953. set maxYaw(value: number);
  39954. /**
  39955. * Gets or sets the minimum pitch angle that the bone can look to
  39956. */
  39957. get minPitch(): number;
  39958. set minPitch(value: number);
  39959. /**
  39960. * Gets or sets the maximum pitch angle that the bone can look to
  39961. */
  39962. get maxPitch(): number;
  39963. set maxPitch(value: number);
  39964. /**
  39965. * Create a BoneLookController
  39966. * @param mesh the mesh that the bone belongs to
  39967. * @param bone the bone that will be looking to the target
  39968. * @param target the target Vector3 to look at
  39969. * @param options optional settings:
  39970. * * maxYaw: the maximum angle the bone will yaw to
  39971. * * minYaw: the minimum angle the bone will yaw to
  39972. * * maxPitch: the maximum angle the bone will pitch to
  39973. * * minPitch: the minimum angle the bone will yaw to
  39974. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39975. * * upAxis: the up axis of the coordinate system
  39976. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39977. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39978. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39979. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39980. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39981. * * adjustRoll: used to make an adjustment to the roll of the bone
  39982. **/
  39983. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39984. maxYaw?: number;
  39985. minYaw?: number;
  39986. maxPitch?: number;
  39987. minPitch?: number;
  39988. slerpAmount?: number;
  39989. upAxis?: Vector3;
  39990. upAxisSpace?: Space;
  39991. yawAxis?: Vector3;
  39992. pitchAxis?: Vector3;
  39993. adjustYaw?: number;
  39994. adjustPitch?: number;
  39995. adjustRoll?: number;
  39996. });
  39997. /**
  39998. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39999. */
  40000. update(): void;
  40001. private _getAngleDiff;
  40002. private _getAngleBetween;
  40003. private _isAngleBetween;
  40004. }
  40005. }
  40006. declare module BABYLON {
  40007. /**
  40008. * Manage the gamepad inputs to control an arc rotate camera.
  40009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40010. */
  40011. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40012. /**
  40013. * Defines the camera the input is attached to.
  40014. */
  40015. camera: ArcRotateCamera;
  40016. /**
  40017. * Defines the gamepad the input is gathering event from.
  40018. */
  40019. gamepad: Nullable<Gamepad>;
  40020. /**
  40021. * Defines the gamepad rotation sensiblity.
  40022. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40023. */
  40024. gamepadRotationSensibility: number;
  40025. /**
  40026. * Defines the gamepad move sensiblity.
  40027. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40028. */
  40029. gamepadMoveSensibility: number;
  40030. private _yAxisScale;
  40031. /**
  40032. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40033. */
  40034. get invertYAxis(): boolean;
  40035. set invertYAxis(value: boolean);
  40036. private _onGamepadConnectedObserver;
  40037. private _onGamepadDisconnectedObserver;
  40038. /**
  40039. * Attach the input controls to a specific dom element to get the input from.
  40040. * @param element Defines the element the controls should be listened from
  40041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40042. */
  40043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40044. /**
  40045. * Detach the current controls from the specified dom element.
  40046. * @param element Defines the element to stop listening the inputs from
  40047. */
  40048. detachControl(element: Nullable<HTMLElement>): void;
  40049. /**
  40050. * Update the current camera state depending on the inputs that have been used this frame.
  40051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40052. */
  40053. checkInputs(): void;
  40054. /**
  40055. * Gets the class name of the current intput.
  40056. * @returns the class name
  40057. */
  40058. getClassName(): string;
  40059. /**
  40060. * Get the friendly name associated with the input class.
  40061. * @returns the input friendly name
  40062. */
  40063. getSimpleName(): string;
  40064. }
  40065. }
  40066. declare module BABYLON {
  40067. interface ArcRotateCameraInputsManager {
  40068. /**
  40069. * Add orientation input support to the input manager.
  40070. * @returns the current input manager
  40071. */
  40072. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40073. }
  40074. /**
  40075. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40077. */
  40078. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40079. /**
  40080. * Defines the camera the input is attached to.
  40081. */
  40082. camera: ArcRotateCamera;
  40083. /**
  40084. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40085. */
  40086. alphaCorrection: number;
  40087. /**
  40088. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40089. */
  40090. gammaCorrection: number;
  40091. private _alpha;
  40092. private _gamma;
  40093. private _dirty;
  40094. private _deviceOrientationHandler;
  40095. /**
  40096. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40097. */
  40098. constructor();
  40099. /**
  40100. * Attach the input controls to a specific dom element to get the input from.
  40101. * @param element Defines the element the controls should be listened from
  40102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40103. */
  40104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40105. /** @hidden */
  40106. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40107. /**
  40108. * Update the current camera state depending on the inputs that have been used this frame.
  40109. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40110. */
  40111. checkInputs(): void;
  40112. /**
  40113. * Detach the current controls from the specified dom element.
  40114. * @param element Defines the element to stop listening the inputs from
  40115. */
  40116. detachControl(element: Nullable<HTMLElement>): void;
  40117. /**
  40118. * Gets the class name of the current intput.
  40119. * @returns the class name
  40120. */
  40121. getClassName(): string;
  40122. /**
  40123. * Get the friendly name associated with the input class.
  40124. * @returns the input friendly name
  40125. */
  40126. getSimpleName(): string;
  40127. }
  40128. }
  40129. declare module BABYLON {
  40130. /**
  40131. * Listen to mouse events to control the camera.
  40132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40133. */
  40134. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40135. /**
  40136. * Defines the camera the input is attached to.
  40137. */
  40138. camera: FlyCamera;
  40139. /**
  40140. * Defines if touch is enabled. (Default is true.)
  40141. */
  40142. touchEnabled: boolean;
  40143. /**
  40144. * Defines the buttons associated with the input to handle camera rotation.
  40145. */
  40146. buttons: number[];
  40147. /**
  40148. * Assign buttons for Yaw control.
  40149. */
  40150. buttonsYaw: number[];
  40151. /**
  40152. * Assign buttons for Pitch control.
  40153. */
  40154. buttonsPitch: number[];
  40155. /**
  40156. * Assign buttons for Roll control.
  40157. */
  40158. buttonsRoll: number[];
  40159. /**
  40160. * Detect if any button is being pressed while mouse is moved.
  40161. * -1 = Mouse locked.
  40162. * 0 = Left button.
  40163. * 1 = Middle Button.
  40164. * 2 = Right Button.
  40165. */
  40166. activeButton: number;
  40167. /**
  40168. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40169. * Higher values reduce its sensitivity.
  40170. */
  40171. angularSensibility: number;
  40172. private _mousemoveCallback;
  40173. private _observer;
  40174. private _rollObserver;
  40175. private previousPosition;
  40176. private noPreventDefault;
  40177. private element;
  40178. /**
  40179. * Listen to mouse events to control the camera.
  40180. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40182. */
  40183. constructor(touchEnabled?: boolean);
  40184. /**
  40185. * Attach the mouse control to the HTML DOM element.
  40186. * @param element Defines the element that listens to the input events.
  40187. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40188. */
  40189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40190. /**
  40191. * Detach the current controls from the specified dom element.
  40192. * @param element Defines the element to stop listening the inputs from
  40193. */
  40194. detachControl(element: Nullable<HTMLElement>): void;
  40195. /**
  40196. * Gets the class name of the current input.
  40197. * @returns the class name.
  40198. */
  40199. getClassName(): string;
  40200. /**
  40201. * Get the friendly name associated with the input class.
  40202. * @returns the input's friendly name.
  40203. */
  40204. getSimpleName(): string;
  40205. private _pointerInput;
  40206. private _onMouseMove;
  40207. /**
  40208. * Rotate camera by mouse offset.
  40209. */
  40210. private rotateCamera;
  40211. }
  40212. }
  40213. declare module BABYLON {
  40214. /**
  40215. * Default Inputs manager for the FlyCamera.
  40216. * It groups all the default supported inputs for ease of use.
  40217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40218. */
  40219. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40220. /**
  40221. * Instantiates a new FlyCameraInputsManager.
  40222. * @param camera Defines the camera the inputs belong to.
  40223. */
  40224. constructor(camera: FlyCamera);
  40225. /**
  40226. * Add keyboard input support to the input manager.
  40227. * @returns the new FlyCameraKeyboardMoveInput().
  40228. */
  40229. addKeyboard(): FlyCameraInputsManager;
  40230. /**
  40231. * Add mouse input support to the input manager.
  40232. * @param touchEnabled Enable touch screen support.
  40233. * @returns the new FlyCameraMouseInput().
  40234. */
  40235. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40236. }
  40237. }
  40238. declare module BABYLON {
  40239. /**
  40240. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40241. * such as in a 3D Space Shooter or a Flight Simulator.
  40242. */
  40243. export class FlyCamera extends TargetCamera {
  40244. /**
  40245. * Define the collision ellipsoid of the camera.
  40246. * This is helpful for simulating a camera body, like a player's body.
  40247. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40248. */
  40249. ellipsoid: Vector3;
  40250. /**
  40251. * Define an offset for the position of the ellipsoid around the camera.
  40252. * This can be helpful if the camera is attached away from the player's body center,
  40253. * such as at its head.
  40254. */
  40255. ellipsoidOffset: Vector3;
  40256. /**
  40257. * Enable or disable collisions of the camera with the rest of the scene objects.
  40258. */
  40259. checkCollisions: boolean;
  40260. /**
  40261. * Enable or disable gravity on the camera.
  40262. */
  40263. applyGravity: boolean;
  40264. /**
  40265. * Define the current direction the camera is moving to.
  40266. */
  40267. cameraDirection: Vector3;
  40268. /**
  40269. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40270. * This overrides and empties cameraRotation.
  40271. */
  40272. rotationQuaternion: Quaternion;
  40273. /**
  40274. * Track Roll to maintain the wanted Rolling when looking around.
  40275. */
  40276. _trackRoll: number;
  40277. /**
  40278. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40279. */
  40280. rollCorrect: number;
  40281. /**
  40282. * Mimic a banked turn, Rolling the camera when Yawing.
  40283. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40284. */
  40285. bankedTurn: boolean;
  40286. /**
  40287. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40288. */
  40289. bankedTurnLimit: number;
  40290. /**
  40291. * Value of 0 disables the banked Roll.
  40292. * Value of 1 is equal to the Yaw angle in radians.
  40293. */
  40294. bankedTurnMultiplier: number;
  40295. /**
  40296. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40297. */
  40298. inputs: FlyCameraInputsManager;
  40299. /**
  40300. * Gets the input sensibility for mouse input.
  40301. * Higher values reduce sensitivity.
  40302. */
  40303. get angularSensibility(): number;
  40304. /**
  40305. * Sets the input sensibility for a mouse input.
  40306. * Higher values reduce sensitivity.
  40307. */
  40308. set angularSensibility(value: number);
  40309. /**
  40310. * Get the keys for camera movement forward.
  40311. */
  40312. get keysForward(): number[];
  40313. /**
  40314. * Set the keys for camera movement forward.
  40315. */
  40316. set keysForward(value: number[]);
  40317. /**
  40318. * Get the keys for camera movement backward.
  40319. */
  40320. get keysBackward(): number[];
  40321. set keysBackward(value: number[]);
  40322. /**
  40323. * Get the keys for camera movement up.
  40324. */
  40325. get keysUp(): number[];
  40326. /**
  40327. * Set the keys for camera movement up.
  40328. */
  40329. set keysUp(value: number[]);
  40330. /**
  40331. * Get the keys for camera movement down.
  40332. */
  40333. get keysDown(): number[];
  40334. /**
  40335. * Set the keys for camera movement down.
  40336. */
  40337. set keysDown(value: number[]);
  40338. /**
  40339. * Get the keys for camera movement left.
  40340. */
  40341. get keysLeft(): number[];
  40342. /**
  40343. * Set the keys for camera movement left.
  40344. */
  40345. set keysLeft(value: number[]);
  40346. /**
  40347. * Set the keys for camera movement right.
  40348. */
  40349. get keysRight(): number[];
  40350. /**
  40351. * Set the keys for camera movement right.
  40352. */
  40353. set keysRight(value: number[]);
  40354. /**
  40355. * Event raised when the camera collides with a mesh in the scene.
  40356. */
  40357. onCollide: (collidedMesh: AbstractMesh) => void;
  40358. private _collider;
  40359. private _needMoveForGravity;
  40360. private _oldPosition;
  40361. private _diffPosition;
  40362. private _newPosition;
  40363. /** @hidden */
  40364. _localDirection: Vector3;
  40365. /** @hidden */
  40366. _transformedDirection: Vector3;
  40367. /**
  40368. * Instantiates a FlyCamera.
  40369. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40370. * such as in a 3D Space Shooter or a Flight Simulator.
  40371. * @param name Define the name of the camera in the scene.
  40372. * @param position Define the starting position of the camera in the scene.
  40373. * @param scene Define the scene the camera belongs to.
  40374. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40375. */
  40376. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40377. /**
  40378. * Attach a control to the HTML DOM element.
  40379. * @param element Defines the element that listens to the input events.
  40380. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40381. */
  40382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40383. /**
  40384. * Detach a control from the HTML DOM element.
  40385. * The camera will stop reacting to that input.
  40386. * @param element Defines the element that listens to the input events.
  40387. */
  40388. detachControl(element: HTMLElement): void;
  40389. private _collisionMask;
  40390. /**
  40391. * Get the mask that the camera ignores in collision events.
  40392. */
  40393. get collisionMask(): number;
  40394. /**
  40395. * Set the mask that the camera ignores in collision events.
  40396. */
  40397. set collisionMask(mask: number);
  40398. /** @hidden */
  40399. _collideWithWorld(displacement: Vector3): void;
  40400. /** @hidden */
  40401. private _onCollisionPositionChange;
  40402. /** @hidden */
  40403. _checkInputs(): void;
  40404. /** @hidden */
  40405. _decideIfNeedsToMove(): boolean;
  40406. /** @hidden */
  40407. _updatePosition(): void;
  40408. /**
  40409. * Restore the Roll to its target value at the rate specified.
  40410. * @param rate - Higher means slower restoring.
  40411. * @hidden
  40412. */
  40413. restoreRoll(rate: number): void;
  40414. /**
  40415. * Destroy the camera and release the current resources held by it.
  40416. */
  40417. dispose(): void;
  40418. /**
  40419. * Get the current object class name.
  40420. * @returns the class name.
  40421. */
  40422. getClassName(): string;
  40423. }
  40424. }
  40425. declare module BABYLON {
  40426. /**
  40427. * Listen to keyboard events to control the camera.
  40428. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40429. */
  40430. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40431. /**
  40432. * Defines the camera the input is attached to.
  40433. */
  40434. camera: FlyCamera;
  40435. /**
  40436. * The list of keyboard keys used to control the forward move of the camera.
  40437. */
  40438. keysForward: number[];
  40439. /**
  40440. * The list of keyboard keys used to control the backward move of the camera.
  40441. */
  40442. keysBackward: number[];
  40443. /**
  40444. * The list of keyboard keys used to control the forward move of the camera.
  40445. */
  40446. keysUp: number[];
  40447. /**
  40448. * The list of keyboard keys used to control the backward move of the camera.
  40449. */
  40450. keysDown: number[];
  40451. /**
  40452. * The list of keyboard keys used to control the right strafe move of the camera.
  40453. */
  40454. keysRight: number[];
  40455. /**
  40456. * The list of keyboard keys used to control the left strafe move of the camera.
  40457. */
  40458. keysLeft: number[];
  40459. private _keys;
  40460. private _onCanvasBlurObserver;
  40461. private _onKeyboardObserver;
  40462. private _engine;
  40463. private _scene;
  40464. /**
  40465. * Attach the input controls to a specific dom element to get the input from.
  40466. * @param element Defines the element the controls should be listened from
  40467. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40468. */
  40469. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40470. /**
  40471. * Detach the current controls from the specified dom element.
  40472. * @param element Defines the element to stop listening the inputs from
  40473. */
  40474. detachControl(element: Nullable<HTMLElement>): void;
  40475. /**
  40476. * Gets the class name of the current intput.
  40477. * @returns the class name
  40478. */
  40479. getClassName(): string;
  40480. /** @hidden */
  40481. _onLostFocus(e: FocusEvent): void;
  40482. /**
  40483. * Get the friendly name associated with the input class.
  40484. * @returns the input friendly name
  40485. */
  40486. getSimpleName(): string;
  40487. /**
  40488. * Update the current camera state depending on the inputs that have been used this frame.
  40489. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40490. */
  40491. checkInputs(): void;
  40492. }
  40493. }
  40494. declare module BABYLON {
  40495. /**
  40496. * Manage the mouse wheel inputs to control a follow camera.
  40497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40498. */
  40499. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40500. /**
  40501. * Defines the camera the input is attached to.
  40502. */
  40503. camera: FollowCamera;
  40504. /**
  40505. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40506. */
  40507. axisControlRadius: boolean;
  40508. /**
  40509. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40510. */
  40511. axisControlHeight: boolean;
  40512. /**
  40513. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40514. */
  40515. axisControlRotation: boolean;
  40516. /**
  40517. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40518. * relation to mouseWheel events.
  40519. */
  40520. wheelPrecision: number;
  40521. /**
  40522. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40523. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40524. */
  40525. wheelDeltaPercentage: number;
  40526. private _wheel;
  40527. private _observer;
  40528. /**
  40529. * Attach the input controls to a specific dom element to get the input from.
  40530. * @param element Defines the element the controls should be listened from
  40531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40532. */
  40533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40534. /**
  40535. * Detach the current controls from the specified dom element.
  40536. * @param element Defines the element to stop listening the inputs from
  40537. */
  40538. detachControl(element: Nullable<HTMLElement>): void;
  40539. /**
  40540. * Gets the class name of the current intput.
  40541. * @returns the class name
  40542. */
  40543. getClassName(): string;
  40544. /**
  40545. * Get the friendly name associated with the input class.
  40546. * @returns the input friendly name
  40547. */
  40548. getSimpleName(): string;
  40549. }
  40550. }
  40551. declare module BABYLON {
  40552. /**
  40553. * Manage the pointers inputs to control an follow camera.
  40554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40555. */
  40556. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40557. /**
  40558. * Defines the camera the input is attached to.
  40559. */
  40560. camera: FollowCamera;
  40561. /**
  40562. * Gets the class name of the current input.
  40563. * @returns the class name
  40564. */
  40565. getClassName(): string;
  40566. /**
  40567. * Defines the pointer angular sensibility along the X axis or how fast is
  40568. * the camera rotating.
  40569. * A negative number will reverse the axis direction.
  40570. */
  40571. angularSensibilityX: number;
  40572. /**
  40573. * Defines the pointer angular sensibility along the Y axis or how fast is
  40574. * the camera rotating.
  40575. * A negative number will reverse the axis direction.
  40576. */
  40577. angularSensibilityY: number;
  40578. /**
  40579. * Defines the pointer pinch precision or how fast is the camera zooming.
  40580. * A negative number will reverse the axis direction.
  40581. */
  40582. pinchPrecision: number;
  40583. /**
  40584. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40585. * from 0.
  40586. * It defines the percentage of current camera.radius to use as delta when
  40587. * pinch zoom is used.
  40588. */
  40589. pinchDeltaPercentage: number;
  40590. /**
  40591. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40592. */
  40593. axisXControlRadius: boolean;
  40594. /**
  40595. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40596. */
  40597. axisXControlHeight: boolean;
  40598. /**
  40599. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40600. */
  40601. axisXControlRotation: boolean;
  40602. /**
  40603. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40604. */
  40605. axisYControlRadius: boolean;
  40606. /**
  40607. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40608. */
  40609. axisYControlHeight: boolean;
  40610. /**
  40611. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40612. */
  40613. axisYControlRotation: boolean;
  40614. /**
  40615. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40616. */
  40617. axisPinchControlRadius: boolean;
  40618. /**
  40619. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40620. */
  40621. axisPinchControlHeight: boolean;
  40622. /**
  40623. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40624. */
  40625. axisPinchControlRotation: boolean;
  40626. /**
  40627. * Log error messages if basic misconfiguration has occurred.
  40628. */
  40629. warningEnable: boolean;
  40630. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40631. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40632. private _warningCounter;
  40633. private _warning;
  40634. }
  40635. }
  40636. declare module BABYLON {
  40637. /**
  40638. * Default Inputs manager for the FollowCamera.
  40639. * It groups all the default supported inputs for ease of use.
  40640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40641. */
  40642. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40643. /**
  40644. * Instantiates a new FollowCameraInputsManager.
  40645. * @param camera Defines the camera the inputs belong to
  40646. */
  40647. constructor(camera: FollowCamera);
  40648. /**
  40649. * Add keyboard input support to the input manager.
  40650. * @returns the current input manager
  40651. */
  40652. addKeyboard(): FollowCameraInputsManager;
  40653. /**
  40654. * Add mouse wheel input support to the input manager.
  40655. * @returns the current input manager
  40656. */
  40657. addMouseWheel(): FollowCameraInputsManager;
  40658. /**
  40659. * Add pointers input support to the input manager.
  40660. * @returns the current input manager
  40661. */
  40662. addPointers(): FollowCameraInputsManager;
  40663. /**
  40664. * Add orientation input support to the input manager.
  40665. * @returns the current input manager
  40666. */
  40667. addVRDeviceOrientation(): FollowCameraInputsManager;
  40668. }
  40669. }
  40670. declare module BABYLON {
  40671. /**
  40672. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40673. * an arc rotate version arcFollowCamera are available.
  40674. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40675. */
  40676. export class FollowCamera extends TargetCamera {
  40677. /**
  40678. * Distance the follow camera should follow an object at
  40679. */
  40680. radius: number;
  40681. /**
  40682. * Minimum allowed distance of the camera to the axis of rotation
  40683. * (The camera can not get closer).
  40684. * This can help limiting how the Camera is able to move in the scene.
  40685. */
  40686. lowerRadiusLimit: Nullable<number>;
  40687. /**
  40688. * Maximum allowed distance of the camera to the axis of rotation
  40689. * (The camera can not get further).
  40690. * This can help limiting how the Camera is able to move in the scene.
  40691. */
  40692. upperRadiusLimit: Nullable<number>;
  40693. /**
  40694. * Define a rotation offset between the camera and the object it follows
  40695. */
  40696. rotationOffset: number;
  40697. /**
  40698. * Minimum allowed angle to camera position relative to target object.
  40699. * This can help limiting how the Camera is able to move in the scene.
  40700. */
  40701. lowerRotationOffsetLimit: Nullable<number>;
  40702. /**
  40703. * Maximum allowed angle to camera position relative to target object.
  40704. * This can help limiting how the Camera is able to move in the scene.
  40705. */
  40706. upperRotationOffsetLimit: Nullable<number>;
  40707. /**
  40708. * Define a height offset between the camera and the object it follows.
  40709. * It can help following an object from the top (like a car chaing a plane)
  40710. */
  40711. heightOffset: number;
  40712. /**
  40713. * Minimum allowed height of camera position relative to target object.
  40714. * This can help limiting how the Camera is able to move in the scene.
  40715. */
  40716. lowerHeightOffsetLimit: Nullable<number>;
  40717. /**
  40718. * Maximum allowed height of camera position relative to target object.
  40719. * This can help limiting how the Camera is able to move in the scene.
  40720. */
  40721. upperHeightOffsetLimit: Nullable<number>;
  40722. /**
  40723. * Define how fast the camera can accelerate to follow it s target.
  40724. */
  40725. cameraAcceleration: number;
  40726. /**
  40727. * Define the speed limit of the camera following an object.
  40728. */
  40729. maxCameraSpeed: number;
  40730. /**
  40731. * Define the target of the camera.
  40732. */
  40733. lockedTarget: Nullable<AbstractMesh>;
  40734. /**
  40735. * Defines the input associated with the camera.
  40736. */
  40737. inputs: FollowCameraInputsManager;
  40738. /**
  40739. * Instantiates the follow camera.
  40740. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40741. * @param name Define the name of the camera in the scene
  40742. * @param position Define the position of the camera
  40743. * @param scene Define the scene the camera belong to
  40744. * @param lockedTarget Define the target of the camera
  40745. */
  40746. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40747. private _follow;
  40748. /**
  40749. * Attached controls to the current camera.
  40750. * @param element Defines the element the controls should be listened from
  40751. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40752. */
  40753. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40754. /**
  40755. * Detach the current controls from the camera.
  40756. * The camera will stop reacting to inputs.
  40757. * @param element Defines the element to stop listening the inputs from
  40758. */
  40759. detachControl(element: HTMLElement): void;
  40760. /** @hidden */
  40761. _checkInputs(): void;
  40762. private _checkLimits;
  40763. /**
  40764. * Gets the camera class name.
  40765. * @returns the class name
  40766. */
  40767. getClassName(): string;
  40768. }
  40769. /**
  40770. * Arc Rotate version of the follow camera.
  40771. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40772. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40773. */
  40774. export class ArcFollowCamera extends TargetCamera {
  40775. /** The longitudinal angle of the camera */
  40776. alpha: number;
  40777. /** The latitudinal angle of the camera */
  40778. beta: number;
  40779. /** The radius of the camera from its target */
  40780. radius: number;
  40781. /** Define the camera target (the messh it should follow) */
  40782. target: Nullable<AbstractMesh>;
  40783. private _cartesianCoordinates;
  40784. /**
  40785. * Instantiates a new ArcFollowCamera
  40786. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40787. * @param name Define the name of the camera
  40788. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40789. * @param beta Define the rotation angle of the camera around the elevation axis
  40790. * @param radius Define the radius of the camera from its target point
  40791. * @param target Define the target of the camera
  40792. * @param scene Define the scene the camera belongs to
  40793. */
  40794. constructor(name: string,
  40795. /** The longitudinal angle of the camera */
  40796. alpha: number,
  40797. /** The latitudinal angle of the camera */
  40798. beta: number,
  40799. /** The radius of the camera from its target */
  40800. radius: number,
  40801. /** Define the camera target (the messh it should follow) */
  40802. target: Nullable<AbstractMesh>, scene: Scene);
  40803. private _follow;
  40804. /** @hidden */
  40805. _checkInputs(): void;
  40806. /**
  40807. * Returns the class name of the object.
  40808. * It is mostly used internally for serialization purposes.
  40809. */
  40810. getClassName(): string;
  40811. }
  40812. }
  40813. declare module BABYLON {
  40814. /**
  40815. * Manage the keyboard inputs to control the movement of a follow camera.
  40816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40817. */
  40818. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40819. /**
  40820. * Defines the camera the input is attached to.
  40821. */
  40822. camera: FollowCamera;
  40823. /**
  40824. * Defines the list of key codes associated with the up action (increase heightOffset)
  40825. */
  40826. keysHeightOffsetIncr: number[];
  40827. /**
  40828. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40829. */
  40830. keysHeightOffsetDecr: number[];
  40831. /**
  40832. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40833. */
  40834. keysHeightOffsetModifierAlt: boolean;
  40835. /**
  40836. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40837. */
  40838. keysHeightOffsetModifierCtrl: boolean;
  40839. /**
  40840. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40841. */
  40842. keysHeightOffsetModifierShift: boolean;
  40843. /**
  40844. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40845. */
  40846. keysRotationOffsetIncr: number[];
  40847. /**
  40848. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40849. */
  40850. keysRotationOffsetDecr: number[];
  40851. /**
  40852. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40853. */
  40854. keysRotationOffsetModifierAlt: boolean;
  40855. /**
  40856. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40857. */
  40858. keysRotationOffsetModifierCtrl: boolean;
  40859. /**
  40860. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40861. */
  40862. keysRotationOffsetModifierShift: boolean;
  40863. /**
  40864. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40865. */
  40866. keysRadiusIncr: number[];
  40867. /**
  40868. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40869. */
  40870. keysRadiusDecr: number[];
  40871. /**
  40872. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40873. */
  40874. keysRadiusModifierAlt: boolean;
  40875. /**
  40876. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40877. */
  40878. keysRadiusModifierCtrl: boolean;
  40879. /**
  40880. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40881. */
  40882. keysRadiusModifierShift: boolean;
  40883. /**
  40884. * Defines the rate of change of heightOffset.
  40885. */
  40886. heightSensibility: number;
  40887. /**
  40888. * Defines the rate of change of rotationOffset.
  40889. */
  40890. rotationSensibility: number;
  40891. /**
  40892. * Defines the rate of change of radius.
  40893. */
  40894. radiusSensibility: number;
  40895. private _keys;
  40896. private _ctrlPressed;
  40897. private _altPressed;
  40898. private _shiftPressed;
  40899. private _onCanvasBlurObserver;
  40900. private _onKeyboardObserver;
  40901. private _engine;
  40902. private _scene;
  40903. /**
  40904. * Attach the input controls to a specific dom element to get the input from.
  40905. * @param element Defines the element the controls should be listened from
  40906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40907. */
  40908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40909. /**
  40910. * Detach the current controls from the specified dom element.
  40911. * @param element Defines the element to stop listening the inputs from
  40912. */
  40913. detachControl(element: Nullable<HTMLElement>): void;
  40914. /**
  40915. * Update the current camera state depending on the inputs that have been used this frame.
  40916. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40917. */
  40918. checkInputs(): void;
  40919. /**
  40920. * Gets the class name of the current input.
  40921. * @returns the class name
  40922. */
  40923. getClassName(): string;
  40924. /**
  40925. * Get the friendly name associated with the input class.
  40926. * @returns the input friendly name
  40927. */
  40928. getSimpleName(): string;
  40929. /**
  40930. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40931. * allow modification of the heightOffset value.
  40932. */
  40933. private _modifierHeightOffset;
  40934. /**
  40935. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40936. * allow modification of the rotationOffset value.
  40937. */
  40938. private _modifierRotationOffset;
  40939. /**
  40940. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40941. * allow modification of the radius value.
  40942. */
  40943. private _modifierRadius;
  40944. }
  40945. }
  40946. declare module BABYLON {
  40947. interface FreeCameraInputsManager {
  40948. /**
  40949. * @hidden
  40950. */
  40951. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40952. /**
  40953. * Add orientation input support to the input manager.
  40954. * @returns the current input manager
  40955. */
  40956. addDeviceOrientation(): FreeCameraInputsManager;
  40957. }
  40958. /**
  40959. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40960. * Screen rotation is taken into account.
  40961. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40962. */
  40963. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40964. private _camera;
  40965. private _screenOrientationAngle;
  40966. private _constantTranform;
  40967. private _screenQuaternion;
  40968. private _alpha;
  40969. private _beta;
  40970. private _gamma;
  40971. /**
  40972. * Can be used to detect if a device orientation sensor is available on a device
  40973. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40974. * @returns a promise that will resolve on orientation change
  40975. */
  40976. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40977. /**
  40978. * @hidden
  40979. */
  40980. _onDeviceOrientationChangedObservable: Observable<void>;
  40981. /**
  40982. * Instantiates a new input
  40983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40984. */
  40985. constructor();
  40986. /**
  40987. * Define the camera controlled by the input.
  40988. */
  40989. get camera(): FreeCamera;
  40990. set camera(camera: FreeCamera);
  40991. /**
  40992. * Attach the input controls to a specific dom element to get the input from.
  40993. * @param element Defines the element the controls should be listened from
  40994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40995. */
  40996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40997. private _orientationChanged;
  40998. private _deviceOrientation;
  40999. /**
  41000. * Detach the current controls from the specified dom element.
  41001. * @param element Defines the element to stop listening the inputs from
  41002. */
  41003. detachControl(element: Nullable<HTMLElement>): void;
  41004. /**
  41005. * Update the current camera state depending on the inputs that have been used this frame.
  41006. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41007. */
  41008. checkInputs(): void;
  41009. /**
  41010. * Gets the class name of the current intput.
  41011. * @returns the class name
  41012. */
  41013. getClassName(): string;
  41014. /**
  41015. * Get the friendly name associated with the input class.
  41016. * @returns the input friendly name
  41017. */
  41018. getSimpleName(): string;
  41019. }
  41020. }
  41021. declare module BABYLON {
  41022. /**
  41023. * Manage the gamepad inputs to control a free camera.
  41024. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41025. */
  41026. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41027. /**
  41028. * Define the camera the input is attached to.
  41029. */
  41030. camera: FreeCamera;
  41031. /**
  41032. * Define the Gamepad controlling the input
  41033. */
  41034. gamepad: Nullable<Gamepad>;
  41035. /**
  41036. * Defines the gamepad rotation sensiblity.
  41037. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41038. */
  41039. gamepadAngularSensibility: number;
  41040. /**
  41041. * Defines the gamepad move sensiblity.
  41042. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41043. */
  41044. gamepadMoveSensibility: number;
  41045. private _yAxisScale;
  41046. /**
  41047. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41048. */
  41049. get invertYAxis(): boolean;
  41050. set invertYAxis(value: boolean);
  41051. private _onGamepadConnectedObserver;
  41052. private _onGamepadDisconnectedObserver;
  41053. private _cameraTransform;
  41054. private _deltaTransform;
  41055. private _vector3;
  41056. private _vector2;
  41057. /**
  41058. * Attach the input controls to a specific dom element to get the input from.
  41059. * @param element Defines the element the controls should be listened from
  41060. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41061. */
  41062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41063. /**
  41064. * Detach the current controls from the specified dom element.
  41065. * @param element Defines the element to stop listening the inputs from
  41066. */
  41067. detachControl(element: Nullable<HTMLElement>): void;
  41068. /**
  41069. * Update the current camera state depending on the inputs that have been used this frame.
  41070. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41071. */
  41072. checkInputs(): void;
  41073. /**
  41074. * Gets the class name of the current intput.
  41075. * @returns the class name
  41076. */
  41077. getClassName(): string;
  41078. /**
  41079. * Get the friendly name associated with the input class.
  41080. * @returns the input friendly name
  41081. */
  41082. getSimpleName(): string;
  41083. }
  41084. }
  41085. declare module BABYLON {
  41086. /**
  41087. * Defines the potential axis of a Joystick
  41088. */
  41089. export enum JoystickAxis {
  41090. /** X axis */
  41091. X = 0,
  41092. /** Y axis */
  41093. Y = 1,
  41094. /** Z axis */
  41095. Z = 2
  41096. }
  41097. /**
  41098. * Class used to define virtual joystick (used in touch mode)
  41099. */
  41100. export class VirtualJoystick {
  41101. /**
  41102. * Gets or sets a boolean indicating that left and right values must be inverted
  41103. */
  41104. reverseLeftRight: boolean;
  41105. /**
  41106. * Gets or sets a boolean indicating that up and down values must be inverted
  41107. */
  41108. reverseUpDown: boolean;
  41109. /**
  41110. * Gets the offset value for the position (ie. the change of the position value)
  41111. */
  41112. deltaPosition: Vector3;
  41113. /**
  41114. * Gets a boolean indicating if the virtual joystick was pressed
  41115. */
  41116. pressed: boolean;
  41117. /**
  41118. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41119. */
  41120. static Canvas: Nullable<HTMLCanvasElement>;
  41121. private static _globalJoystickIndex;
  41122. private static vjCanvasContext;
  41123. private static vjCanvasWidth;
  41124. private static vjCanvasHeight;
  41125. private static halfWidth;
  41126. private _action;
  41127. private _axisTargetedByLeftAndRight;
  41128. private _axisTargetedByUpAndDown;
  41129. private _joystickSensibility;
  41130. private _inversedSensibility;
  41131. private _joystickPointerID;
  41132. private _joystickColor;
  41133. private _joystickPointerPos;
  41134. private _joystickPreviousPointerPos;
  41135. private _joystickPointerStartPos;
  41136. private _deltaJoystickVector;
  41137. private _leftJoystick;
  41138. private _touches;
  41139. private _onPointerDownHandlerRef;
  41140. private _onPointerMoveHandlerRef;
  41141. private _onPointerUpHandlerRef;
  41142. private _onResize;
  41143. /**
  41144. * Creates a new virtual joystick
  41145. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41146. */
  41147. constructor(leftJoystick?: boolean);
  41148. /**
  41149. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41150. * @param newJoystickSensibility defines the new sensibility
  41151. */
  41152. setJoystickSensibility(newJoystickSensibility: number): void;
  41153. private _onPointerDown;
  41154. private _onPointerMove;
  41155. private _onPointerUp;
  41156. /**
  41157. * Change the color of the virtual joystick
  41158. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41159. */
  41160. setJoystickColor(newColor: string): void;
  41161. /**
  41162. * Defines a callback to call when the joystick is touched
  41163. * @param action defines the callback
  41164. */
  41165. setActionOnTouch(action: () => any): void;
  41166. /**
  41167. * Defines which axis you'd like to control for left & right
  41168. * @param axis defines the axis to use
  41169. */
  41170. setAxisForLeftRight(axis: JoystickAxis): void;
  41171. /**
  41172. * Defines which axis you'd like to control for up & down
  41173. * @param axis defines the axis to use
  41174. */
  41175. setAxisForUpDown(axis: JoystickAxis): void;
  41176. private _drawVirtualJoystick;
  41177. /**
  41178. * Release internal HTML canvas
  41179. */
  41180. releaseCanvas(): void;
  41181. }
  41182. }
  41183. declare module BABYLON {
  41184. interface FreeCameraInputsManager {
  41185. /**
  41186. * Add virtual joystick input support to the input manager.
  41187. * @returns the current input manager
  41188. */
  41189. addVirtualJoystick(): FreeCameraInputsManager;
  41190. }
  41191. /**
  41192. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41194. */
  41195. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41196. /**
  41197. * Defines the camera the input is attached to.
  41198. */
  41199. camera: FreeCamera;
  41200. private _leftjoystick;
  41201. private _rightjoystick;
  41202. /**
  41203. * Gets the left stick of the virtual joystick.
  41204. * @returns The virtual Joystick
  41205. */
  41206. getLeftJoystick(): VirtualJoystick;
  41207. /**
  41208. * Gets the right stick of the virtual joystick.
  41209. * @returns The virtual Joystick
  41210. */
  41211. getRightJoystick(): VirtualJoystick;
  41212. /**
  41213. * Update the current camera state depending on the inputs that have been used this frame.
  41214. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41215. */
  41216. checkInputs(): void;
  41217. /**
  41218. * Attach the input controls to a specific dom element to get the input from.
  41219. * @param element Defines the element the controls should be listened from
  41220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41221. */
  41222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41223. /**
  41224. * Detach the current controls from the specified dom element.
  41225. * @param element Defines the element to stop listening the inputs from
  41226. */
  41227. detachControl(element: Nullable<HTMLElement>): void;
  41228. /**
  41229. * Gets the class name of the current intput.
  41230. * @returns the class name
  41231. */
  41232. getClassName(): string;
  41233. /**
  41234. * Get the friendly name associated with the input class.
  41235. * @returns the input friendly name
  41236. */
  41237. getSimpleName(): string;
  41238. }
  41239. }
  41240. declare module BABYLON {
  41241. /**
  41242. * This represents a FPS type of camera controlled by touch.
  41243. * This is like a universal camera minus the Gamepad controls.
  41244. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41245. */
  41246. export class TouchCamera extends FreeCamera {
  41247. /**
  41248. * Defines the touch sensibility for rotation.
  41249. * The higher the faster.
  41250. */
  41251. get touchAngularSensibility(): number;
  41252. set touchAngularSensibility(value: number);
  41253. /**
  41254. * Defines the touch sensibility for move.
  41255. * The higher the faster.
  41256. */
  41257. get touchMoveSensibility(): number;
  41258. set touchMoveSensibility(value: number);
  41259. /**
  41260. * Instantiates a new touch camera.
  41261. * This represents a FPS type of camera controlled by touch.
  41262. * This is like a universal camera minus the Gamepad controls.
  41263. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41264. * @param name Define the name of the camera in the scene
  41265. * @param position Define the start position of the camera in the scene
  41266. * @param scene Define the scene the camera belongs to
  41267. */
  41268. constructor(name: string, position: Vector3, scene: Scene);
  41269. /**
  41270. * Gets the current object class name.
  41271. * @return the class name
  41272. */
  41273. getClassName(): string;
  41274. /** @hidden */
  41275. _setupInputs(): void;
  41276. }
  41277. }
  41278. declare module BABYLON {
  41279. /**
  41280. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41281. * being tilted forward or back and left or right.
  41282. */
  41283. export class DeviceOrientationCamera extends FreeCamera {
  41284. private _initialQuaternion;
  41285. private _quaternionCache;
  41286. private _tmpDragQuaternion;
  41287. private _disablePointerInputWhenUsingDeviceOrientation;
  41288. /**
  41289. * Creates a new device orientation camera
  41290. * @param name The name of the camera
  41291. * @param position The start position camera
  41292. * @param scene The scene the camera belongs to
  41293. */
  41294. constructor(name: string, position: Vector3, scene: Scene);
  41295. /**
  41296. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41297. */
  41298. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41299. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41300. private _dragFactor;
  41301. /**
  41302. * Enabled turning on the y axis when the orientation sensor is active
  41303. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41304. */
  41305. enableHorizontalDragging(dragFactor?: number): void;
  41306. /**
  41307. * Gets the current instance class name ("DeviceOrientationCamera").
  41308. * This helps avoiding instanceof at run time.
  41309. * @returns the class name
  41310. */
  41311. getClassName(): string;
  41312. /**
  41313. * @hidden
  41314. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41315. */
  41316. _checkInputs(): void;
  41317. /**
  41318. * Reset the camera to its default orientation on the specified axis only.
  41319. * @param axis The axis to reset
  41320. */
  41321. resetToCurrentRotation(axis?: Axis): void;
  41322. }
  41323. }
  41324. declare module BABYLON {
  41325. /**
  41326. * Defines supported buttons for XBox360 compatible gamepads
  41327. */
  41328. export enum Xbox360Button {
  41329. /** A */
  41330. A = 0,
  41331. /** B */
  41332. B = 1,
  41333. /** X */
  41334. X = 2,
  41335. /** Y */
  41336. Y = 3,
  41337. /** Left button */
  41338. LB = 4,
  41339. /** Right button */
  41340. RB = 5,
  41341. /** Back */
  41342. Back = 8,
  41343. /** Start */
  41344. Start = 9,
  41345. /** Left stick */
  41346. LeftStick = 10,
  41347. /** Right stick */
  41348. RightStick = 11
  41349. }
  41350. /** Defines values for XBox360 DPad */
  41351. export enum Xbox360Dpad {
  41352. /** Up */
  41353. Up = 12,
  41354. /** Down */
  41355. Down = 13,
  41356. /** Left */
  41357. Left = 14,
  41358. /** Right */
  41359. Right = 15
  41360. }
  41361. /**
  41362. * Defines a XBox360 gamepad
  41363. */
  41364. export class Xbox360Pad extends Gamepad {
  41365. private _leftTrigger;
  41366. private _rightTrigger;
  41367. private _onlefttriggerchanged;
  41368. private _onrighttriggerchanged;
  41369. private _onbuttondown;
  41370. private _onbuttonup;
  41371. private _ondpaddown;
  41372. private _ondpadup;
  41373. /** Observable raised when a button is pressed */
  41374. onButtonDownObservable: Observable<Xbox360Button>;
  41375. /** Observable raised when a button is released */
  41376. onButtonUpObservable: Observable<Xbox360Button>;
  41377. /** Observable raised when a pad is pressed */
  41378. onPadDownObservable: Observable<Xbox360Dpad>;
  41379. /** Observable raised when a pad is released */
  41380. onPadUpObservable: Observable<Xbox360Dpad>;
  41381. private _buttonA;
  41382. private _buttonB;
  41383. private _buttonX;
  41384. private _buttonY;
  41385. private _buttonBack;
  41386. private _buttonStart;
  41387. private _buttonLB;
  41388. private _buttonRB;
  41389. private _buttonLeftStick;
  41390. private _buttonRightStick;
  41391. private _dPadUp;
  41392. private _dPadDown;
  41393. private _dPadLeft;
  41394. private _dPadRight;
  41395. private _isXboxOnePad;
  41396. /**
  41397. * Creates a new XBox360 gamepad object
  41398. * @param id defines the id of this gamepad
  41399. * @param index defines its index
  41400. * @param gamepad defines the internal HTML gamepad object
  41401. * @param xboxOne defines if it is a XBox One gamepad
  41402. */
  41403. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41404. /**
  41405. * Defines the callback to call when left trigger is pressed
  41406. * @param callback defines the callback to use
  41407. */
  41408. onlefttriggerchanged(callback: (value: number) => void): void;
  41409. /**
  41410. * Defines the callback to call when right trigger is pressed
  41411. * @param callback defines the callback to use
  41412. */
  41413. onrighttriggerchanged(callback: (value: number) => void): void;
  41414. /**
  41415. * Gets the left trigger value
  41416. */
  41417. get leftTrigger(): number;
  41418. /**
  41419. * Sets the left trigger value
  41420. */
  41421. set leftTrigger(newValue: number);
  41422. /**
  41423. * Gets the right trigger value
  41424. */
  41425. get rightTrigger(): number;
  41426. /**
  41427. * Sets the right trigger value
  41428. */
  41429. set rightTrigger(newValue: number);
  41430. /**
  41431. * Defines the callback to call when a button is pressed
  41432. * @param callback defines the callback to use
  41433. */
  41434. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41435. /**
  41436. * Defines the callback to call when a button is released
  41437. * @param callback defines the callback to use
  41438. */
  41439. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41440. /**
  41441. * Defines the callback to call when a pad is pressed
  41442. * @param callback defines the callback to use
  41443. */
  41444. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41445. /**
  41446. * Defines the callback to call when a pad is released
  41447. * @param callback defines the callback to use
  41448. */
  41449. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41450. private _setButtonValue;
  41451. private _setDPadValue;
  41452. /**
  41453. * Gets the value of the `A` button
  41454. */
  41455. get buttonA(): number;
  41456. /**
  41457. * Sets the value of the `A` button
  41458. */
  41459. set buttonA(value: number);
  41460. /**
  41461. * Gets the value of the `B` button
  41462. */
  41463. get buttonB(): number;
  41464. /**
  41465. * Sets the value of the `B` button
  41466. */
  41467. set buttonB(value: number);
  41468. /**
  41469. * Gets the value of the `X` button
  41470. */
  41471. get buttonX(): number;
  41472. /**
  41473. * Sets the value of the `X` button
  41474. */
  41475. set buttonX(value: number);
  41476. /**
  41477. * Gets the value of the `Y` button
  41478. */
  41479. get buttonY(): number;
  41480. /**
  41481. * Sets the value of the `Y` button
  41482. */
  41483. set buttonY(value: number);
  41484. /**
  41485. * Gets the value of the `Start` button
  41486. */
  41487. get buttonStart(): number;
  41488. /**
  41489. * Sets the value of the `Start` button
  41490. */
  41491. set buttonStart(value: number);
  41492. /**
  41493. * Gets the value of the `Back` button
  41494. */
  41495. get buttonBack(): number;
  41496. /**
  41497. * Sets the value of the `Back` button
  41498. */
  41499. set buttonBack(value: number);
  41500. /**
  41501. * Gets the value of the `Left` button
  41502. */
  41503. get buttonLB(): number;
  41504. /**
  41505. * Sets the value of the `Left` button
  41506. */
  41507. set buttonLB(value: number);
  41508. /**
  41509. * Gets the value of the `Right` button
  41510. */
  41511. get buttonRB(): number;
  41512. /**
  41513. * Sets the value of the `Right` button
  41514. */
  41515. set buttonRB(value: number);
  41516. /**
  41517. * Gets the value of the Left joystick
  41518. */
  41519. get buttonLeftStick(): number;
  41520. /**
  41521. * Sets the value of the Left joystick
  41522. */
  41523. set buttonLeftStick(value: number);
  41524. /**
  41525. * Gets the value of the Right joystick
  41526. */
  41527. get buttonRightStick(): number;
  41528. /**
  41529. * Sets the value of the Right joystick
  41530. */
  41531. set buttonRightStick(value: number);
  41532. /**
  41533. * Gets the value of D-pad up
  41534. */
  41535. get dPadUp(): number;
  41536. /**
  41537. * Sets the value of D-pad up
  41538. */
  41539. set dPadUp(value: number);
  41540. /**
  41541. * Gets the value of D-pad down
  41542. */
  41543. get dPadDown(): number;
  41544. /**
  41545. * Sets the value of D-pad down
  41546. */
  41547. set dPadDown(value: number);
  41548. /**
  41549. * Gets the value of D-pad left
  41550. */
  41551. get dPadLeft(): number;
  41552. /**
  41553. * Sets the value of D-pad left
  41554. */
  41555. set dPadLeft(value: number);
  41556. /**
  41557. * Gets the value of D-pad right
  41558. */
  41559. get dPadRight(): number;
  41560. /**
  41561. * Sets the value of D-pad right
  41562. */
  41563. set dPadRight(value: number);
  41564. /**
  41565. * Force the gamepad to synchronize with device values
  41566. */
  41567. update(): void;
  41568. /**
  41569. * Disposes the gamepad
  41570. */
  41571. dispose(): void;
  41572. }
  41573. }
  41574. declare module BABYLON {
  41575. /**
  41576. * Defines supported buttons for DualShock compatible gamepads
  41577. */
  41578. export enum DualShockButton {
  41579. /** Cross */
  41580. Cross = 0,
  41581. /** Circle */
  41582. Circle = 1,
  41583. /** Square */
  41584. Square = 2,
  41585. /** Triangle */
  41586. Triangle = 3,
  41587. /** L1 */
  41588. L1 = 4,
  41589. /** R1 */
  41590. R1 = 5,
  41591. /** Share */
  41592. Share = 8,
  41593. /** Options */
  41594. Options = 9,
  41595. /** Left stick */
  41596. LeftStick = 10,
  41597. /** Right stick */
  41598. RightStick = 11
  41599. }
  41600. /** Defines values for DualShock DPad */
  41601. export enum DualShockDpad {
  41602. /** Up */
  41603. Up = 12,
  41604. /** Down */
  41605. Down = 13,
  41606. /** Left */
  41607. Left = 14,
  41608. /** Right */
  41609. Right = 15
  41610. }
  41611. /**
  41612. * Defines a DualShock gamepad
  41613. */
  41614. export class DualShockPad extends Gamepad {
  41615. private _leftTrigger;
  41616. private _rightTrigger;
  41617. private _onlefttriggerchanged;
  41618. private _onrighttriggerchanged;
  41619. private _onbuttondown;
  41620. private _onbuttonup;
  41621. private _ondpaddown;
  41622. private _ondpadup;
  41623. /** Observable raised when a button is pressed */
  41624. onButtonDownObservable: Observable<DualShockButton>;
  41625. /** Observable raised when a button is released */
  41626. onButtonUpObservable: Observable<DualShockButton>;
  41627. /** Observable raised when a pad is pressed */
  41628. onPadDownObservable: Observable<DualShockDpad>;
  41629. /** Observable raised when a pad is released */
  41630. onPadUpObservable: Observable<DualShockDpad>;
  41631. private _buttonCross;
  41632. private _buttonCircle;
  41633. private _buttonSquare;
  41634. private _buttonTriangle;
  41635. private _buttonShare;
  41636. private _buttonOptions;
  41637. private _buttonL1;
  41638. private _buttonR1;
  41639. private _buttonLeftStick;
  41640. private _buttonRightStick;
  41641. private _dPadUp;
  41642. private _dPadDown;
  41643. private _dPadLeft;
  41644. private _dPadRight;
  41645. /**
  41646. * Creates a new DualShock gamepad object
  41647. * @param id defines the id of this gamepad
  41648. * @param index defines its index
  41649. * @param gamepad defines the internal HTML gamepad object
  41650. */
  41651. constructor(id: string, index: number, gamepad: any);
  41652. /**
  41653. * Defines the callback to call when left trigger is pressed
  41654. * @param callback defines the callback to use
  41655. */
  41656. onlefttriggerchanged(callback: (value: number) => void): void;
  41657. /**
  41658. * Defines the callback to call when right trigger is pressed
  41659. * @param callback defines the callback to use
  41660. */
  41661. onrighttriggerchanged(callback: (value: number) => void): void;
  41662. /**
  41663. * Gets the left trigger value
  41664. */
  41665. get leftTrigger(): number;
  41666. /**
  41667. * Sets the left trigger value
  41668. */
  41669. set leftTrigger(newValue: number);
  41670. /**
  41671. * Gets the right trigger value
  41672. */
  41673. get rightTrigger(): number;
  41674. /**
  41675. * Sets the right trigger value
  41676. */
  41677. set rightTrigger(newValue: number);
  41678. /**
  41679. * Defines the callback to call when a button is pressed
  41680. * @param callback defines the callback to use
  41681. */
  41682. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41683. /**
  41684. * Defines the callback to call when a button is released
  41685. * @param callback defines the callback to use
  41686. */
  41687. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41688. /**
  41689. * Defines the callback to call when a pad is pressed
  41690. * @param callback defines the callback to use
  41691. */
  41692. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41693. /**
  41694. * Defines the callback to call when a pad is released
  41695. * @param callback defines the callback to use
  41696. */
  41697. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41698. private _setButtonValue;
  41699. private _setDPadValue;
  41700. /**
  41701. * Gets the value of the `Cross` button
  41702. */
  41703. get buttonCross(): number;
  41704. /**
  41705. * Sets the value of the `Cross` button
  41706. */
  41707. set buttonCross(value: number);
  41708. /**
  41709. * Gets the value of the `Circle` button
  41710. */
  41711. get buttonCircle(): number;
  41712. /**
  41713. * Sets the value of the `Circle` button
  41714. */
  41715. set buttonCircle(value: number);
  41716. /**
  41717. * Gets the value of the `Square` button
  41718. */
  41719. get buttonSquare(): number;
  41720. /**
  41721. * Sets the value of the `Square` button
  41722. */
  41723. set buttonSquare(value: number);
  41724. /**
  41725. * Gets the value of the `Triangle` button
  41726. */
  41727. get buttonTriangle(): number;
  41728. /**
  41729. * Sets the value of the `Triangle` button
  41730. */
  41731. set buttonTriangle(value: number);
  41732. /**
  41733. * Gets the value of the `Options` button
  41734. */
  41735. get buttonOptions(): number;
  41736. /**
  41737. * Sets the value of the `Options` button
  41738. */
  41739. set buttonOptions(value: number);
  41740. /**
  41741. * Gets the value of the `Share` button
  41742. */
  41743. get buttonShare(): number;
  41744. /**
  41745. * Sets the value of the `Share` button
  41746. */
  41747. set buttonShare(value: number);
  41748. /**
  41749. * Gets the value of the `L1` button
  41750. */
  41751. get buttonL1(): number;
  41752. /**
  41753. * Sets the value of the `L1` button
  41754. */
  41755. set buttonL1(value: number);
  41756. /**
  41757. * Gets the value of the `R1` button
  41758. */
  41759. get buttonR1(): number;
  41760. /**
  41761. * Sets the value of the `R1` button
  41762. */
  41763. set buttonR1(value: number);
  41764. /**
  41765. * Gets the value of the Left joystick
  41766. */
  41767. get buttonLeftStick(): number;
  41768. /**
  41769. * Sets the value of the Left joystick
  41770. */
  41771. set buttonLeftStick(value: number);
  41772. /**
  41773. * Gets the value of the Right joystick
  41774. */
  41775. get buttonRightStick(): number;
  41776. /**
  41777. * Sets the value of the Right joystick
  41778. */
  41779. set buttonRightStick(value: number);
  41780. /**
  41781. * Gets the value of D-pad up
  41782. */
  41783. get dPadUp(): number;
  41784. /**
  41785. * Sets the value of D-pad up
  41786. */
  41787. set dPadUp(value: number);
  41788. /**
  41789. * Gets the value of D-pad down
  41790. */
  41791. get dPadDown(): number;
  41792. /**
  41793. * Sets the value of D-pad down
  41794. */
  41795. set dPadDown(value: number);
  41796. /**
  41797. * Gets the value of D-pad left
  41798. */
  41799. get dPadLeft(): number;
  41800. /**
  41801. * Sets the value of D-pad left
  41802. */
  41803. set dPadLeft(value: number);
  41804. /**
  41805. * Gets the value of D-pad right
  41806. */
  41807. get dPadRight(): number;
  41808. /**
  41809. * Sets the value of D-pad right
  41810. */
  41811. set dPadRight(value: number);
  41812. /**
  41813. * Force the gamepad to synchronize with device values
  41814. */
  41815. update(): void;
  41816. /**
  41817. * Disposes the gamepad
  41818. */
  41819. dispose(): void;
  41820. }
  41821. }
  41822. declare module BABYLON {
  41823. /**
  41824. * Manager for handling gamepads
  41825. */
  41826. export class GamepadManager {
  41827. private _scene?;
  41828. private _babylonGamepads;
  41829. private _oneGamepadConnected;
  41830. /** @hidden */
  41831. _isMonitoring: boolean;
  41832. private _gamepadEventSupported;
  41833. private _gamepadSupport?;
  41834. /**
  41835. * observable to be triggered when the gamepad controller has been connected
  41836. */
  41837. onGamepadConnectedObservable: Observable<Gamepad>;
  41838. /**
  41839. * observable to be triggered when the gamepad controller has been disconnected
  41840. */
  41841. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41842. private _onGamepadConnectedEvent;
  41843. private _onGamepadDisconnectedEvent;
  41844. /**
  41845. * Initializes the gamepad manager
  41846. * @param _scene BabylonJS scene
  41847. */
  41848. constructor(_scene?: Scene | undefined);
  41849. /**
  41850. * The gamepads in the game pad manager
  41851. */
  41852. get gamepads(): Gamepad[];
  41853. /**
  41854. * Get the gamepad controllers based on type
  41855. * @param type The type of gamepad controller
  41856. * @returns Nullable gamepad
  41857. */
  41858. getGamepadByType(type?: number): Nullable<Gamepad>;
  41859. /**
  41860. * Disposes the gamepad manager
  41861. */
  41862. dispose(): void;
  41863. private _addNewGamepad;
  41864. private _startMonitoringGamepads;
  41865. private _stopMonitoringGamepads;
  41866. /** @hidden */
  41867. _checkGamepadsStatus(): void;
  41868. private _updateGamepadObjects;
  41869. }
  41870. }
  41871. declare module BABYLON {
  41872. interface Scene {
  41873. /** @hidden */
  41874. _gamepadManager: Nullable<GamepadManager>;
  41875. /**
  41876. * Gets the gamepad manager associated with the scene
  41877. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41878. */
  41879. gamepadManager: GamepadManager;
  41880. }
  41881. /**
  41882. * Interface representing a free camera inputs manager
  41883. */
  41884. interface FreeCameraInputsManager {
  41885. /**
  41886. * Adds gamepad input support to the FreeCameraInputsManager.
  41887. * @returns the FreeCameraInputsManager
  41888. */
  41889. addGamepad(): FreeCameraInputsManager;
  41890. }
  41891. /**
  41892. * Interface representing an arc rotate camera inputs manager
  41893. */
  41894. interface ArcRotateCameraInputsManager {
  41895. /**
  41896. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41897. * @returns the camera inputs manager
  41898. */
  41899. addGamepad(): ArcRotateCameraInputsManager;
  41900. }
  41901. /**
  41902. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41903. */
  41904. export class GamepadSystemSceneComponent implements ISceneComponent {
  41905. /**
  41906. * The component name helpfull to identify the component in the list of scene components.
  41907. */
  41908. readonly name: string;
  41909. /**
  41910. * The scene the component belongs to.
  41911. */
  41912. scene: Scene;
  41913. /**
  41914. * Creates a new instance of the component for the given scene
  41915. * @param scene Defines the scene to register the component in
  41916. */
  41917. constructor(scene: Scene);
  41918. /**
  41919. * Registers the component in a given scene
  41920. */
  41921. register(): void;
  41922. /**
  41923. * Rebuilds the elements related to this component in case of
  41924. * context lost for instance.
  41925. */
  41926. rebuild(): void;
  41927. /**
  41928. * Disposes the component and the associated ressources
  41929. */
  41930. dispose(): void;
  41931. private _beforeCameraUpdate;
  41932. }
  41933. }
  41934. declare module BABYLON {
  41935. /**
  41936. * 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,
  41937. * which still works and will still be found in many Playgrounds.
  41938. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41939. */
  41940. export class UniversalCamera extends TouchCamera {
  41941. /**
  41942. * Defines the gamepad rotation sensiblity.
  41943. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41944. */
  41945. get gamepadAngularSensibility(): number;
  41946. set gamepadAngularSensibility(value: number);
  41947. /**
  41948. * Defines the gamepad move sensiblity.
  41949. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41950. */
  41951. get gamepadMoveSensibility(): number;
  41952. set gamepadMoveSensibility(value: number);
  41953. /**
  41954. * 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,
  41955. * which still works and will still be found in many Playgrounds.
  41956. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41957. * @param name Define the name of the camera in the scene
  41958. * @param position Define the start position of the camera in the scene
  41959. * @param scene Define the scene the camera belongs to
  41960. */
  41961. constructor(name: string, position: Vector3, scene: Scene);
  41962. /**
  41963. * Gets the current object class name.
  41964. * @return the class name
  41965. */
  41966. getClassName(): string;
  41967. }
  41968. }
  41969. declare module BABYLON {
  41970. /**
  41971. * This represents a FPS type of camera. This is only here for back compat purpose.
  41972. * Please use the UniversalCamera instead as both are identical.
  41973. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41974. */
  41975. export class GamepadCamera extends UniversalCamera {
  41976. /**
  41977. * Instantiates a new Gamepad Camera
  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. * @param name Define the name of the camera in the scene
  41982. * @param position Define the start position of the camera in the scene
  41983. * @param scene Define the scene the camera belongs to
  41984. */
  41985. constructor(name: string, position: Vector3, scene: Scene);
  41986. /**
  41987. * Gets the current object class name.
  41988. * @return the class name
  41989. */
  41990. getClassName(): string;
  41991. }
  41992. }
  41993. declare module BABYLON {
  41994. /** @hidden */
  41995. export var passPixelShader: {
  41996. name: string;
  41997. shader: string;
  41998. };
  41999. }
  42000. declare module BABYLON {
  42001. /** @hidden */
  42002. export var passCubePixelShader: {
  42003. name: string;
  42004. shader: string;
  42005. };
  42006. }
  42007. declare module BABYLON {
  42008. /**
  42009. * PassPostProcess which produces an output the same as it's input
  42010. */
  42011. export class PassPostProcess extends PostProcess {
  42012. /**
  42013. * Creates the PassPostProcess
  42014. * @param name The name of the effect.
  42015. * @param options The required width/height ratio to downsize to before computing the render pass.
  42016. * @param camera The camera to apply the render pass to.
  42017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42018. * @param engine The engine which the post process will be applied. (default: current engine)
  42019. * @param reusable If the post process can be reused on the same frame. (default: false)
  42020. * @param textureType The type of texture to be used when performing the post processing.
  42021. * @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)
  42022. */
  42023. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42024. }
  42025. /**
  42026. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42027. */
  42028. export class PassCubePostProcess extends PostProcess {
  42029. private _face;
  42030. /**
  42031. * Gets or sets the cube face to display.
  42032. * * 0 is +X
  42033. * * 1 is -X
  42034. * * 2 is +Y
  42035. * * 3 is -Y
  42036. * * 4 is +Z
  42037. * * 5 is -Z
  42038. */
  42039. get face(): number;
  42040. set face(value: number);
  42041. /**
  42042. * Creates the PassCubePostProcess
  42043. * @param name The name of the effect.
  42044. * @param options The required width/height ratio to downsize to before computing the render pass.
  42045. * @param camera The camera to apply the render pass to.
  42046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42047. * @param engine The engine which the post process will be applied. (default: current engine)
  42048. * @param reusable If the post process can be reused on the same frame. (default: false)
  42049. * @param textureType The type of texture to be used when performing the post processing.
  42050. * @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)
  42051. */
  42052. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42053. }
  42054. }
  42055. declare module BABYLON {
  42056. /** @hidden */
  42057. export var anaglyphPixelShader: {
  42058. name: string;
  42059. shader: string;
  42060. };
  42061. }
  42062. declare module BABYLON {
  42063. /**
  42064. * Postprocess used to generate anaglyphic rendering
  42065. */
  42066. export class AnaglyphPostProcess extends PostProcess {
  42067. private _passedProcess;
  42068. /**
  42069. * Creates a new AnaglyphPostProcess
  42070. * @param name defines postprocess name
  42071. * @param options defines creation options or target ratio scale
  42072. * @param rigCameras defines cameras using this postprocess
  42073. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42074. * @param engine defines hosting engine
  42075. * @param reusable defines if the postprocess will be reused multiple times per frame
  42076. */
  42077. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42078. }
  42079. }
  42080. declare module BABYLON {
  42081. /**
  42082. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42083. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42084. */
  42085. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42086. /**
  42087. * Creates a new AnaglyphArcRotateCamera
  42088. * @param name defines camera name
  42089. * @param alpha defines alpha angle (in radians)
  42090. * @param beta defines beta angle (in radians)
  42091. * @param radius defines radius
  42092. * @param target defines camera target
  42093. * @param interaxialDistance defines distance between each color axis
  42094. * @param scene defines the hosting scene
  42095. */
  42096. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42097. /**
  42098. * Gets camera class name
  42099. * @returns AnaglyphArcRotateCamera
  42100. */
  42101. getClassName(): string;
  42102. }
  42103. }
  42104. declare module BABYLON {
  42105. /**
  42106. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42107. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42108. */
  42109. export class AnaglyphFreeCamera extends FreeCamera {
  42110. /**
  42111. * Creates a new AnaglyphFreeCamera
  42112. * @param name defines camera name
  42113. * @param position defines initial position
  42114. * @param interaxialDistance defines distance between each color axis
  42115. * @param scene defines the hosting scene
  42116. */
  42117. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42118. /**
  42119. * Gets camera class name
  42120. * @returns AnaglyphFreeCamera
  42121. */
  42122. getClassName(): string;
  42123. }
  42124. }
  42125. declare module BABYLON {
  42126. /**
  42127. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42128. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42129. */
  42130. export class AnaglyphGamepadCamera extends GamepadCamera {
  42131. /**
  42132. * Creates a new AnaglyphGamepadCamera
  42133. * @param name defines camera name
  42134. * @param position defines initial position
  42135. * @param interaxialDistance defines distance between each color axis
  42136. * @param scene defines the hosting scene
  42137. */
  42138. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42139. /**
  42140. * Gets camera class name
  42141. * @returns AnaglyphGamepadCamera
  42142. */
  42143. getClassName(): string;
  42144. }
  42145. }
  42146. declare module BABYLON {
  42147. /**
  42148. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42149. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42150. */
  42151. export class AnaglyphUniversalCamera extends UniversalCamera {
  42152. /**
  42153. * Creates a new AnaglyphUniversalCamera
  42154. * @param name defines camera name
  42155. * @param position defines initial position
  42156. * @param interaxialDistance defines distance between each color axis
  42157. * @param scene defines the hosting scene
  42158. */
  42159. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42160. /**
  42161. * Gets camera class name
  42162. * @returns AnaglyphUniversalCamera
  42163. */
  42164. getClassName(): string;
  42165. }
  42166. }
  42167. declare module BABYLON {
  42168. /** @hidden */
  42169. export var stereoscopicInterlacePixelShader: {
  42170. name: string;
  42171. shader: string;
  42172. };
  42173. }
  42174. declare module BABYLON {
  42175. /**
  42176. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42177. */
  42178. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42179. private _stepSize;
  42180. private _passedProcess;
  42181. /**
  42182. * Initializes a StereoscopicInterlacePostProcessI
  42183. * @param name The name of the effect.
  42184. * @param rigCameras The rig cameras to be appled to the post process
  42185. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42186. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42187. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42188. * @param engine The engine which the post process will be applied. (default: current engine)
  42189. * @param reusable If the post process can be reused on the same frame. (default: false)
  42190. */
  42191. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42192. }
  42193. /**
  42194. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42195. */
  42196. export class StereoscopicInterlacePostProcess extends PostProcess {
  42197. private _stepSize;
  42198. private _passedProcess;
  42199. /**
  42200. * Initializes a StereoscopicInterlacePostProcess
  42201. * @param name The name of the effect.
  42202. * @param rigCameras The rig cameras to be appled to the post process
  42203. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42204. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42205. * @param engine The engine which the post process will be applied. (default: current engine)
  42206. * @param reusable If the post process can be reused on the same frame. (default: false)
  42207. */
  42208. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42209. }
  42210. }
  42211. declare module BABYLON {
  42212. /**
  42213. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42214. * @see http://doc.babylonjs.com/features/cameras
  42215. */
  42216. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42217. /**
  42218. * Creates a new StereoscopicArcRotateCamera
  42219. * @param name defines camera name
  42220. * @param alpha defines alpha angle (in radians)
  42221. * @param beta defines beta angle (in radians)
  42222. * @param radius defines radius
  42223. * @param target defines camera target
  42224. * @param interaxialDistance defines distance between each color axis
  42225. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42226. * @param scene defines the hosting scene
  42227. */
  42228. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42229. /**
  42230. * Gets camera class name
  42231. * @returns StereoscopicArcRotateCamera
  42232. */
  42233. getClassName(): string;
  42234. }
  42235. }
  42236. declare module BABYLON {
  42237. /**
  42238. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42239. * @see http://doc.babylonjs.com/features/cameras
  42240. */
  42241. export class StereoscopicFreeCamera extends FreeCamera {
  42242. /**
  42243. * Creates a new StereoscopicFreeCamera
  42244. * @param name defines camera name
  42245. * @param position defines initial position
  42246. * @param interaxialDistance defines distance between each color axis
  42247. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42248. * @param scene defines the hosting scene
  42249. */
  42250. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42251. /**
  42252. * Gets camera class name
  42253. * @returns StereoscopicFreeCamera
  42254. */
  42255. getClassName(): string;
  42256. }
  42257. }
  42258. declare module BABYLON {
  42259. /**
  42260. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42261. * @see http://doc.babylonjs.com/features/cameras
  42262. */
  42263. export class StereoscopicGamepadCamera extends GamepadCamera {
  42264. /**
  42265. * Creates a new StereoscopicGamepadCamera
  42266. * @param name defines camera name
  42267. * @param position defines initial position
  42268. * @param interaxialDistance defines distance between each color axis
  42269. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42270. * @param scene defines the hosting scene
  42271. */
  42272. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42273. /**
  42274. * Gets camera class name
  42275. * @returns StereoscopicGamepadCamera
  42276. */
  42277. getClassName(): string;
  42278. }
  42279. }
  42280. declare module BABYLON {
  42281. /**
  42282. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42283. * @see http://doc.babylonjs.com/features/cameras
  42284. */
  42285. export class StereoscopicUniversalCamera extends UniversalCamera {
  42286. /**
  42287. * Creates a new StereoscopicUniversalCamera
  42288. * @param name defines camera name
  42289. * @param position defines initial position
  42290. * @param interaxialDistance defines distance between each color axis
  42291. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42292. * @param scene defines the hosting scene
  42293. */
  42294. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42295. /**
  42296. * Gets camera class name
  42297. * @returns StereoscopicUniversalCamera
  42298. */
  42299. getClassName(): string;
  42300. }
  42301. }
  42302. declare module BABYLON {
  42303. /**
  42304. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42305. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42306. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42307. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42308. */
  42309. export class VirtualJoysticksCamera extends FreeCamera {
  42310. /**
  42311. * Intantiates a VirtualJoysticksCamera. 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. * @param name Define the name of the camera in the scene
  42316. * @param position Define the start position of the camera in the scene
  42317. * @param scene Define the scene the camera belongs to
  42318. */
  42319. constructor(name: string, position: Vector3, scene: Scene);
  42320. /**
  42321. * Gets the current object class name.
  42322. * @return the class name
  42323. */
  42324. getClassName(): string;
  42325. }
  42326. }
  42327. declare module BABYLON {
  42328. /**
  42329. * This represents all the required metrics to create a VR camera.
  42330. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42331. */
  42332. export class VRCameraMetrics {
  42333. /**
  42334. * Define the horizontal resolution off the screen.
  42335. */
  42336. hResolution: number;
  42337. /**
  42338. * Define the vertical resolution off the screen.
  42339. */
  42340. vResolution: number;
  42341. /**
  42342. * Define the horizontal screen size.
  42343. */
  42344. hScreenSize: number;
  42345. /**
  42346. * Define the vertical screen size.
  42347. */
  42348. vScreenSize: number;
  42349. /**
  42350. * Define the vertical screen center position.
  42351. */
  42352. vScreenCenter: number;
  42353. /**
  42354. * Define the distance of the eyes to the screen.
  42355. */
  42356. eyeToScreenDistance: number;
  42357. /**
  42358. * Define the distance between both lenses
  42359. */
  42360. lensSeparationDistance: number;
  42361. /**
  42362. * Define the distance between both viewer's eyes.
  42363. */
  42364. interpupillaryDistance: number;
  42365. /**
  42366. * Define the distortion factor of the VR postprocess.
  42367. * Please, touch with care.
  42368. */
  42369. distortionK: number[];
  42370. /**
  42371. * Define the chromatic aberration correction factors for the VR post process.
  42372. */
  42373. chromaAbCorrection: number[];
  42374. /**
  42375. * Define the scale factor of the post process.
  42376. * The smaller the better but the slower.
  42377. */
  42378. postProcessScaleFactor: number;
  42379. /**
  42380. * Define an offset for the lens center.
  42381. */
  42382. lensCenterOffset: number;
  42383. /**
  42384. * Define if the current vr camera should compensate the distortion of the lense or not.
  42385. */
  42386. compensateDistortion: boolean;
  42387. /**
  42388. * Defines if multiview should be enabled when rendering (Default: false)
  42389. */
  42390. multiviewEnabled: boolean;
  42391. /**
  42392. * Gets the rendering aspect ratio based on the provided resolutions.
  42393. */
  42394. get aspectRatio(): number;
  42395. /**
  42396. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42397. */
  42398. get aspectRatioFov(): number;
  42399. /**
  42400. * @hidden
  42401. */
  42402. get leftHMatrix(): Matrix;
  42403. /**
  42404. * @hidden
  42405. */
  42406. get rightHMatrix(): Matrix;
  42407. /**
  42408. * @hidden
  42409. */
  42410. get leftPreViewMatrix(): Matrix;
  42411. /**
  42412. * @hidden
  42413. */
  42414. get rightPreViewMatrix(): Matrix;
  42415. /**
  42416. * Get the default VRMetrics based on the most generic setup.
  42417. * @returns the default vr metrics
  42418. */
  42419. static GetDefault(): VRCameraMetrics;
  42420. }
  42421. }
  42422. declare module BABYLON {
  42423. /** @hidden */
  42424. export var vrDistortionCorrectionPixelShader: {
  42425. name: string;
  42426. shader: string;
  42427. };
  42428. }
  42429. declare module BABYLON {
  42430. /**
  42431. * VRDistortionCorrectionPostProcess used for mobile VR
  42432. */
  42433. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42434. private _isRightEye;
  42435. private _distortionFactors;
  42436. private _postProcessScaleFactor;
  42437. private _lensCenterOffset;
  42438. private _scaleIn;
  42439. private _scaleFactor;
  42440. private _lensCenter;
  42441. /**
  42442. * Initializes the VRDistortionCorrectionPostProcess
  42443. * @param name The name of the effect.
  42444. * @param camera The camera to apply the render pass to.
  42445. * @param isRightEye If this is for the right eye distortion
  42446. * @param vrMetrics All the required metrics for the VR camera
  42447. */
  42448. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42449. }
  42450. }
  42451. declare module BABYLON {
  42452. /**
  42453. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42454. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42455. */
  42456. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42457. /**
  42458. * Creates a new VRDeviceOrientationArcRotateCamera
  42459. * @param name defines camera name
  42460. * @param alpha defines the camera rotation along the logitudinal axis
  42461. * @param beta defines the camera rotation along the latitudinal axis
  42462. * @param radius defines the camera distance from its target
  42463. * @param target defines the camera target
  42464. * @param scene defines the scene the camera belongs to
  42465. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42466. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42467. */
  42468. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42469. /**
  42470. * Gets camera class name
  42471. * @returns VRDeviceOrientationArcRotateCamera
  42472. */
  42473. getClassName(): string;
  42474. }
  42475. }
  42476. declare module BABYLON {
  42477. /**
  42478. * Camera used to simulate VR rendering (based on FreeCamera)
  42479. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42480. */
  42481. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42482. /**
  42483. * Creates a new VRDeviceOrientationFreeCamera
  42484. * @param name defines camera name
  42485. * @param position defines the start position of the camera
  42486. * @param scene defines the scene the camera belongs to
  42487. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42488. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42489. */
  42490. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42491. /**
  42492. * Gets camera class name
  42493. * @returns VRDeviceOrientationFreeCamera
  42494. */
  42495. getClassName(): string;
  42496. }
  42497. }
  42498. declare module BABYLON {
  42499. /**
  42500. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42501. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42502. */
  42503. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42504. /**
  42505. * Creates a new VRDeviceOrientationGamepadCamera
  42506. * @param name defines camera name
  42507. * @param position defines the start position of the camera
  42508. * @param scene defines the scene the camera belongs to
  42509. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42510. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42511. */
  42512. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42513. /**
  42514. * Gets camera class name
  42515. * @returns VRDeviceOrientationGamepadCamera
  42516. */
  42517. getClassName(): string;
  42518. }
  42519. }
  42520. declare module BABYLON {
  42521. /** @hidden */
  42522. export var imageProcessingPixelShader: {
  42523. name: string;
  42524. shader: string;
  42525. };
  42526. }
  42527. declare module BABYLON {
  42528. /**
  42529. * ImageProcessingPostProcess
  42530. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42531. */
  42532. export class ImageProcessingPostProcess extends PostProcess {
  42533. /**
  42534. * Default configuration related to image processing available in the PBR Material.
  42535. */
  42536. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42537. /**
  42538. * Gets the image processing configuration used either in this material.
  42539. */
  42540. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42541. /**
  42542. * Sets the Default image processing configuration used either in the this material.
  42543. *
  42544. * If sets to null, the scene one is in use.
  42545. */
  42546. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42547. /**
  42548. * Keep track of the image processing observer to allow dispose and replace.
  42549. */
  42550. private _imageProcessingObserver;
  42551. /**
  42552. * Attaches a new image processing configuration to the PBR Material.
  42553. * @param configuration
  42554. */
  42555. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42556. /**
  42557. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42558. */
  42559. get colorCurves(): Nullable<ColorCurves>;
  42560. /**
  42561. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42562. */
  42563. set colorCurves(value: Nullable<ColorCurves>);
  42564. /**
  42565. * Gets wether the color curves effect is enabled.
  42566. */
  42567. get colorCurvesEnabled(): boolean;
  42568. /**
  42569. * Sets wether the color curves effect is enabled.
  42570. */
  42571. set colorCurvesEnabled(value: boolean);
  42572. /**
  42573. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42574. */
  42575. get colorGradingTexture(): Nullable<BaseTexture>;
  42576. /**
  42577. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42578. */
  42579. set colorGradingTexture(value: Nullable<BaseTexture>);
  42580. /**
  42581. * Gets wether the color grading effect is enabled.
  42582. */
  42583. get colorGradingEnabled(): boolean;
  42584. /**
  42585. * Gets wether the color grading effect is enabled.
  42586. */
  42587. set colorGradingEnabled(value: boolean);
  42588. /**
  42589. * Gets exposure used in the effect.
  42590. */
  42591. get exposure(): number;
  42592. /**
  42593. * Sets exposure used in the effect.
  42594. */
  42595. set exposure(value: number);
  42596. /**
  42597. * Gets wether tonemapping is enabled or not.
  42598. */
  42599. get toneMappingEnabled(): boolean;
  42600. /**
  42601. * Sets wether tonemapping is enabled or not
  42602. */
  42603. set toneMappingEnabled(value: boolean);
  42604. /**
  42605. * Gets the type of tone mapping effect.
  42606. */
  42607. get toneMappingType(): number;
  42608. /**
  42609. * Sets the type of tone mapping effect.
  42610. */
  42611. set toneMappingType(value: number);
  42612. /**
  42613. * Gets contrast used in the effect.
  42614. */
  42615. get contrast(): number;
  42616. /**
  42617. * Sets contrast used in the effect.
  42618. */
  42619. set contrast(value: number);
  42620. /**
  42621. * Gets Vignette stretch size.
  42622. */
  42623. get vignetteStretch(): number;
  42624. /**
  42625. * Sets Vignette stretch size.
  42626. */
  42627. set vignetteStretch(value: number);
  42628. /**
  42629. * Gets Vignette centre X Offset.
  42630. */
  42631. get vignetteCentreX(): number;
  42632. /**
  42633. * Sets Vignette centre X Offset.
  42634. */
  42635. set vignetteCentreX(value: number);
  42636. /**
  42637. * Gets Vignette centre Y Offset.
  42638. */
  42639. get vignetteCentreY(): number;
  42640. /**
  42641. * Sets Vignette centre Y Offset.
  42642. */
  42643. set vignetteCentreY(value: number);
  42644. /**
  42645. * Gets Vignette weight or intensity of the vignette effect.
  42646. */
  42647. get vignetteWeight(): number;
  42648. /**
  42649. * Sets Vignette weight or intensity of the vignette effect.
  42650. */
  42651. set vignetteWeight(value: number);
  42652. /**
  42653. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42654. * if vignetteEnabled is set to true.
  42655. */
  42656. get vignetteColor(): Color4;
  42657. /**
  42658. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42659. * if vignetteEnabled is set to true.
  42660. */
  42661. set vignetteColor(value: Color4);
  42662. /**
  42663. * Gets Camera field of view used by the Vignette effect.
  42664. */
  42665. get vignetteCameraFov(): number;
  42666. /**
  42667. * Sets Camera field of view used by the Vignette effect.
  42668. */
  42669. set vignetteCameraFov(value: number);
  42670. /**
  42671. * Gets the vignette blend mode allowing different kind of effect.
  42672. */
  42673. get vignetteBlendMode(): number;
  42674. /**
  42675. * Sets the vignette blend mode allowing different kind of effect.
  42676. */
  42677. set vignetteBlendMode(value: number);
  42678. /**
  42679. * Gets wether the vignette effect is enabled.
  42680. */
  42681. get vignetteEnabled(): boolean;
  42682. /**
  42683. * Sets wether the vignette effect is enabled.
  42684. */
  42685. set vignetteEnabled(value: boolean);
  42686. private _fromLinearSpace;
  42687. /**
  42688. * Gets wether the input of the processing is in Gamma or Linear Space.
  42689. */
  42690. get fromLinearSpace(): boolean;
  42691. /**
  42692. * Sets wether the input of the processing is in Gamma or Linear Space.
  42693. */
  42694. set fromLinearSpace(value: boolean);
  42695. /**
  42696. * Defines cache preventing GC.
  42697. */
  42698. private _defines;
  42699. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42700. /**
  42701. * "ImageProcessingPostProcess"
  42702. * @returns "ImageProcessingPostProcess"
  42703. */
  42704. getClassName(): string;
  42705. protected _updateParameters(): void;
  42706. dispose(camera?: Camera): void;
  42707. }
  42708. }
  42709. declare module BABYLON {
  42710. /**
  42711. * Class containing static functions to help procedurally build meshes
  42712. */
  42713. export class GroundBuilder {
  42714. /**
  42715. * Creates a ground mesh
  42716. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42717. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42719. * @param name defines the name of the mesh
  42720. * @param options defines the options used to create the mesh
  42721. * @param scene defines the hosting scene
  42722. * @returns the ground mesh
  42723. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42724. */
  42725. static CreateGround(name: string, options: {
  42726. width?: number;
  42727. height?: number;
  42728. subdivisions?: number;
  42729. subdivisionsX?: number;
  42730. subdivisionsY?: number;
  42731. updatable?: boolean;
  42732. }, scene: any): Mesh;
  42733. /**
  42734. * Creates a tiled ground mesh
  42735. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42736. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42737. * * 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
  42738. * * 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
  42739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42740. * @param name defines the name of the mesh
  42741. * @param options defines the options used to create the mesh
  42742. * @param scene defines the hosting scene
  42743. * @returns the tiled ground mesh
  42744. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42745. */
  42746. static CreateTiledGround(name: string, options: {
  42747. xmin: number;
  42748. zmin: number;
  42749. xmax: number;
  42750. zmax: number;
  42751. subdivisions?: {
  42752. w: number;
  42753. h: number;
  42754. };
  42755. precision?: {
  42756. w: number;
  42757. h: number;
  42758. };
  42759. updatable?: boolean;
  42760. }, scene?: Nullable<Scene>): Mesh;
  42761. /**
  42762. * Creates a ground mesh from a height map
  42763. * * The parameter `url` sets the URL of the height map image resource.
  42764. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42765. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42766. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42767. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42768. * * 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.
  42769. * * 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).
  42770. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42772. * @param name defines the name of the mesh
  42773. * @param url defines the url to the height map
  42774. * @param options defines the options used to create the mesh
  42775. * @param scene defines the hosting scene
  42776. * @returns the ground mesh
  42777. * @see https://doc.babylonjs.com/babylon101/height_map
  42778. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42779. */
  42780. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42781. width?: number;
  42782. height?: number;
  42783. subdivisions?: number;
  42784. minHeight?: number;
  42785. maxHeight?: number;
  42786. colorFilter?: Color3;
  42787. alphaFilter?: number;
  42788. updatable?: boolean;
  42789. onReady?: (mesh: GroundMesh) => void;
  42790. }, scene?: Nullable<Scene>): GroundMesh;
  42791. }
  42792. }
  42793. declare module BABYLON {
  42794. /**
  42795. * Class containing static functions to help procedurally build meshes
  42796. */
  42797. export class TorusBuilder {
  42798. /**
  42799. * Creates a torus mesh
  42800. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42801. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42802. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42804. * * 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
  42805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42806. * @param name defines the name of the mesh
  42807. * @param options defines the options used to create the mesh
  42808. * @param scene defines the hosting scene
  42809. * @returns the torus mesh
  42810. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42811. */
  42812. static CreateTorus(name: string, options: {
  42813. diameter?: number;
  42814. thickness?: number;
  42815. tessellation?: number;
  42816. updatable?: boolean;
  42817. sideOrientation?: number;
  42818. frontUVs?: Vector4;
  42819. backUVs?: Vector4;
  42820. }, scene: any): Mesh;
  42821. }
  42822. }
  42823. declare module BABYLON {
  42824. /**
  42825. * Class containing static functions to help procedurally build meshes
  42826. */
  42827. export class CylinderBuilder {
  42828. /**
  42829. * Creates a cylinder or a cone mesh
  42830. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42831. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42832. * * 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.
  42833. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42834. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42835. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42836. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42837. * * 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).
  42838. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42839. * * 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).
  42840. * * 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
  42841. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42842. * * 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
  42843. * * 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.
  42844. * * If `enclose` is false, a ring surface is one element.
  42845. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42846. * * 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
  42847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42848. * * 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
  42849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42850. * @param name defines the name of the mesh
  42851. * @param options defines the options used to create the mesh
  42852. * @param scene defines the hosting scene
  42853. * @returns the cylinder mesh
  42854. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42855. */
  42856. static CreateCylinder(name: string, options: {
  42857. height?: number;
  42858. diameterTop?: number;
  42859. diameterBottom?: number;
  42860. diameter?: number;
  42861. tessellation?: number;
  42862. subdivisions?: number;
  42863. arc?: number;
  42864. faceColors?: Color4[];
  42865. faceUV?: Vector4[];
  42866. updatable?: boolean;
  42867. hasRings?: boolean;
  42868. enclose?: boolean;
  42869. cap?: number;
  42870. sideOrientation?: number;
  42871. frontUVs?: Vector4;
  42872. backUVs?: Vector4;
  42873. }, scene: any): Mesh;
  42874. }
  42875. }
  42876. declare module BABYLON {
  42877. /**
  42878. * States of the webXR experience
  42879. */
  42880. export enum WebXRState {
  42881. /**
  42882. * Transitioning to being in XR mode
  42883. */
  42884. ENTERING_XR = 0,
  42885. /**
  42886. * Transitioning to non XR mode
  42887. */
  42888. EXITING_XR = 1,
  42889. /**
  42890. * In XR mode and presenting
  42891. */
  42892. IN_XR = 2,
  42893. /**
  42894. * Not entered XR mode
  42895. */
  42896. NOT_IN_XR = 3
  42897. }
  42898. /**
  42899. * Abstraction of the XR render target
  42900. */
  42901. export interface WebXRRenderTarget extends IDisposable {
  42902. /**
  42903. * xrpresent context of the canvas which can be used to display/mirror xr content
  42904. */
  42905. canvasContext: WebGLRenderingContext;
  42906. /**
  42907. * xr layer for the canvas
  42908. */
  42909. xrLayer: Nullable<XRWebGLLayer>;
  42910. /**
  42911. * Initializes the xr layer for the session
  42912. * @param xrSession xr session
  42913. * @returns a promise that will resolve once the XR Layer has been created
  42914. */
  42915. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42916. }
  42917. }
  42918. declare module BABYLON {
  42919. /**
  42920. * COnfiguration object for WebXR output canvas
  42921. */
  42922. export class WebXRManagedOutputCanvasOptions {
  42923. /**
  42924. * An optional canvas in case you wish to create it yourself and provide it here.
  42925. * If not provided, a new canvas will be created
  42926. */
  42927. canvasElement?: HTMLCanvasElement;
  42928. /**
  42929. * Options for this XR Layer output
  42930. */
  42931. canvasOptions?: XRWebGLLayerOptions;
  42932. /**
  42933. * CSS styling for a newly created canvas (if not provided)
  42934. */
  42935. newCanvasCssStyle?: string;
  42936. /**
  42937. * Get the default values of the configuration object
  42938. * @returns default values of this configuration object
  42939. */
  42940. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42941. }
  42942. /**
  42943. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42944. */
  42945. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42946. private _options;
  42947. private _canvas;
  42948. private _engine;
  42949. /**
  42950. * Rendering context of the canvas which can be used to display/mirror xr content
  42951. */
  42952. canvasContext: WebGLRenderingContext;
  42953. /**
  42954. * xr layer for the canvas
  42955. */
  42956. xrLayer: Nullable<XRWebGLLayer>;
  42957. /**
  42958. * Initializes the canvas to be added/removed upon entering/exiting xr
  42959. * @param _xrSessionManager The XR Session manager
  42960. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42961. */
  42962. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42963. /**
  42964. * Disposes of the object
  42965. */
  42966. dispose(): void;
  42967. /**
  42968. * Initializes the xr layer for the session
  42969. * @param xrSession xr session
  42970. * @returns a promise that will resolve once the XR Layer has been created
  42971. */
  42972. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42973. private _addCanvas;
  42974. private _removeCanvas;
  42975. private _setManagedOutputCanvas;
  42976. }
  42977. }
  42978. declare module BABYLON {
  42979. /**
  42980. * Manages an XRSession to work with Babylon's engine
  42981. * @see https://doc.babylonjs.com/how_to/webxr
  42982. */
  42983. export class WebXRSessionManager implements IDisposable {
  42984. /** The scene which the session should be created for */
  42985. scene: Scene;
  42986. private _referenceSpace;
  42987. private _rttProvider;
  42988. private _sessionEnded;
  42989. private _xrNavigator;
  42990. private baseLayer;
  42991. /**
  42992. * The base reference space from which the session started. good if you want to reset your
  42993. * reference space
  42994. */
  42995. baseReferenceSpace: XRReferenceSpace;
  42996. /**
  42997. * Current XR frame
  42998. */
  42999. currentFrame: Nullable<XRFrame>;
  43000. /** WebXR timestamp updated every frame */
  43001. currentTimestamp: number;
  43002. /**
  43003. * Used just in case of a failure to initialize an immersive session.
  43004. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43005. */
  43006. defaultHeightCompensation: number;
  43007. /**
  43008. * Fires every time a new xrFrame arrives which can be used to update the camera
  43009. */
  43010. onXRFrameObservable: Observable<XRFrame>;
  43011. /**
  43012. * Fires when the reference space changed
  43013. */
  43014. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43015. /**
  43016. * Fires when the xr session is ended either by the device or manually done
  43017. */
  43018. onXRSessionEnded: Observable<any>;
  43019. /**
  43020. * Fires when the xr session is ended either by the device or manually done
  43021. */
  43022. onXRSessionInit: Observable<XRSession>;
  43023. /**
  43024. * Underlying xr session
  43025. */
  43026. session: XRSession;
  43027. /**
  43028. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43029. * or get the offset the player is currently at.
  43030. */
  43031. viewerReferenceSpace: XRReferenceSpace;
  43032. /**
  43033. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43034. * @param scene The scene which the session should be created for
  43035. */
  43036. constructor(
  43037. /** The scene which the session should be created for */
  43038. scene: Scene);
  43039. /**
  43040. * The current reference space used in this session. This reference space can constantly change!
  43041. * It is mainly used to offset the camera's position.
  43042. */
  43043. get referenceSpace(): XRReferenceSpace;
  43044. /**
  43045. * Set a new reference space and triggers the observable
  43046. */
  43047. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43048. /**
  43049. * Disposes of the session manager
  43050. */
  43051. dispose(): void;
  43052. /**
  43053. * Stops the xrSession and restores the render loop
  43054. * @returns Promise which resolves after it exits XR
  43055. */
  43056. exitXRAsync(): Promise<void>;
  43057. /**
  43058. * Gets the correct render target texture to be rendered this frame for this eye
  43059. * @param eye the eye for which to get the render target
  43060. * @returns the render target for the specified eye
  43061. */
  43062. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43063. /**
  43064. * Creates a WebXRRenderTarget object for the XR session
  43065. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43066. * @param options optional options to provide when creating a new render target
  43067. * @returns a WebXR render target to which the session can render
  43068. */
  43069. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43070. /**
  43071. * Initializes the manager
  43072. * After initialization enterXR can be called to start an XR session
  43073. * @returns Promise which resolves after it is initialized
  43074. */
  43075. initializeAsync(): Promise<void>;
  43076. /**
  43077. * Initializes an xr session
  43078. * @param xrSessionMode mode to initialize
  43079. * @param xrSessionInit defines optional and required values to pass to the session builder
  43080. * @returns a promise which will resolve once the session has been initialized
  43081. */
  43082. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43083. /**
  43084. * Checks if a session would be supported for the creation options specified
  43085. * @param sessionMode session mode to check if supported eg. immersive-vr
  43086. * @returns A Promise that resolves to true if supported and false if not
  43087. */
  43088. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43089. /**
  43090. * Resets the reference space to the one started the session
  43091. */
  43092. resetReferenceSpace(): void;
  43093. /**
  43094. * Starts rendering to the xr layer
  43095. */
  43096. runXRRenderLoop(): void;
  43097. /**
  43098. * Sets the reference space on the xr session
  43099. * @param referenceSpaceType space to set
  43100. * @returns a promise that will resolve once the reference space has been set
  43101. */
  43102. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43103. /**
  43104. * Updates the render state of the session
  43105. * @param state state to set
  43106. * @returns a promise that resolves once the render state has been updated
  43107. */
  43108. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43109. /**
  43110. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43111. * @param sessionMode defines the session to test
  43112. * @returns a promise with boolean as final value
  43113. */
  43114. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43115. private _createRenderTargetTexture;
  43116. }
  43117. }
  43118. declare module BABYLON {
  43119. /**
  43120. * WebXR Camera which holds the views for the xrSession
  43121. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43122. */
  43123. export class WebXRCamera extends FreeCamera {
  43124. private _xrSessionManager;
  43125. private _firstFrame;
  43126. private _referenceQuaternion;
  43127. private _referencedPosition;
  43128. private _xrInvPositionCache;
  43129. private _xrInvQuaternionCache;
  43130. /**
  43131. * Should position compensation execute on first frame.
  43132. * This is used when copying the position from a native (non XR) camera
  43133. */
  43134. compensateOnFirstFrame: boolean;
  43135. /**
  43136. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43137. * @param name the name of the camera
  43138. * @param scene the scene to add the camera to
  43139. * @param _xrSessionManager a constructed xr session manager
  43140. */
  43141. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43142. /**
  43143. * Return the user's height, unrelated to the current ground.
  43144. * This will be the y position of this camera, when ground level is 0.
  43145. */
  43146. get realWorldHeight(): number;
  43147. /** @hidden */
  43148. _updateForDualEyeDebugging(): void;
  43149. /**
  43150. * Sets this camera's transformation based on a non-vr camera
  43151. * @param otherCamera the non-vr camera to copy the transformation from
  43152. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43153. */
  43154. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43155. /**
  43156. * Gets the current instance class name ("WebXRCamera").
  43157. * @returns the class name
  43158. */
  43159. getClassName(): string;
  43160. private _updateFromXRSession;
  43161. private _updateNumberOfRigCameras;
  43162. private _updateReferenceSpace;
  43163. private _updateReferenceSpaceOffset;
  43164. }
  43165. }
  43166. declare module BABYLON {
  43167. /**
  43168. * Defining the interface required for a (webxr) feature
  43169. */
  43170. export interface IWebXRFeature extends IDisposable {
  43171. /**
  43172. * Is this feature attached
  43173. */
  43174. attached: boolean;
  43175. /**
  43176. * Should auto-attach be disabled?
  43177. */
  43178. disableAutoAttach: boolean;
  43179. /**
  43180. * Attach the feature to the session
  43181. * Will usually be called by the features manager
  43182. *
  43183. * @param force should attachment be forced (even when already attached)
  43184. * @returns true if successful.
  43185. */
  43186. attach(force?: boolean): boolean;
  43187. /**
  43188. * Detach the feature from the session
  43189. * Will usually be called by the features manager
  43190. *
  43191. * @returns true if successful.
  43192. */
  43193. detach(): boolean;
  43194. }
  43195. /**
  43196. * A list of the currently available features without referencing them
  43197. */
  43198. export class WebXRFeatureName {
  43199. /**
  43200. * The name of the anchor system feature
  43201. */
  43202. static ANCHOR_SYSTEM: string;
  43203. /**
  43204. * The name of the background remover feature
  43205. */
  43206. static BACKGROUND_REMOVER: string;
  43207. /**
  43208. * The name of the hit test feature
  43209. */
  43210. static HIT_TEST: string;
  43211. /**
  43212. * physics impostors for xr controllers feature
  43213. */
  43214. static PHYSICS_CONTROLLERS: string;
  43215. /**
  43216. * The name of the plane detection feature
  43217. */
  43218. static PLANE_DETECTION: string;
  43219. /**
  43220. * The name of the pointer selection feature
  43221. */
  43222. static POINTER_SELECTION: string;
  43223. /**
  43224. * The name of the teleportation feature
  43225. */
  43226. static TELEPORTATION: string;
  43227. }
  43228. /**
  43229. * Defining the constructor of a feature. Used to register the modules.
  43230. */
  43231. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43232. /**
  43233. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43234. * It is mainly used in AR sessions.
  43235. *
  43236. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43237. */
  43238. export class WebXRFeaturesManager implements IDisposable {
  43239. private _xrSessionManager;
  43240. private static readonly _AvailableFeatures;
  43241. private _features;
  43242. /**
  43243. * constructs a new features manages.
  43244. *
  43245. * @param _xrSessionManager an instance of WebXRSessionManager
  43246. */
  43247. constructor(_xrSessionManager: WebXRSessionManager);
  43248. /**
  43249. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43250. * Mainly used internally.
  43251. *
  43252. * @param featureName the name of the feature to register
  43253. * @param constructorFunction the function used to construct the module
  43254. * @param version the (babylon) version of the module
  43255. * @param stable is that a stable version of this module
  43256. */
  43257. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43258. /**
  43259. * Returns a constructor of a specific feature.
  43260. *
  43261. * @param featureName the name of the feature to construct
  43262. * @param version the version of the feature to load
  43263. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43264. * @param options optional options provided to the module.
  43265. * @returns a function that, when called, will return a new instance of this feature
  43266. */
  43267. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43268. /**
  43269. * Can be used to return the list of features currently registered
  43270. *
  43271. * @returns an Array of available features
  43272. */
  43273. static GetAvailableFeatures(): string[];
  43274. /**
  43275. * Gets the versions available for a specific feature
  43276. * @param featureName the name of the feature
  43277. * @returns an array with the available versions
  43278. */
  43279. static GetAvailableVersions(featureName: string): string[];
  43280. /**
  43281. * Return the latest unstable version of this feature
  43282. * @param featureName the name of the feature to search
  43283. * @returns the version number. if not found will return -1
  43284. */
  43285. static GetLatestVersionOfFeature(featureName: string): number;
  43286. /**
  43287. * Return the latest stable version of this feature
  43288. * @param featureName the name of the feature to search
  43289. * @returns the version number. if not found will return -1
  43290. */
  43291. static GetStableVersionOfFeature(featureName: string): number;
  43292. /**
  43293. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43294. * Can be used during a session to start a feature
  43295. * @param featureName the name of feature to attach
  43296. */
  43297. attachFeature(featureName: string): void;
  43298. /**
  43299. * Can be used inside a session or when the session ends to detach a specific feature
  43300. * @param featureName the name of the feature to detach
  43301. */
  43302. detachFeature(featureName: string): void;
  43303. /**
  43304. * Used to disable an already-enabled feature
  43305. * The feature will be disposed and will be recreated once enabled.
  43306. * @param featureName the feature to disable
  43307. * @returns true if disable was successful
  43308. */
  43309. disableFeature(featureName: string | {
  43310. Name: string;
  43311. }): boolean;
  43312. /**
  43313. * dispose this features manager
  43314. */
  43315. dispose(): void;
  43316. /**
  43317. * 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.
  43318. * 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.
  43319. *
  43320. * @param featureName the name of the feature to load or the class of the feature
  43321. * @param version optional version to load. if not provided the latest version will be enabled
  43322. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43323. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43324. * @returns a new constructed feature or throws an error if feature not found.
  43325. */
  43326. enableFeature(featureName: string | {
  43327. Name: string;
  43328. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43329. /**
  43330. * get the implementation of an enabled feature.
  43331. * @param featureName the name of the feature to load
  43332. * @returns the feature class, if found
  43333. */
  43334. getEnabledFeature(featureName: string): IWebXRFeature;
  43335. /**
  43336. * Get the list of enabled features
  43337. * @returns an array of enabled features
  43338. */
  43339. getEnabledFeatures(): string[];
  43340. }
  43341. }
  43342. declare module BABYLON {
  43343. /**
  43344. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43345. * @see https://doc.babylonjs.com/how_to/webxr
  43346. */
  43347. export class WebXRExperienceHelper implements IDisposable {
  43348. private scene;
  43349. private _nonVRCamera;
  43350. private _originalSceneAutoClear;
  43351. private _supported;
  43352. /**
  43353. * Camera used to render xr content
  43354. */
  43355. camera: WebXRCamera;
  43356. /** A features manager for this xr session */
  43357. featuresManager: WebXRFeaturesManager;
  43358. /**
  43359. * Observers registered here will be triggered after the camera's initial transformation is set
  43360. * This can be used to set a different ground level or an extra rotation.
  43361. *
  43362. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43363. * to the position set after this observable is done executing.
  43364. */
  43365. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43366. /**
  43367. * Fires when the state of the experience helper has changed
  43368. */
  43369. onStateChangedObservable: Observable<WebXRState>;
  43370. /** Session manager used to keep track of xr session */
  43371. sessionManager: WebXRSessionManager;
  43372. /**
  43373. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43374. */
  43375. state: WebXRState;
  43376. /**
  43377. * Creates a WebXRExperienceHelper
  43378. * @param scene The scene the helper should be created in
  43379. */
  43380. private constructor();
  43381. /**
  43382. * Creates the experience helper
  43383. * @param scene the scene to attach the experience helper to
  43384. * @returns a promise for the experience helper
  43385. */
  43386. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43387. /**
  43388. * Disposes of the experience helper
  43389. */
  43390. dispose(): void;
  43391. /**
  43392. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43393. * @param sessionMode options for the XR session
  43394. * @param referenceSpaceType frame of reference of the XR session
  43395. * @param renderTarget the output canvas that will be used to enter XR mode
  43396. * @returns promise that resolves after xr mode has entered
  43397. */
  43398. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43399. /**
  43400. * Exits XR mode and returns the scene to its original state
  43401. * @returns promise that resolves after xr mode has exited
  43402. */
  43403. exitXRAsync(): Promise<void>;
  43404. private _nonXRToXRCamera;
  43405. private _setState;
  43406. }
  43407. }
  43408. declare module BABYLON {
  43409. /**
  43410. * X-Y values for axes in WebXR
  43411. */
  43412. export interface IWebXRMotionControllerAxesValue {
  43413. /**
  43414. * The value of the x axis
  43415. */
  43416. x: number;
  43417. /**
  43418. * The value of the y-axis
  43419. */
  43420. y: number;
  43421. }
  43422. /**
  43423. * changed / previous values for the values of this component
  43424. */
  43425. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43426. /**
  43427. * current (this frame) value
  43428. */
  43429. current: T;
  43430. /**
  43431. * previous (last change) value
  43432. */
  43433. previous: T;
  43434. }
  43435. /**
  43436. * Represents changes in the component between current frame and last values recorded
  43437. */
  43438. export interface IWebXRMotionControllerComponentChanges {
  43439. /**
  43440. * will be populated with previous and current values if axes changed
  43441. */
  43442. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43443. /**
  43444. * will be populated with previous and current values if pressed changed
  43445. */
  43446. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43447. /**
  43448. * will be populated with previous and current values if touched changed
  43449. */
  43450. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43451. /**
  43452. * will be populated with previous and current values if value changed
  43453. */
  43454. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43455. }
  43456. /**
  43457. * This class represents a single component (for example button or thumbstick) of a motion controller
  43458. */
  43459. export class WebXRControllerComponent implements IDisposable {
  43460. /**
  43461. * the id of this component
  43462. */
  43463. id: string;
  43464. /**
  43465. * the type of the component
  43466. */
  43467. type: MotionControllerComponentType;
  43468. private _buttonIndex;
  43469. private _axesIndices;
  43470. private _axes;
  43471. private _changes;
  43472. private _currentValue;
  43473. private _hasChanges;
  43474. private _pressed;
  43475. private _touched;
  43476. /**
  43477. * button component type
  43478. */
  43479. static BUTTON_TYPE: MotionControllerComponentType;
  43480. /**
  43481. * squeeze component type
  43482. */
  43483. static SQUEEZE_TYPE: MotionControllerComponentType;
  43484. /**
  43485. * Thumbstick component type
  43486. */
  43487. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43488. /**
  43489. * Touchpad component type
  43490. */
  43491. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43492. /**
  43493. * trigger component type
  43494. */
  43495. static TRIGGER_TYPE: MotionControllerComponentType;
  43496. /**
  43497. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43498. * the axes data changes
  43499. */
  43500. onAxisValueChangedObservable: Observable<{
  43501. x: number;
  43502. y: number;
  43503. }>;
  43504. /**
  43505. * Observers registered here will be triggered when the state of a button changes
  43506. * State change is either pressed / touched / value
  43507. */
  43508. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43509. /**
  43510. * Creates a new component for a motion controller.
  43511. * It is created by the motion controller itself
  43512. *
  43513. * @param id the id of this component
  43514. * @param type the type of the component
  43515. * @param _buttonIndex index in the buttons array of the gamepad
  43516. * @param _axesIndices indices of the values in the axes array of the gamepad
  43517. */
  43518. constructor(
  43519. /**
  43520. * the id of this component
  43521. */
  43522. id: string,
  43523. /**
  43524. * the type of the component
  43525. */
  43526. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43527. /**
  43528. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43529. */
  43530. get axes(): IWebXRMotionControllerAxesValue;
  43531. /**
  43532. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43533. */
  43534. get changes(): IWebXRMotionControllerComponentChanges;
  43535. /**
  43536. * Return whether or not the component changed the last frame
  43537. */
  43538. get hasChanges(): boolean;
  43539. /**
  43540. * is the button currently pressed
  43541. */
  43542. get pressed(): boolean;
  43543. /**
  43544. * is the button currently touched
  43545. */
  43546. get touched(): boolean;
  43547. /**
  43548. * Get the current value of this component
  43549. */
  43550. get value(): number;
  43551. /**
  43552. * Dispose this component
  43553. */
  43554. dispose(): void;
  43555. /**
  43556. * Are there axes correlating to this component
  43557. * @return true is axes data is available
  43558. */
  43559. isAxes(): boolean;
  43560. /**
  43561. * Is this component a button (hence - pressable)
  43562. * @returns true if can be pressed
  43563. */
  43564. isButton(): boolean;
  43565. /**
  43566. * update this component using the gamepad object it is in. Called on every frame
  43567. * @param nativeController the native gamepad controller object
  43568. */
  43569. update(nativeController: IMinimalMotionControllerObject): void;
  43570. }
  43571. }
  43572. declare module BABYLON {
  43573. /**
  43574. * Class used to represent data loading progression
  43575. */
  43576. export class SceneLoaderProgressEvent {
  43577. /** defines if data length to load can be evaluated */
  43578. readonly lengthComputable: boolean;
  43579. /** defines the loaded data length */
  43580. readonly loaded: number;
  43581. /** defines the data length to load */
  43582. readonly total: number;
  43583. /**
  43584. * Create a new progress event
  43585. * @param lengthComputable defines if data length to load can be evaluated
  43586. * @param loaded defines the loaded data length
  43587. * @param total defines the data length to load
  43588. */
  43589. constructor(
  43590. /** defines if data length to load can be evaluated */
  43591. lengthComputable: boolean,
  43592. /** defines the loaded data length */
  43593. loaded: number,
  43594. /** defines the data length to load */
  43595. total: number);
  43596. /**
  43597. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43598. * @param event defines the source event
  43599. * @returns a new SceneLoaderProgressEvent
  43600. */
  43601. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43602. }
  43603. /**
  43604. * Interface used by SceneLoader plugins to define supported file extensions
  43605. */
  43606. export interface ISceneLoaderPluginExtensions {
  43607. /**
  43608. * Defines the list of supported extensions
  43609. */
  43610. [extension: string]: {
  43611. isBinary: boolean;
  43612. };
  43613. }
  43614. /**
  43615. * Interface used by SceneLoader plugin factory
  43616. */
  43617. export interface ISceneLoaderPluginFactory {
  43618. /**
  43619. * Defines the name of the factory
  43620. */
  43621. name: string;
  43622. /**
  43623. * Function called to create a new plugin
  43624. * @return the new plugin
  43625. */
  43626. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43627. /**
  43628. * The callback that returns true if the data can be directly loaded.
  43629. * @param data string containing the file data
  43630. * @returns if the data can be loaded directly
  43631. */
  43632. canDirectLoad?(data: string): boolean;
  43633. }
  43634. /**
  43635. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43636. */
  43637. export interface ISceneLoaderPluginBase {
  43638. /**
  43639. * The friendly name of this plugin.
  43640. */
  43641. name: string;
  43642. /**
  43643. * The file extensions supported by this plugin.
  43644. */
  43645. extensions: string | ISceneLoaderPluginExtensions;
  43646. /**
  43647. * The callback called when loading from a url.
  43648. * @param scene scene loading this url
  43649. * @param url url to load
  43650. * @param onSuccess callback called when the file successfully loads
  43651. * @param onProgress callback called while file is loading (if the server supports this mode)
  43652. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43653. * @param onError callback called when the file fails to load
  43654. * @returns a file request object
  43655. */
  43656. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43657. /**
  43658. * The callback called when loading from a file object.
  43659. * @param scene scene loading this file
  43660. * @param file defines the file to load
  43661. * @param onSuccess defines the callback to call when data is loaded
  43662. * @param onProgress defines the callback to call during loading process
  43663. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43664. * @param onError defines the callback to call when an error occurs
  43665. * @returns a file request object
  43666. */
  43667. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43668. /**
  43669. * The callback that returns true if the data can be directly loaded.
  43670. * @param data string containing the file data
  43671. * @returns if the data can be loaded directly
  43672. */
  43673. canDirectLoad?(data: string): boolean;
  43674. /**
  43675. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43676. * @param scene scene loading this data
  43677. * @param data string containing the data
  43678. * @returns data to pass to the plugin
  43679. */
  43680. directLoad?(scene: Scene, data: string): any;
  43681. /**
  43682. * The callback that allows custom handling of the root url based on the response url.
  43683. * @param rootUrl the original root url
  43684. * @param responseURL the response url if available
  43685. * @returns the new root url
  43686. */
  43687. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43688. }
  43689. /**
  43690. * Interface used to define a SceneLoader plugin
  43691. */
  43692. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43693. /**
  43694. * Import meshes into a scene.
  43695. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43696. * @param scene The scene to import into
  43697. * @param data The data to import
  43698. * @param rootUrl The root url for scene and resources
  43699. * @param meshes The meshes array to import into
  43700. * @param particleSystems The particle systems array to import into
  43701. * @param skeletons The skeletons array to import into
  43702. * @param onError The callback when import fails
  43703. * @returns True if successful or false otherwise
  43704. */
  43705. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43706. /**
  43707. * Load into a scene.
  43708. * @param scene The scene to load into
  43709. * @param data The data to import
  43710. * @param rootUrl The root url for scene and resources
  43711. * @param onError The callback when import fails
  43712. * @returns True if successful or false otherwise
  43713. */
  43714. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43715. /**
  43716. * Load into an asset container.
  43717. * @param scene The scene to load into
  43718. * @param data The data to import
  43719. * @param rootUrl The root url for scene and resources
  43720. * @param onError The callback when import fails
  43721. * @returns The loaded asset container
  43722. */
  43723. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43724. }
  43725. /**
  43726. * Interface used to define an async SceneLoader plugin
  43727. */
  43728. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43729. /**
  43730. * Import meshes into a scene.
  43731. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43732. * @param scene The scene to import into
  43733. * @param data The data to import
  43734. * @param rootUrl The root url for scene and resources
  43735. * @param onProgress The callback when the load progresses
  43736. * @param fileName Defines the name of the file to load
  43737. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43738. */
  43739. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43740. meshes: AbstractMesh[];
  43741. particleSystems: IParticleSystem[];
  43742. skeletons: Skeleton[];
  43743. animationGroups: AnimationGroup[];
  43744. }>;
  43745. /**
  43746. * Load into a scene.
  43747. * @param scene The scene to load into
  43748. * @param data The data to import
  43749. * @param rootUrl The root url for scene and resources
  43750. * @param onProgress The callback when the load progresses
  43751. * @param fileName Defines the name of the file to load
  43752. * @returns Nothing
  43753. */
  43754. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43755. /**
  43756. * Load into an asset container.
  43757. * @param scene The scene to load into
  43758. * @param data The data to import
  43759. * @param rootUrl The root url for scene and resources
  43760. * @param onProgress The callback when the load progresses
  43761. * @param fileName Defines the name of the file to load
  43762. * @returns The loaded asset container
  43763. */
  43764. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43765. }
  43766. /**
  43767. * Mode that determines how to handle old animation groups before loading new ones.
  43768. */
  43769. export enum SceneLoaderAnimationGroupLoadingMode {
  43770. /**
  43771. * Reset all old animations to initial state then dispose them.
  43772. */
  43773. Clean = 0,
  43774. /**
  43775. * Stop all old animations.
  43776. */
  43777. Stop = 1,
  43778. /**
  43779. * Restart old animations from first frame.
  43780. */
  43781. Sync = 2,
  43782. /**
  43783. * Old animations remains untouched.
  43784. */
  43785. NoSync = 3
  43786. }
  43787. /**
  43788. * Class used to load scene from various file formats using registered plugins
  43789. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43790. */
  43791. export class SceneLoader {
  43792. /**
  43793. * No logging while loading
  43794. */
  43795. static readonly NO_LOGGING: number;
  43796. /**
  43797. * Minimal logging while loading
  43798. */
  43799. static readonly MINIMAL_LOGGING: number;
  43800. /**
  43801. * Summary logging while loading
  43802. */
  43803. static readonly SUMMARY_LOGGING: number;
  43804. /**
  43805. * Detailled logging while loading
  43806. */
  43807. static readonly DETAILED_LOGGING: number;
  43808. /**
  43809. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43810. */
  43811. static get ForceFullSceneLoadingForIncremental(): boolean;
  43812. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43813. /**
  43814. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43815. */
  43816. static get ShowLoadingScreen(): boolean;
  43817. static set ShowLoadingScreen(value: boolean);
  43818. /**
  43819. * Defines the current logging level (while loading the scene)
  43820. * @ignorenaming
  43821. */
  43822. static get loggingLevel(): number;
  43823. static set loggingLevel(value: number);
  43824. /**
  43825. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43826. */
  43827. static get CleanBoneMatrixWeights(): boolean;
  43828. static set CleanBoneMatrixWeights(value: boolean);
  43829. /**
  43830. * Event raised when a plugin is used to load a scene
  43831. */
  43832. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43833. private static _registeredPlugins;
  43834. private static _getDefaultPlugin;
  43835. private static _getPluginForExtension;
  43836. private static _getPluginForDirectLoad;
  43837. private static _getPluginForFilename;
  43838. private static _getDirectLoad;
  43839. private static _loadData;
  43840. private static _getFileInfo;
  43841. /**
  43842. * Gets a plugin that can load the given extension
  43843. * @param extension defines the extension to load
  43844. * @returns a plugin or null if none works
  43845. */
  43846. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43847. /**
  43848. * Gets a boolean indicating that the given extension can be loaded
  43849. * @param extension defines the extension to load
  43850. * @returns true if the extension is supported
  43851. */
  43852. static IsPluginForExtensionAvailable(extension: string): boolean;
  43853. /**
  43854. * Adds a new plugin to the list of registered plugins
  43855. * @param plugin defines the plugin to add
  43856. */
  43857. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43858. /**
  43859. * Import meshes into a scene
  43860. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43861. * @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)
  43862. * @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)
  43863. * @param scene the instance of BABYLON.Scene to append to
  43864. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43865. * @param onProgress a callback with a progress event for each file being loaded
  43866. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43867. * @param pluginExtension the extension used to determine the plugin
  43868. * @returns The loaded plugin
  43869. */
  43870. 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>;
  43871. /**
  43872. * Import meshes into a scene
  43873. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43874. * @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)
  43875. * @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)
  43876. * @param scene the instance of BABYLON.Scene to append to
  43877. * @param onProgress a callback with a progress event for each file being loaded
  43878. * @param pluginExtension the extension used to determine the plugin
  43879. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43880. */
  43881. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43882. meshes: AbstractMesh[];
  43883. particleSystems: IParticleSystem[];
  43884. skeletons: Skeleton[];
  43885. animationGroups: AnimationGroup[];
  43886. }>;
  43887. /**
  43888. * Load a scene
  43889. * @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)
  43890. * @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)
  43891. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43892. * @param onSuccess a callback with the scene when import succeeds
  43893. * @param onProgress a callback with a progress event for each file being loaded
  43894. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43895. * @param pluginExtension the extension used to determine the plugin
  43896. * @returns The loaded plugin
  43897. */
  43898. 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>;
  43899. /**
  43900. * Load a scene
  43901. * @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)
  43902. * @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)
  43903. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43904. * @param onProgress a callback with a progress event for each file being loaded
  43905. * @param pluginExtension the extension used to determine the plugin
  43906. * @returns The loaded scene
  43907. */
  43908. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43909. /**
  43910. * Append a scene
  43911. * @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)
  43912. * @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)
  43913. * @param scene is the instance of BABYLON.Scene to append to
  43914. * @param onSuccess a callback with the scene when import succeeds
  43915. * @param onProgress a callback with a progress event for each file being loaded
  43916. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43917. * @param pluginExtension the extension used to determine the plugin
  43918. * @returns The loaded plugin
  43919. */
  43920. 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>;
  43921. /**
  43922. * Append a scene
  43923. * @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)
  43924. * @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)
  43925. * @param scene is the instance of BABYLON.Scene to append to
  43926. * @param onProgress a callback with a progress event for each file being loaded
  43927. * @param pluginExtension the extension used to determine the plugin
  43928. * @returns The given scene
  43929. */
  43930. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43931. /**
  43932. * Load a scene into an asset container
  43933. * @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)
  43934. * @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)
  43935. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43936. * @param onSuccess a callback with the scene when import succeeds
  43937. * @param onProgress a callback with a progress event for each file being loaded
  43938. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43939. * @param pluginExtension the extension used to determine the plugin
  43940. * @returns The loaded plugin
  43941. */
  43942. 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>;
  43943. /**
  43944. * Load a scene into an asset container
  43945. * @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)
  43946. * @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)
  43947. * @param scene is the instance of Scene to append to
  43948. * @param onProgress a callback with a progress event for each file being loaded
  43949. * @param pluginExtension the extension used to determine the plugin
  43950. * @returns The loaded asset container
  43951. */
  43952. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43953. /**
  43954. * Import animations from a file into a scene
  43955. * @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)
  43956. * @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)
  43957. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43958. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43959. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43960. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43961. * @param onSuccess a callback with the scene when import succeeds
  43962. * @param onProgress a callback with a progress event for each file being loaded
  43963. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43964. */
  43965. 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;
  43966. /**
  43967. * Import animations from a file into a scene
  43968. * @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)
  43969. * @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)
  43970. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43971. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43972. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43973. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43974. * @param onSuccess a callback with the scene when import succeeds
  43975. * @param onProgress a callback with a progress event for each file being loaded
  43976. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43977. * @returns the updated scene with imported animations
  43978. */
  43979. 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>;
  43980. }
  43981. }
  43982. declare module BABYLON {
  43983. /**
  43984. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43985. */
  43986. export type MotionControllerHandness = "none" | "left" | "right";
  43987. /**
  43988. * The type of components available in motion controllers.
  43989. * This is not the name of the component.
  43990. */
  43991. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43992. /**
  43993. * The state of a controller component
  43994. */
  43995. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43996. /**
  43997. * The schema of motion controller layout.
  43998. * No object will be initialized using this interface
  43999. * This is used just to define the profile.
  44000. */
  44001. export interface IMotionControllerLayout {
  44002. /**
  44003. * Path to load the assets. Usually relative to the base path
  44004. */
  44005. assetPath: string;
  44006. /**
  44007. * Available components (unsorted)
  44008. */
  44009. components: {
  44010. /**
  44011. * A map of component Ids
  44012. */
  44013. [componentId: string]: {
  44014. /**
  44015. * The type of input the component outputs
  44016. */
  44017. type: MotionControllerComponentType;
  44018. /**
  44019. * The indices of this component in the gamepad object
  44020. */
  44021. gamepadIndices: {
  44022. /**
  44023. * Index of button
  44024. */
  44025. button?: number;
  44026. /**
  44027. * If available, index of x-axis
  44028. */
  44029. xAxis?: number;
  44030. /**
  44031. * If available, index of y-axis
  44032. */
  44033. yAxis?: number;
  44034. };
  44035. /**
  44036. * The mesh's root node name
  44037. */
  44038. rootNodeName: string;
  44039. /**
  44040. * Animation definitions for this model
  44041. */
  44042. visualResponses: {
  44043. [stateKey: string]: {
  44044. /**
  44045. * What property will be animated
  44046. */
  44047. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44048. /**
  44049. * What states influence this visual response
  44050. */
  44051. states: MotionControllerComponentStateType[];
  44052. /**
  44053. * Type of animation - movement or visibility
  44054. */
  44055. valueNodeProperty: "transform" | "visibility";
  44056. /**
  44057. * Base node name to move. Its position will be calculated according to the min and max nodes
  44058. */
  44059. valueNodeName?: string;
  44060. /**
  44061. * Minimum movement node
  44062. */
  44063. minNodeName?: string;
  44064. /**
  44065. * Max movement node
  44066. */
  44067. maxNodeName?: string;
  44068. };
  44069. };
  44070. /**
  44071. * If touch enabled, what is the name of node to display user feedback
  44072. */
  44073. touchPointNodeName?: string;
  44074. };
  44075. };
  44076. /**
  44077. * Is it xr standard mapping or not
  44078. */
  44079. gamepadMapping: "" | "xr-standard";
  44080. /**
  44081. * Base root node of this entire model
  44082. */
  44083. rootNodeName: string;
  44084. /**
  44085. * Defines the main button component id
  44086. */
  44087. selectComponentId: string;
  44088. }
  44089. /**
  44090. * A definition for the layout map in the input profile
  44091. */
  44092. export interface IMotionControllerLayoutMap {
  44093. /**
  44094. * Layouts with handness type as a key
  44095. */
  44096. [handness: string]: IMotionControllerLayout;
  44097. }
  44098. /**
  44099. * The XR Input profile schema
  44100. * Profiles can be found here:
  44101. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44102. */
  44103. export interface IMotionControllerProfile {
  44104. /**
  44105. * fallback profiles for this profileId
  44106. */
  44107. fallbackProfileIds: string[];
  44108. /**
  44109. * The layout map, with handness as key
  44110. */
  44111. layouts: IMotionControllerLayoutMap;
  44112. /**
  44113. * The id of this profile
  44114. * correlates to the profile(s) in the xrInput.profiles array
  44115. */
  44116. profileId: string;
  44117. }
  44118. /**
  44119. * A helper-interface for the 3 meshes needed for controller button animation
  44120. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44121. */
  44122. export interface IMotionControllerButtonMeshMap {
  44123. /**
  44124. * the mesh that defines the pressed value mesh position.
  44125. * This is used to find the max-position of this button
  44126. */
  44127. pressedMesh: AbstractMesh;
  44128. /**
  44129. * the mesh that defines the unpressed value mesh position.
  44130. * This is used to find the min (or initial) position of this button
  44131. */
  44132. unpressedMesh: AbstractMesh;
  44133. /**
  44134. * The mesh that will be changed when value changes
  44135. */
  44136. valueMesh: AbstractMesh;
  44137. }
  44138. /**
  44139. * A helper-interface for the 3 meshes needed for controller axis animation.
  44140. * This will be expanded when touchpad animations are fully supported
  44141. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44142. */
  44143. export interface IMotionControllerMeshMap {
  44144. /**
  44145. * the mesh that defines the maximum value mesh position.
  44146. */
  44147. maxMesh?: AbstractMesh;
  44148. /**
  44149. * the mesh that defines the minimum value mesh position.
  44150. */
  44151. minMesh?: AbstractMesh;
  44152. /**
  44153. * The mesh that will be changed when axis value changes
  44154. */
  44155. valueMesh: AbstractMesh;
  44156. }
  44157. /**
  44158. * The elements needed for change-detection of the gamepad objects in motion controllers
  44159. */
  44160. export interface IMinimalMotionControllerObject {
  44161. /**
  44162. * Available axes of this controller
  44163. */
  44164. axes: number[];
  44165. /**
  44166. * An array of available buttons
  44167. */
  44168. buttons: Array<{
  44169. /**
  44170. * Value of the button/trigger
  44171. */
  44172. value: number;
  44173. /**
  44174. * If the button/trigger is currently touched
  44175. */
  44176. touched: boolean;
  44177. /**
  44178. * If the button/trigger is currently pressed
  44179. */
  44180. pressed: boolean;
  44181. }>;
  44182. }
  44183. /**
  44184. * An Abstract Motion controller
  44185. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44186. * Each component has an observable to check for changes in value and state
  44187. */
  44188. export abstract class WebXRAbstractMotionController implements IDisposable {
  44189. protected scene: Scene;
  44190. protected layout: IMotionControllerLayout;
  44191. /**
  44192. * The gamepad object correlating to this controller
  44193. */
  44194. gamepadObject: IMinimalMotionControllerObject;
  44195. /**
  44196. * handness (left/right/none) of this controller
  44197. */
  44198. handness: MotionControllerHandness;
  44199. private _initComponent;
  44200. private _modelReady;
  44201. /**
  44202. * A map of components (WebXRControllerComponent) in this motion controller
  44203. * Components have a ComponentType and can also have both button and axis definitions
  44204. */
  44205. readonly components: {
  44206. [id: string]: WebXRControllerComponent;
  44207. };
  44208. /**
  44209. * Disable the model's animation. Can be set at any time.
  44210. */
  44211. disableAnimation: boolean;
  44212. /**
  44213. * Observers registered here will be triggered when the model of this controller is done loading
  44214. */
  44215. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44216. /**
  44217. * The profile id of this motion controller
  44218. */
  44219. abstract profileId: string;
  44220. /**
  44221. * The root mesh of the model. It is null if the model was not yet initialized
  44222. */
  44223. rootMesh: Nullable<AbstractMesh>;
  44224. /**
  44225. * constructs a new abstract motion controller
  44226. * @param scene the scene to which the model of the controller will be added
  44227. * @param layout The profile layout to load
  44228. * @param gamepadObject The gamepad object correlating to this controller
  44229. * @param handness handness (left/right/none) of this controller
  44230. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44231. */
  44232. constructor(scene: Scene, layout: IMotionControllerLayout,
  44233. /**
  44234. * The gamepad object correlating to this controller
  44235. */
  44236. gamepadObject: IMinimalMotionControllerObject,
  44237. /**
  44238. * handness (left/right/none) of this controller
  44239. */
  44240. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44241. /**
  44242. * Dispose this controller, the model mesh and all its components
  44243. */
  44244. dispose(): void;
  44245. /**
  44246. * Returns all components of specific type
  44247. * @param type the type to search for
  44248. * @return an array of components with this type
  44249. */
  44250. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44251. /**
  44252. * get a component based an its component id as defined in layout.components
  44253. * @param id the id of the component
  44254. * @returns the component correlates to the id or undefined if not found
  44255. */
  44256. getComponent(id: string): WebXRControllerComponent;
  44257. /**
  44258. * Get the list of components available in this motion controller
  44259. * @returns an array of strings correlating to available components
  44260. */
  44261. getComponentIds(): string[];
  44262. /**
  44263. * Get the first component of specific type
  44264. * @param type type of component to find
  44265. * @return a controller component or null if not found
  44266. */
  44267. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44268. /**
  44269. * Get the main (Select) component of this controller as defined in the layout
  44270. * @returns the main component of this controller
  44271. */
  44272. getMainComponent(): WebXRControllerComponent;
  44273. /**
  44274. * Loads the model correlating to this controller
  44275. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44276. * @returns A promise fulfilled with the result of the model loading
  44277. */
  44278. loadModel(): Promise<boolean>;
  44279. /**
  44280. * Update this model using the current XRFrame
  44281. * @param xrFrame the current xr frame to use and update the model
  44282. */
  44283. updateFromXRFrame(xrFrame: XRFrame): void;
  44284. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44285. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44286. /**
  44287. * Moves the axis on the controller mesh based on its current state
  44288. * @param axis the index of the axis
  44289. * @param axisValue the value of the axis which determines the meshes new position
  44290. * @hidden
  44291. */
  44292. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44293. /**
  44294. * Update the model itself with the current frame data
  44295. * @param xrFrame the frame to use for updating the model mesh
  44296. */
  44297. protected updateModel(xrFrame: XRFrame): void;
  44298. /**
  44299. * Get the filename and path for this controller's model
  44300. * @returns a map of filename and path
  44301. */
  44302. protected abstract _getFilenameAndPath(): {
  44303. filename: string;
  44304. path: string;
  44305. };
  44306. /**
  44307. * This function is called before the mesh is loaded. It checks for loading constraints.
  44308. * For example, this function can check if the GLB loader is available
  44309. * If this function returns false, the generic controller will be loaded instead
  44310. * @returns Is the client ready to load the mesh
  44311. */
  44312. protected abstract _getModelLoadingConstraints(): boolean;
  44313. /**
  44314. * This function will be called after the model was successfully loaded and can be used
  44315. * for mesh transformations before it is available for the user
  44316. * @param meshes the loaded meshes
  44317. */
  44318. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44319. /**
  44320. * Set the root mesh for this controller. Important for the WebXR controller class
  44321. * @param meshes the loaded meshes
  44322. */
  44323. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44324. /**
  44325. * A function executed each frame that updates the mesh (if needed)
  44326. * @param xrFrame the current xrFrame
  44327. */
  44328. protected abstract _updateModel(xrFrame: XRFrame): void;
  44329. private _getGenericFilenameAndPath;
  44330. private _getGenericParentMesh;
  44331. }
  44332. }
  44333. declare module BABYLON {
  44334. /**
  44335. * A generic trigger-only motion controller for WebXR
  44336. */
  44337. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44338. /**
  44339. * Static version of the profile id of this controller
  44340. */
  44341. static ProfileId: string;
  44342. profileId: string;
  44343. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44344. protected _getFilenameAndPath(): {
  44345. filename: string;
  44346. path: string;
  44347. };
  44348. protected _getModelLoadingConstraints(): boolean;
  44349. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44350. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44351. protected _updateModel(): void;
  44352. }
  44353. }
  44354. declare module BABYLON {
  44355. /**
  44356. * Class containing static functions to help procedurally build meshes
  44357. */
  44358. export class SphereBuilder {
  44359. /**
  44360. * Creates a sphere mesh
  44361. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44362. * * 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`)
  44363. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44364. * * 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
  44365. * * 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)
  44366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44367. * * 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
  44368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44369. * @param name defines the name of the mesh
  44370. * @param options defines the options used to create the mesh
  44371. * @param scene defines the hosting scene
  44372. * @returns the sphere mesh
  44373. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44374. */
  44375. static CreateSphere(name: string, options: {
  44376. segments?: number;
  44377. diameter?: number;
  44378. diameterX?: number;
  44379. diameterY?: number;
  44380. diameterZ?: number;
  44381. arc?: number;
  44382. slice?: number;
  44383. sideOrientation?: number;
  44384. frontUVs?: Vector4;
  44385. backUVs?: Vector4;
  44386. updatable?: boolean;
  44387. }, scene?: Nullable<Scene>): Mesh;
  44388. }
  44389. }
  44390. declare module BABYLON {
  44391. /**
  44392. * A profiled motion controller has its profile loaded from an online repository.
  44393. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44394. */
  44395. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44396. private _repositoryUrl;
  44397. private _buttonMeshMapping;
  44398. private _touchDots;
  44399. /**
  44400. * The profile ID of this controller. Will be populated when the controller initializes.
  44401. */
  44402. profileId: string;
  44403. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44404. dispose(): void;
  44405. protected _getFilenameAndPath(): {
  44406. filename: string;
  44407. path: string;
  44408. };
  44409. protected _getModelLoadingConstraints(): boolean;
  44410. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44411. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44412. protected _updateModel(_xrFrame: XRFrame): void;
  44413. }
  44414. }
  44415. declare module BABYLON {
  44416. /**
  44417. * A construction function type to create a new controller based on an xrInput object
  44418. */
  44419. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44420. /**
  44421. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44422. *
  44423. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44424. * it should be replaced with auto-loaded controllers.
  44425. *
  44426. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44427. */
  44428. export class WebXRMotionControllerManager {
  44429. private static _AvailableControllers;
  44430. private static _Fallbacks;
  44431. private static _ProfileLoadingPromises;
  44432. private static _ProfilesList;
  44433. /**
  44434. * The base URL of the online controller repository. Can be changed at any time.
  44435. */
  44436. static BaseRepositoryUrl: string;
  44437. /**
  44438. * Which repository gets priority - local or online
  44439. */
  44440. static PrioritizeOnlineRepository: boolean;
  44441. /**
  44442. * Use the online repository, or use only locally-defined controllers
  44443. */
  44444. static UseOnlineRepository: boolean;
  44445. /**
  44446. * Clear the cache used for profile loading and reload when requested again
  44447. */
  44448. static ClearProfilesCache(): void;
  44449. /**
  44450. * Register the default fallbacks.
  44451. * This function is called automatically when this file is imported.
  44452. */
  44453. static DefaultFallbacks(): void;
  44454. /**
  44455. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44456. * @param profileId the profile to which a fallback needs to be found
  44457. * @return an array with corresponding fallback profiles
  44458. */
  44459. static FindFallbackWithProfileId(profileId: string): string[];
  44460. /**
  44461. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44462. * The order of search:
  44463. *
  44464. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44465. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44466. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44467. * 4) return the generic trigger controller if none were found
  44468. *
  44469. * @param xrInput the xrInput to which a new controller is initialized
  44470. * @param scene the scene to which the model will be added
  44471. * @param forceProfile force a certain profile for this controller
  44472. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44473. */
  44474. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44475. /**
  44476. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44477. *
  44478. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44479. *
  44480. * @param type the profile type to register
  44481. * @param constructFunction the function to be called when loading this profile
  44482. */
  44483. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44484. /**
  44485. * Register a fallback to a specific profile.
  44486. * @param profileId the profileId that will receive the fallbacks
  44487. * @param fallbacks A list of fallback profiles
  44488. */
  44489. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44490. /**
  44491. * Will update the list of profiles available in the repository
  44492. * @return a promise that resolves to a map of profiles available online
  44493. */
  44494. static UpdateProfilesList(): Promise<{
  44495. [profile: string]: string;
  44496. }>;
  44497. private static _LoadProfileFromRepository;
  44498. private static _LoadProfilesFromAvailableControllers;
  44499. }
  44500. }
  44501. declare module BABYLON {
  44502. /**
  44503. * Configuration options for the WebXR controller creation
  44504. */
  44505. export interface IWebXRControllerOptions {
  44506. /**
  44507. * Should the controller mesh be animated when a user interacts with it
  44508. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44509. */
  44510. disableMotionControllerAnimation?: boolean;
  44511. /**
  44512. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44513. */
  44514. doNotLoadControllerMesh?: boolean;
  44515. /**
  44516. * Force a specific controller type for this controller.
  44517. * This can be used when creating your own profile or when testing different controllers
  44518. */
  44519. forceControllerProfile?: string;
  44520. }
  44521. /**
  44522. * Represents an XR controller
  44523. */
  44524. export class WebXRInputSource {
  44525. private _scene;
  44526. /** The underlying input source for the controller */
  44527. inputSource: XRInputSource;
  44528. private _options;
  44529. private _tmpQuaternion;
  44530. private _tmpVector;
  44531. private _uniqueId;
  44532. /**
  44533. * 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
  44534. */
  44535. grip?: AbstractMesh;
  44536. /**
  44537. * If available, this is the gamepad object related to this controller.
  44538. * Using this object it is possible to get click events and trackpad changes of the
  44539. * webxr controller that is currently being used.
  44540. */
  44541. motionController?: WebXRAbstractMotionController;
  44542. /**
  44543. * Event that fires when the controller is removed/disposed.
  44544. * The object provided as event data is this controller, after associated assets were disposed.
  44545. * uniqueId is still available.
  44546. */
  44547. onDisposeObservable: Observable<WebXRInputSource>;
  44548. /**
  44549. * Will be triggered when the mesh associated with the motion controller is done loading.
  44550. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44551. * A shortened version of controller -> motion controller -> on mesh loaded.
  44552. */
  44553. onMeshLoadedObservable: Observable<AbstractMesh>;
  44554. /**
  44555. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44556. */
  44557. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44558. /**
  44559. * Pointer which can be used to select objects or attach a visible laser to
  44560. */
  44561. pointer: AbstractMesh;
  44562. /**
  44563. * Creates the controller
  44564. * @see https://doc.babylonjs.com/how_to/webxr
  44565. * @param _scene the scene which the controller should be associated to
  44566. * @param inputSource the underlying input source for the controller
  44567. * @param _options options for this controller creation
  44568. */
  44569. constructor(_scene: Scene,
  44570. /** The underlying input source for the controller */
  44571. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44572. /**
  44573. * Get this controllers unique id
  44574. */
  44575. get uniqueId(): string;
  44576. /**
  44577. * Disposes of the object
  44578. */
  44579. dispose(): void;
  44580. /**
  44581. * Gets a world space ray coming from the pointer or grip
  44582. * @param result the resulting ray
  44583. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44584. */
  44585. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44586. /**
  44587. * Updates the controller pose based on the given XRFrame
  44588. * @param xrFrame xr frame to update the pose with
  44589. * @param referenceSpace reference space to use
  44590. */
  44591. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44592. }
  44593. }
  44594. declare module BABYLON {
  44595. /**
  44596. * The schema for initialization options of the XR Input class
  44597. */
  44598. export interface IWebXRInputOptions {
  44599. /**
  44600. * If set to true no model will be automatically loaded
  44601. */
  44602. doNotLoadControllerMeshes?: boolean;
  44603. /**
  44604. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44605. * If not found, the xr input profile data will be used.
  44606. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44607. */
  44608. forceInputProfile?: string;
  44609. /**
  44610. * Do not send a request to the controller repository to load the profile.
  44611. *
  44612. * Instead, use the controllers available in babylon itself.
  44613. */
  44614. disableOnlineControllerRepository?: boolean;
  44615. /**
  44616. * A custom URL for the controllers repository
  44617. */
  44618. customControllersRepositoryURL?: string;
  44619. /**
  44620. * Should the controller model's components not move according to the user input
  44621. */
  44622. disableControllerAnimation?: boolean;
  44623. }
  44624. /**
  44625. * XR input used to track XR inputs such as controllers/rays
  44626. */
  44627. export class WebXRInput implements IDisposable {
  44628. /**
  44629. * the xr session manager for this session
  44630. */
  44631. xrSessionManager: WebXRSessionManager;
  44632. /**
  44633. * the WebXR camera for this session. Mainly used for teleportation
  44634. */
  44635. xrCamera: WebXRCamera;
  44636. private readonly options;
  44637. /**
  44638. * XR controllers being tracked
  44639. */
  44640. controllers: Array<WebXRInputSource>;
  44641. private _frameObserver;
  44642. private _sessionEndedObserver;
  44643. private _sessionInitObserver;
  44644. /**
  44645. * Event when a controller has been connected/added
  44646. */
  44647. onControllerAddedObservable: Observable<WebXRInputSource>;
  44648. /**
  44649. * Event when a controller has been removed/disconnected
  44650. */
  44651. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44652. /**
  44653. * Initializes the WebXRInput
  44654. * @param xrSessionManager the xr session manager for this session
  44655. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44656. * @param options = initialization options for this xr input
  44657. */
  44658. constructor(
  44659. /**
  44660. * the xr session manager for this session
  44661. */
  44662. xrSessionManager: WebXRSessionManager,
  44663. /**
  44664. * the WebXR camera for this session. Mainly used for teleportation
  44665. */
  44666. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44667. private _onInputSourcesChange;
  44668. private _addAndRemoveControllers;
  44669. /**
  44670. * Disposes of the object
  44671. */
  44672. dispose(): void;
  44673. }
  44674. }
  44675. declare module BABYLON {
  44676. /**
  44677. * This is the base class for all WebXR features.
  44678. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44679. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44680. */
  44681. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44682. protected _xrSessionManager: WebXRSessionManager;
  44683. private _attached;
  44684. private _removeOnDetach;
  44685. /**
  44686. * Should auto-attach be disabled?
  44687. */
  44688. disableAutoAttach: boolean;
  44689. /**
  44690. * Construct a new (abstract) WebXR feature
  44691. * @param _xrSessionManager the xr session manager for this feature
  44692. */
  44693. constructor(_xrSessionManager: WebXRSessionManager);
  44694. /**
  44695. * Is this feature attached
  44696. */
  44697. get attached(): boolean;
  44698. /**
  44699. * attach this feature
  44700. *
  44701. * @param force should attachment be forced (even when already attached)
  44702. * @returns true if successful, false is failed or already attached
  44703. */
  44704. attach(force?: boolean): boolean;
  44705. /**
  44706. * detach this feature.
  44707. *
  44708. * @returns true if successful, false if failed or already detached
  44709. */
  44710. detach(): boolean;
  44711. /**
  44712. * Dispose this feature and all of the resources attached
  44713. */
  44714. dispose(): void;
  44715. /**
  44716. * This is used to register callbacks that will automatically be removed when detach is called.
  44717. * @param observable the observable to which the observer will be attached
  44718. * @param callback the callback to register
  44719. */
  44720. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44721. /**
  44722. * Code in this function will be executed on each xrFrame received from the browser.
  44723. * This function will not execute after the feature is detached.
  44724. * @param _xrFrame the current frame
  44725. */
  44726. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44727. }
  44728. }
  44729. declare module BABYLON {
  44730. /**
  44731. * Renders a layer on top of an existing scene
  44732. */
  44733. export class UtilityLayerRenderer implements IDisposable {
  44734. /** the original scene that will be rendered on top of */
  44735. originalScene: Scene;
  44736. private _pointerCaptures;
  44737. private _lastPointerEvents;
  44738. private static _DefaultUtilityLayer;
  44739. private static _DefaultKeepDepthUtilityLayer;
  44740. private _sharedGizmoLight;
  44741. private _renderCamera;
  44742. /**
  44743. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44744. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44745. * @returns the camera that is used when rendering the utility layer
  44746. */
  44747. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44748. /**
  44749. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44750. * @param cam the camera that should be used when rendering the utility layer
  44751. */
  44752. setRenderCamera(cam: Nullable<Camera>): void;
  44753. /**
  44754. * @hidden
  44755. * Light which used by gizmos to get light shading
  44756. */
  44757. _getSharedGizmoLight(): HemisphericLight;
  44758. /**
  44759. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44760. */
  44761. pickUtilitySceneFirst: boolean;
  44762. /**
  44763. * 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)
  44764. */
  44765. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44766. /**
  44767. * 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)
  44768. */
  44769. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44770. /**
  44771. * The scene that is rendered on top of the original scene
  44772. */
  44773. utilityLayerScene: Scene;
  44774. /**
  44775. * If the utility layer should automatically be rendered on top of existing scene
  44776. */
  44777. shouldRender: boolean;
  44778. /**
  44779. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44780. */
  44781. onlyCheckPointerDownEvents: boolean;
  44782. /**
  44783. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44784. */
  44785. processAllEvents: boolean;
  44786. /**
  44787. * Observable raised when the pointer move from the utility layer scene to the main scene
  44788. */
  44789. onPointerOutObservable: Observable<number>;
  44790. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44791. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44792. private _afterRenderObserver;
  44793. private _sceneDisposeObserver;
  44794. private _originalPointerObserver;
  44795. /**
  44796. * Instantiates a UtilityLayerRenderer
  44797. * @param originalScene the original scene that will be rendered on top of
  44798. * @param handleEvents boolean indicating if the utility layer should handle events
  44799. */
  44800. constructor(
  44801. /** the original scene that will be rendered on top of */
  44802. originalScene: Scene, handleEvents?: boolean);
  44803. private _notifyObservers;
  44804. /**
  44805. * Renders the utility layers scene on top of the original scene
  44806. */
  44807. render(): void;
  44808. /**
  44809. * Disposes of the renderer
  44810. */
  44811. dispose(): void;
  44812. private _updateCamera;
  44813. }
  44814. }
  44815. declare module BABYLON {
  44816. /**
  44817. * Options interface for the pointer selection module
  44818. */
  44819. export interface IWebXRControllerPointerSelectionOptions {
  44820. /**
  44821. * if provided, this scene will be used to render meshes.
  44822. */
  44823. customUtilityLayerScene?: Scene;
  44824. /**
  44825. * 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)
  44826. * If not disabled, the last picked point will be used to execute a pointer up event
  44827. * If disabled, pointer up event will be triggered right after the pointer down event.
  44828. * Used in screen and gaze target ray mode only
  44829. */
  44830. disablePointerUpOnTouchOut: boolean;
  44831. /**
  44832. * For gaze mode (time to select instead of press)
  44833. */
  44834. forceGazeMode: boolean;
  44835. /**
  44836. * 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
  44837. * to start a new countdown to the pointer down event.
  44838. * Defaults to 1.
  44839. */
  44840. gazeModePointerMovedFactor?: number;
  44841. /**
  44842. * Different button type to use instead of the main component
  44843. */
  44844. overrideButtonId?: string;
  44845. /**
  44846. * use this rendering group id for the meshes (optional)
  44847. */
  44848. renderingGroupId?: number;
  44849. /**
  44850. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44851. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44852. * 3000 means 3 seconds between pointing at something and selecting it
  44853. */
  44854. timeToSelect?: number;
  44855. /**
  44856. * Should meshes created here be added to a utility layer or the main scene
  44857. */
  44858. useUtilityLayer?: boolean;
  44859. /**
  44860. * the xr input to use with this pointer selection
  44861. */
  44862. xrInput: WebXRInput;
  44863. }
  44864. /**
  44865. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44866. */
  44867. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44868. private readonly _options;
  44869. private static _idCounter;
  44870. private _attachController;
  44871. private _controllers;
  44872. private _scene;
  44873. private _tmpVectorForPickCompare;
  44874. /**
  44875. * The module's name
  44876. */
  44877. static readonly Name: string;
  44878. /**
  44879. * The (Babylon) version of this module.
  44880. * This is an integer representing the implementation version.
  44881. * This number does not correspond to the WebXR specs version
  44882. */
  44883. static readonly Version: number;
  44884. /**
  44885. * Disable lighting on the laser pointer (so it will always be visible)
  44886. */
  44887. disablePointerLighting: boolean;
  44888. /**
  44889. * Disable lighting on the selection mesh (so it will always be visible)
  44890. */
  44891. disableSelectionMeshLighting: boolean;
  44892. /**
  44893. * Should the laser pointer be displayed
  44894. */
  44895. displayLaserPointer: boolean;
  44896. /**
  44897. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44898. */
  44899. displaySelectionMesh: boolean;
  44900. /**
  44901. * This color will be set to the laser pointer when selection is triggered
  44902. */
  44903. laserPointerPickedColor: Color3;
  44904. /**
  44905. * Default color of the laser pointer
  44906. */
  44907. lasterPointerDefaultColor: Color3;
  44908. /**
  44909. * default color of the selection ring
  44910. */
  44911. selectionMeshDefaultColor: Color3;
  44912. /**
  44913. * This color will be applied to the selection ring when selection is triggered
  44914. */
  44915. selectionMeshPickedColor: Color3;
  44916. /**
  44917. * Optional filter to be used for ray selection. This predicate shares behavior with
  44918. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44919. */
  44920. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44921. /**
  44922. * constructs a new background remover module
  44923. * @param _xrSessionManager the session manager for this module
  44924. * @param _options read-only options to be used in this module
  44925. */
  44926. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44927. /**
  44928. * attach this feature
  44929. * Will usually be called by the features manager
  44930. *
  44931. * @returns true if successful.
  44932. */
  44933. attach(): boolean;
  44934. /**
  44935. * detach this feature.
  44936. * Will usually be called by the features manager
  44937. *
  44938. * @returns true if successful.
  44939. */
  44940. detach(): boolean;
  44941. /**
  44942. * Will get the mesh under a specific pointer.
  44943. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44944. * @param controllerId the controllerId to check
  44945. * @returns The mesh under pointer or null if no mesh is under the pointer
  44946. */
  44947. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44948. /**
  44949. * Get the xr controller that correlates to the pointer id in the pointer event
  44950. *
  44951. * @param id the pointer id to search for
  44952. * @returns the controller that correlates to this id or null if not found
  44953. */
  44954. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44955. protected _onXRFrame(_xrFrame: XRFrame): void;
  44956. private _attachGazeMode;
  44957. private _attachScreenRayMode;
  44958. private _attachTrackedPointerRayMode;
  44959. private _convertNormalToDirectionOfRay;
  44960. private _detachController;
  44961. private _generateNewMeshPair;
  44962. private _pickingMoved;
  44963. private _updatePointerDistance;
  44964. }
  44965. }
  44966. declare module BABYLON {
  44967. /**
  44968. * Button which can be used to enter a different mode of XR
  44969. */
  44970. export class WebXREnterExitUIButton {
  44971. /** button element */
  44972. element: HTMLElement;
  44973. /** XR initialization options for the button */
  44974. sessionMode: XRSessionMode;
  44975. /** Reference space type */
  44976. referenceSpaceType: XRReferenceSpaceType;
  44977. /**
  44978. * Creates a WebXREnterExitUIButton
  44979. * @param element button element
  44980. * @param sessionMode XR initialization session mode
  44981. * @param referenceSpaceType the type of reference space to be used
  44982. */
  44983. constructor(
  44984. /** button element */
  44985. element: HTMLElement,
  44986. /** XR initialization options for the button */
  44987. sessionMode: XRSessionMode,
  44988. /** Reference space type */
  44989. referenceSpaceType: XRReferenceSpaceType);
  44990. /**
  44991. * Extendable function which can be used to update the button's visuals when the state changes
  44992. * @param activeButton the current active button in the UI
  44993. */
  44994. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44995. }
  44996. /**
  44997. * Options to create the webXR UI
  44998. */
  44999. export class WebXREnterExitUIOptions {
  45000. /**
  45001. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45002. */
  45003. customButtons?: Array<WebXREnterExitUIButton>;
  45004. /**
  45005. * A reference space type to use when creating the default button.
  45006. * Default is local-floor
  45007. */
  45008. referenceSpaceType?: XRReferenceSpaceType;
  45009. /**
  45010. * Context to enter xr with
  45011. */
  45012. renderTarget?: Nullable<WebXRRenderTarget>;
  45013. /**
  45014. * A session mode to use when creating the default button.
  45015. * Default is immersive-vr
  45016. */
  45017. sessionMode?: XRSessionMode;
  45018. }
  45019. /**
  45020. * UI to allow the user to enter/exit XR mode
  45021. */
  45022. export class WebXREnterExitUI implements IDisposable {
  45023. private scene;
  45024. /** version of the options passed to this UI */
  45025. options: WebXREnterExitUIOptions;
  45026. private _activeButton;
  45027. private _buttons;
  45028. private _overlay;
  45029. /**
  45030. * Fired every time the active button is changed.
  45031. *
  45032. * When xr is entered via a button that launches xr that button will be the callback parameter
  45033. *
  45034. * When exiting xr the callback parameter will be null)
  45035. */
  45036. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45037. /**
  45038. *
  45039. * @param scene babylon scene object to use
  45040. * @param options (read-only) version of the options passed to this UI
  45041. */
  45042. private constructor();
  45043. /**
  45044. * Creates UI to allow the user to enter/exit XR mode
  45045. * @param scene the scene to add the ui to
  45046. * @param helper the xr experience helper to enter/exit xr with
  45047. * @param options options to configure the UI
  45048. * @returns the created ui
  45049. */
  45050. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45051. /**
  45052. * Disposes of the XR UI component
  45053. */
  45054. dispose(): void;
  45055. private _updateButtons;
  45056. }
  45057. }
  45058. declare module BABYLON {
  45059. /**
  45060. * Class containing static functions to help procedurally build meshes
  45061. */
  45062. export class LinesBuilder {
  45063. /**
  45064. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45065. * * 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
  45066. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45067. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45068. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45069. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45070. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45071. * * 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
  45072. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45075. * @param name defines the name of the new line system
  45076. * @param options defines the options used to create the line system
  45077. * @param scene defines the hosting scene
  45078. * @returns a new line system mesh
  45079. */
  45080. static CreateLineSystem(name: string, options: {
  45081. lines: Vector3[][];
  45082. updatable?: boolean;
  45083. instance?: Nullable<LinesMesh>;
  45084. colors?: Nullable<Color4[][]>;
  45085. useVertexAlpha?: boolean;
  45086. }, scene: Nullable<Scene>): LinesMesh;
  45087. /**
  45088. * Creates a line mesh
  45089. * 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
  45090. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45091. * * The parameter `points` is an array successive Vector3
  45092. * * 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
  45093. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45094. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45095. * * When updating an instance, remember that only point positions can change, not the number of points
  45096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45098. * @param name defines the name of the new line system
  45099. * @param options defines the options used to create the line system
  45100. * @param scene defines the hosting scene
  45101. * @returns a new line mesh
  45102. */
  45103. static CreateLines(name: string, options: {
  45104. points: Vector3[];
  45105. updatable?: boolean;
  45106. instance?: Nullable<LinesMesh>;
  45107. colors?: Color4[];
  45108. useVertexAlpha?: boolean;
  45109. }, scene?: Nullable<Scene>): LinesMesh;
  45110. /**
  45111. * Creates a dashed line mesh
  45112. * * 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
  45113. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45114. * * The parameter `points` is an array successive Vector3
  45115. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45116. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45117. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45118. * * 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
  45119. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45120. * * When updating an instance, remember that only point positions can change, not the number of points
  45121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45122. * @param name defines the name of the mesh
  45123. * @param options defines the options used to create the mesh
  45124. * @param scene defines the hosting scene
  45125. * @returns the dashed line mesh
  45126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45127. */
  45128. static CreateDashedLines(name: string, options: {
  45129. points: Vector3[];
  45130. dashSize?: number;
  45131. gapSize?: number;
  45132. dashNb?: number;
  45133. updatable?: boolean;
  45134. instance?: LinesMesh;
  45135. useVertexAlpha?: boolean;
  45136. }, scene?: Nullable<Scene>): LinesMesh;
  45137. }
  45138. }
  45139. declare module BABYLON {
  45140. /**
  45141. * The options container for the teleportation module
  45142. */
  45143. export interface IWebXRTeleportationOptions {
  45144. /**
  45145. * if provided, this scene will be used to render meshes.
  45146. */
  45147. customUtilityLayerScene?: Scene;
  45148. /**
  45149. * Values to configure the default target mesh
  45150. */
  45151. defaultTargetMeshOptions?: {
  45152. /**
  45153. * Fill color of the teleportation area
  45154. */
  45155. teleportationFillColor?: string;
  45156. /**
  45157. * Border color for the teleportation area
  45158. */
  45159. teleportationBorderColor?: string;
  45160. /**
  45161. * Disable the mesh's animation sequence
  45162. */
  45163. disableAnimation?: boolean;
  45164. /**
  45165. * Disable lighting on the material or the ring and arrow
  45166. */
  45167. disableLighting?: boolean;
  45168. /**
  45169. * Override the default material of the torus and arrow
  45170. */
  45171. torusArrowMaterial?: Material;
  45172. };
  45173. /**
  45174. * A list of meshes to use as floor meshes.
  45175. * Meshes can be added and removed after initializing the feature using the
  45176. * addFloorMesh and removeFloorMesh functions
  45177. * If empty, rotation will still work
  45178. */
  45179. floorMeshes?: AbstractMesh[];
  45180. /**
  45181. * use this rendering group id for the meshes (optional)
  45182. */
  45183. renderingGroupId?: number;
  45184. /**
  45185. * Should teleportation move only to snap points
  45186. */
  45187. snapPointsOnly?: boolean;
  45188. /**
  45189. * An array of points to which the teleportation will snap to.
  45190. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45191. */
  45192. snapPositions?: Vector3[];
  45193. /**
  45194. * How close should the teleportation ray be in order to snap to position.
  45195. * Default to 0.8 units (meters)
  45196. */
  45197. snapToPositionRadius?: number;
  45198. /**
  45199. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45200. * If you want to support rotation, make sure your mesh has a direction indicator.
  45201. *
  45202. * When left untouched, the default mesh will be initialized.
  45203. */
  45204. teleportationTargetMesh?: AbstractMesh;
  45205. /**
  45206. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45207. */
  45208. timeToTeleport?: number;
  45209. /**
  45210. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45211. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45212. */
  45213. useMainComponentOnly?: boolean;
  45214. /**
  45215. * Should meshes created here be added to a utility layer or the main scene
  45216. */
  45217. useUtilityLayer?: boolean;
  45218. /**
  45219. * Babylon XR Input class for controller
  45220. */
  45221. xrInput: WebXRInput;
  45222. }
  45223. /**
  45224. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45225. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45226. * the input of the attached controllers.
  45227. */
  45228. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45229. private _options;
  45230. private _controllers;
  45231. private _currentTeleportationControllerId;
  45232. private _floorMeshes;
  45233. private _quadraticBezierCurve;
  45234. private _selectionFeature;
  45235. private _snapToPositions;
  45236. private _snappedToPoint;
  45237. private _teleportationRingMaterial?;
  45238. private _tmpRay;
  45239. private _tmpVector;
  45240. /**
  45241. * The module's name
  45242. */
  45243. static readonly Name: string;
  45244. /**
  45245. * The (Babylon) version of this module.
  45246. * This is an integer representing the implementation version.
  45247. * This number does not correspond to the webxr specs version
  45248. */
  45249. static readonly Version: number;
  45250. /**
  45251. * Is movement backwards enabled
  45252. */
  45253. backwardsMovementEnabled: boolean;
  45254. /**
  45255. * Distance to travel when moving backwards
  45256. */
  45257. backwardsTeleportationDistance: number;
  45258. /**
  45259. * The distance from the user to the inspection point in the direction of the controller
  45260. * A higher number will allow the user to move further
  45261. * defaults to 5 (meters, in xr units)
  45262. */
  45263. parabolicCheckRadius: number;
  45264. /**
  45265. * Should the module support parabolic ray on top of direct ray
  45266. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45267. * Very helpful when moving between floors / different heights
  45268. */
  45269. parabolicRayEnabled: boolean;
  45270. /**
  45271. * How much rotation should be applied when rotating right and left
  45272. */
  45273. rotationAngle: number;
  45274. /**
  45275. * Is rotation enabled when moving forward?
  45276. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45277. */
  45278. rotationEnabled: boolean;
  45279. /**
  45280. * constructs a new anchor system
  45281. * @param _xrSessionManager an instance of WebXRSessionManager
  45282. * @param _options configuration object for this feature
  45283. */
  45284. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45285. /**
  45286. * Get the snapPointsOnly flag
  45287. */
  45288. get snapPointsOnly(): boolean;
  45289. /**
  45290. * Sets the snapPointsOnly flag
  45291. * @param snapToPoints should teleportation be exclusively to snap points
  45292. */
  45293. set snapPointsOnly(snapToPoints: boolean);
  45294. /**
  45295. * Add a new mesh to the floor meshes array
  45296. * @param mesh the mesh to use as floor mesh
  45297. */
  45298. addFloorMesh(mesh: AbstractMesh): void;
  45299. /**
  45300. * Add a new snap-to point to fix teleportation to this position
  45301. * @param newSnapPoint The new Snap-To point
  45302. */
  45303. addSnapPoint(newSnapPoint: Vector3): void;
  45304. attach(): boolean;
  45305. detach(): boolean;
  45306. dispose(): void;
  45307. /**
  45308. * Remove a mesh from the floor meshes array
  45309. * @param mesh the mesh to remove
  45310. */
  45311. removeFloorMesh(mesh: AbstractMesh): void;
  45312. /**
  45313. * Remove a mesh from the floor meshes array using its name
  45314. * @param name the mesh name to remove
  45315. */
  45316. removeFloorMeshByName(name: string): void;
  45317. /**
  45318. * 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
  45319. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45320. * @returns was the point found and removed or not
  45321. */
  45322. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45323. /**
  45324. * This function sets a selection feature that will be disabled when
  45325. * the forward ray is shown and will be reattached when hidden.
  45326. * This is used to remove the selection rays when moving.
  45327. * @param selectionFeature the feature to disable when forward movement is enabled
  45328. */
  45329. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45330. protected _onXRFrame(_xrFrame: XRFrame): void;
  45331. private _attachController;
  45332. private _createDefaultTargetMesh;
  45333. private _detachController;
  45334. private _findClosestSnapPointWithRadius;
  45335. private _setTargetMeshPosition;
  45336. private _setTargetMeshVisibility;
  45337. private _showParabolicPath;
  45338. private _teleportForward;
  45339. }
  45340. }
  45341. declare module BABYLON {
  45342. /**
  45343. * Options for the default xr helper
  45344. */
  45345. export class WebXRDefaultExperienceOptions {
  45346. /**
  45347. * Enable or disable default UI to enter XR
  45348. */
  45349. disableDefaultUI?: boolean;
  45350. /**
  45351. * Should teleportation not initialize. defaults to false.
  45352. */
  45353. disableTeleportation?: boolean;
  45354. /**
  45355. * Floor meshes that will be used for teleport
  45356. */
  45357. floorMeshes?: Array<AbstractMesh>;
  45358. /**
  45359. * If set to true, the first frame will not be used to reset position
  45360. * The first frame is mainly used when copying transformation from the old camera
  45361. * Mainly used in AR
  45362. */
  45363. ignoreNativeCameraTransformation?: boolean;
  45364. /**
  45365. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45366. */
  45367. inputOptions?: IWebXRInputOptions;
  45368. /**
  45369. * optional configuration for the output canvas
  45370. */
  45371. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45372. /**
  45373. * optional UI options. This can be used among other to change session mode and reference space type
  45374. */
  45375. uiOptions?: WebXREnterExitUIOptions;
  45376. /**
  45377. * When loading teleportation and pointer select, use stable versions instead of latest.
  45378. */
  45379. useStablePlugins?: boolean;
  45380. }
  45381. /**
  45382. * Default experience which provides a similar setup to the previous webVRExperience
  45383. */
  45384. export class WebXRDefaultExperience {
  45385. /**
  45386. * Base experience
  45387. */
  45388. baseExperience: WebXRExperienceHelper;
  45389. /**
  45390. * Enables ui for entering/exiting xr
  45391. */
  45392. enterExitUI: WebXREnterExitUI;
  45393. /**
  45394. * Input experience extension
  45395. */
  45396. input: WebXRInput;
  45397. /**
  45398. * Enables laser pointer and selection
  45399. */
  45400. pointerSelection: WebXRControllerPointerSelection;
  45401. /**
  45402. * Default target xr should render to
  45403. */
  45404. renderTarget: WebXRRenderTarget;
  45405. /**
  45406. * Enables teleportation
  45407. */
  45408. teleportation: WebXRMotionControllerTeleportation;
  45409. private constructor();
  45410. /**
  45411. * Creates the default xr experience
  45412. * @param scene scene
  45413. * @param options options for basic configuration
  45414. * @returns resulting WebXRDefaultExperience
  45415. */
  45416. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45417. /**
  45418. * DIsposes of the experience helper
  45419. */
  45420. dispose(): void;
  45421. }
  45422. }
  45423. declare module BABYLON {
  45424. /**
  45425. * Options to modify the vr teleportation behavior.
  45426. */
  45427. export interface VRTeleportationOptions {
  45428. /**
  45429. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45430. */
  45431. floorMeshName?: string;
  45432. /**
  45433. * A list of meshes to be used as the teleportation floor. (default: empty)
  45434. */
  45435. floorMeshes?: Mesh[];
  45436. /**
  45437. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45438. */
  45439. teleportationMode?: number;
  45440. /**
  45441. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45442. */
  45443. teleportationTime?: number;
  45444. /**
  45445. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45446. */
  45447. teleportationSpeed?: number;
  45448. /**
  45449. * The easing function used in the animation or null for Linear. (default CircleEase)
  45450. */
  45451. easingFunction?: EasingFunction;
  45452. }
  45453. /**
  45454. * Options to modify the vr experience helper's behavior.
  45455. */
  45456. export interface VRExperienceHelperOptions extends WebVROptions {
  45457. /**
  45458. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45459. */
  45460. createDeviceOrientationCamera?: boolean;
  45461. /**
  45462. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45463. */
  45464. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45465. /**
  45466. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45467. */
  45468. laserToggle?: boolean;
  45469. /**
  45470. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45471. */
  45472. floorMeshes?: Mesh[];
  45473. /**
  45474. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45475. */
  45476. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45477. /**
  45478. * Defines if WebXR should be used instead of WebVR (if available)
  45479. */
  45480. useXR?: boolean;
  45481. }
  45482. /**
  45483. * Event containing information after VR has been entered
  45484. */
  45485. export class OnAfterEnteringVRObservableEvent {
  45486. /**
  45487. * If entering vr was successful
  45488. */
  45489. success: boolean;
  45490. }
  45491. /**
  45492. * Helps to quickly add VR support to an existing scene.
  45493. * See http://doc.babylonjs.com/how_to/webvr_helper
  45494. */
  45495. export class VRExperienceHelper {
  45496. /** Options to modify the vr experience helper's behavior. */
  45497. webVROptions: VRExperienceHelperOptions;
  45498. private _scene;
  45499. private _position;
  45500. private _btnVR;
  45501. private _btnVRDisplayed;
  45502. private _webVRsupported;
  45503. private _webVRready;
  45504. private _webVRrequesting;
  45505. private _webVRpresenting;
  45506. private _hasEnteredVR;
  45507. private _fullscreenVRpresenting;
  45508. private _inputElement;
  45509. private _webVRCamera;
  45510. private _vrDeviceOrientationCamera;
  45511. private _deviceOrientationCamera;
  45512. private _existingCamera;
  45513. private _onKeyDown;
  45514. private _onVrDisplayPresentChange;
  45515. private _onVRDisplayChanged;
  45516. private _onVRRequestPresentStart;
  45517. private _onVRRequestPresentComplete;
  45518. /**
  45519. * 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)
  45520. */
  45521. enableGazeEvenWhenNoPointerLock: boolean;
  45522. /**
  45523. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45524. */
  45525. exitVROnDoubleTap: boolean;
  45526. /**
  45527. * Observable raised right before entering VR.
  45528. */
  45529. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45530. /**
  45531. * Observable raised when entering VR has completed.
  45532. */
  45533. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45534. /**
  45535. * Observable raised when exiting VR.
  45536. */
  45537. onExitingVRObservable: Observable<VRExperienceHelper>;
  45538. /**
  45539. * Observable raised when controller mesh is loaded.
  45540. */
  45541. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45542. /** Return this.onEnteringVRObservable
  45543. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45544. */
  45545. get onEnteringVR(): Observable<VRExperienceHelper>;
  45546. /** Return this.onExitingVRObservable
  45547. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45548. */
  45549. get onExitingVR(): Observable<VRExperienceHelper>;
  45550. /** Return this.onControllerMeshLoadedObservable
  45551. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45552. */
  45553. get onControllerMeshLoaded(): Observable<WebVRController>;
  45554. private _rayLength;
  45555. private _useCustomVRButton;
  45556. private _teleportationRequested;
  45557. private _teleportActive;
  45558. private _floorMeshName;
  45559. private _floorMeshesCollection;
  45560. private _teleportationMode;
  45561. private _teleportationTime;
  45562. private _teleportationSpeed;
  45563. private _teleportationEasing;
  45564. private _rotationAllowed;
  45565. private _teleportBackwardsVector;
  45566. private _teleportationTarget;
  45567. private _isDefaultTeleportationTarget;
  45568. private _postProcessMove;
  45569. private _teleportationFillColor;
  45570. private _teleportationBorderColor;
  45571. private _rotationAngle;
  45572. private _haloCenter;
  45573. private _cameraGazer;
  45574. private _padSensibilityUp;
  45575. private _padSensibilityDown;
  45576. private _leftController;
  45577. private _rightController;
  45578. private _gazeColor;
  45579. private _laserColor;
  45580. private _pickedLaserColor;
  45581. private _pickedGazeColor;
  45582. /**
  45583. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45584. */
  45585. onNewMeshSelected: Observable<AbstractMesh>;
  45586. /**
  45587. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45588. * This observable will provide the mesh and the controller used to select the mesh
  45589. */
  45590. onMeshSelectedWithController: Observable<{
  45591. mesh: AbstractMesh;
  45592. controller: WebVRController;
  45593. }>;
  45594. /**
  45595. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45596. */
  45597. onNewMeshPicked: Observable<PickingInfo>;
  45598. private _circleEase;
  45599. /**
  45600. * Observable raised before camera teleportation
  45601. */
  45602. onBeforeCameraTeleport: Observable<Vector3>;
  45603. /**
  45604. * Observable raised after camera teleportation
  45605. */
  45606. onAfterCameraTeleport: Observable<Vector3>;
  45607. /**
  45608. * Observable raised when current selected mesh gets unselected
  45609. */
  45610. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45611. private _raySelectionPredicate;
  45612. /**
  45613. * To be optionaly changed by user to define custom ray selection
  45614. */
  45615. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45616. /**
  45617. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45618. */
  45619. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45620. /**
  45621. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45622. */
  45623. teleportationEnabled: boolean;
  45624. private _defaultHeight;
  45625. private _teleportationInitialized;
  45626. private _interactionsEnabled;
  45627. private _interactionsRequested;
  45628. private _displayGaze;
  45629. private _displayLaserPointer;
  45630. /**
  45631. * The mesh used to display where the user is going to teleport.
  45632. */
  45633. get teleportationTarget(): Mesh;
  45634. /**
  45635. * Sets the mesh to be used to display where the user is going to teleport.
  45636. */
  45637. set teleportationTarget(value: Mesh);
  45638. /**
  45639. * 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
  45640. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45641. * See http://doc.babylonjs.com/resources/baking_transformations
  45642. */
  45643. get gazeTrackerMesh(): Mesh;
  45644. set gazeTrackerMesh(value: Mesh);
  45645. /**
  45646. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45647. */
  45648. updateGazeTrackerScale: boolean;
  45649. /**
  45650. * If the gaze trackers color should be updated when selecting meshes
  45651. */
  45652. updateGazeTrackerColor: boolean;
  45653. /**
  45654. * If the controller laser color should be updated when selecting meshes
  45655. */
  45656. updateControllerLaserColor: boolean;
  45657. /**
  45658. * The gaze tracking mesh corresponding to the left controller
  45659. */
  45660. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45661. /**
  45662. * The gaze tracking mesh corresponding to the right controller
  45663. */
  45664. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45665. /**
  45666. * If the ray of the gaze should be displayed.
  45667. */
  45668. get displayGaze(): boolean;
  45669. /**
  45670. * Sets if the ray of the gaze should be displayed.
  45671. */
  45672. set displayGaze(value: boolean);
  45673. /**
  45674. * If the ray of the LaserPointer should be displayed.
  45675. */
  45676. get displayLaserPointer(): boolean;
  45677. /**
  45678. * Sets if the ray of the LaserPointer should be displayed.
  45679. */
  45680. set displayLaserPointer(value: boolean);
  45681. /**
  45682. * The deviceOrientationCamera used as the camera when not in VR.
  45683. */
  45684. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45685. /**
  45686. * Based on the current WebVR support, returns the current VR camera used.
  45687. */
  45688. get currentVRCamera(): Nullable<Camera>;
  45689. /**
  45690. * The webVRCamera which is used when in VR.
  45691. */
  45692. get webVRCamera(): WebVRFreeCamera;
  45693. /**
  45694. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45695. */
  45696. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45697. /**
  45698. * The html button that is used to trigger entering into VR.
  45699. */
  45700. get vrButton(): Nullable<HTMLButtonElement>;
  45701. private get _teleportationRequestInitiated();
  45702. /**
  45703. * Defines whether or not Pointer lock should be requested when switching to
  45704. * full screen.
  45705. */
  45706. requestPointerLockOnFullScreen: boolean;
  45707. /**
  45708. * If asking to force XR, this will be populated with the default xr experience
  45709. */
  45710. xr: WebXRDefaultExperience;
  45711. /**
  45712. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45713. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45714. */
  45715. xrTestDone: boolean;
  45716. /**
  45717. * Instantiates a VRExperienceHelper.
  45718. * Helps to quickly add VR support to an existing scene.
  45719. * @param scene The scene the VRExperienceHelper belongs to.
  45720. * @param webVROptions Options to modify the vr experience helper's behavior.
  45721. */
  45722. constructor(scene: Scene,
  45723. /** Options to modify the vr experience helper's behavior. */
  45724. webVROptions?: VRExperienceHelperOptions);
  45725. private completeVRInit;
  45726. private _onDefaultMeshLoaded;
  45727. private _onResize;
  45728. private _onFullscreenChange;
  45729. /**
  45730. * Gets a value indicating if we are currently in VR mode.
  45731. */
  45732. get isInVRMode(): boolean;
  45733. private onVrDisplayPresentChange;
  45734. private onVRDisplayChanged;
  45735. private moveButtonToBottomRight;
  45736. private displayVRButton;
  45737. private updateButtonVisibility;
  45738. private _cachedAngularSensibility;
  45739. /**
  45740. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45741. * Otherwise, will use the fullscreen API.
  45742. */
  45743. enterVR(): void;
  45744. /**
  45745. * Attempt to exit VR, or fullscreen.
  45746. */
  45747. exitVR(): void;
  45748. /**
  45749. * The position of the vr experience helper.
  45750. */
  45751. get position(): Vector3;
  45752. /**
  45753. * Sets the position of the vr experience helper.
  45754. */
  45755. set position(value: Vector3);
  45756. /**
  45757. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45758. */
  45759. enableInteractions(): void;
  45760. private get _noControllerIsActive();
  45761. private beforeRender;
  45762. private _isTeleportationFloor;
  45763. /**
  45764. * Adds a floor mesh to be used for teleportation.
  45765. * @param floorMesh the mesh to be used for teleportation.
  45766. */
  45767. addFloorMesh(floorMesh: Mesh): void;
  45768. /**
  45769. * Removes a floor mesh from being used for teleportation.
  45770. * @param floorMesh the mesh to be removed.
  45771. */
  45772. removeFloorMesh(floorMesh: Mesh): void;
  45773. /**
  45774. * Enables interactions and teleportation using the VR controllers and gaze.
  45775. * @param vrTeleportationOptions options to modify teleportation behavior.
  45776. */
  45777. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45778. private _onNewGamepadConnected;
  45779. private _tryEnableInteractionOnController;
  45780. private _onNewGamepadDisconnected;
  45781. private _enableInteractionOnController;
  45782. private _checkTeleportWithRay;
  45783. private _checkRotate;
  45784. private _checkTeleportBackwards;
  45785. private _enableTeleportationOnController;
  45786. private _createTeleportationCircles;
  45787. private _displayTeleportationTarget;
  45788. private _hideTeleportationTarget;
  45789. private _rotateCamera;
  45790. private _moveTeleportationSelectorTo;
  45791. private _workingVector;
  45792. private _workingQuaternion;
  45793. private _workingMatrix;
  45794. /**
  45795. * Time Constant Teleportation Mode
  45796. */
  45797. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45798. /**
  45799. * Speed Constant Teleportation Mode
  45800. */
  45801. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45802. /**
  45803. * Teleports the users feet to the desired location
  45804. * @param location The location where the user's feet should be placed
  45805. */
  45806. teleportCamera(location: Vector3): void;
  45807. private _convertNormalToDirectionOfRay;
  45808. private _castRayAndSelectObject;
  45809. private _notifySelectedMeshUnselected;
  45810. /**
  45811. * Permanently set new colors for the laser pointer
  45812. * @param color the new laser color
  45813. * @param pickedColor the new laser color when picked mesh detected
  45814. */
  45815. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45816. /**
  45817. * Set lighting enabled / disabled on the laser pointer of both controllers
  45818. * @param enabled should the lighting be enabled on the laser pointer
  45819. */
  45820. setLaserLightingState(enabled?: boolean): void;
  45821. /**
  45822. * Permanently set new colors for the gaze pointer
  45823. * @param color the new gaze color
  45824. * @param pickedColor the new gaze color when picked mesh detected
  45825. */
  45826. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45827. /**
  45828. * Sets the color of the laser ray from the vr controllers.
  45829. * @param color new color for the ray.
  45830. */
  45831. changeLaserColor(color: Color3): void;
  45832. /**
  45833. * Sets the color of the ray from the vr headsets gaze.
  45834. * @param color new color for the ray.
  45835. */
  45836. changeGazeColor(color: Color3): void;
  45837. /**
  45838. * Exits VR and disposes of the vr experience helper
  45839. */
  45840. dispose(): void;
  45841. /**
  45842. * Gets the name of the VRExperienceHelper class
  45843. * @returns "VRExperienceHelper"
  45844. */
  45845. getClassName(): string;
  45846. }
  45847. }
  45848. declare module BABYLON {
  45849. /**
  45850. * Contains an array of blocks representing the octree
  45851. */
  45852. export interface IOctreeContainer<T> {
  45853. /**
  45854. * Blocks within the octree
  45855. */
  45856. blocks: Array<OctreeBlock<T>>;
  45857. }
  45858. /**
  45859. * Class used to store a cell in an octree
  45860. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45861. */
  45862. export class OctreeBlock<T> {
  45863. /**
  45864. * Gets the content of the current block
  45865. */
  45866. entries: T[];
  45867. /**
  45868. * Gets the list of block children
  45869. */
  45870. blocks: Array<OctreeBlock<T>>;
  45871. private _depth;
  45872. private _maxDepth;
  45873. private _capacity;
  45874. private _minPoint;
  45875. private _maxPoint;
  45876. private _boundingVectors;
  45877. private _creationFunc;
  45878. /**
  45879. * Creates a new block
  45880. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45881. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45882. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45883. * @param depth defines the current depth of this block in the octree
  45884. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45885. * @param creationFunc defines a callback to call when an element is added to the block
  45886. */
  45887. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45888. /**
  45889. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45890. */
  45891. get capacity(): number;
  45892. /**
  45893. * Gets the minimum vector (in world space) of the block's bounding box
  45894. */
  45895. get minPoint(): Vector3;
  45896. /**
  45897. * Gets the maximum vector (in world space) of the block's bounding box
  45898. */
  45899. get maxPoint(): Vector3;
  45900. /**
  45901. * Add a new element to this block
  45902. * @param entry defines the element to add
  45903. */
  45904. addEntry(entry: T): void;
  45905. /**
  45906. * Remove an element from this block
  45907. * @param entry defines the element to remove
  45908. */
  45909. removeEntry(entry: T): void;
  45910. /**
  45911. * Add an array of elements to this block
  45912. * @param entries defines the array of elements to add
  45913. */
  45914. addEntries(entries: T[]): void;
  45915. /**
  45916. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45917. * @param frustumPlanes defines the frustum planes to test
  45918. * @param selection defines the array to store current content if selection is positive
  45919. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45920. */
  45921. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45922. /**
  45923. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45924. * @param sphereCenter defines the bounding sphere center
  45925. * @param sphereRadius defines the bounding sphere radius
  45926. * @param selection defines the array to store current content if selection is positive
  45927. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45928. */
  45929. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45930. /**
  45931. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45932. * @param ray defines the ray to test with
  45933. * @param selection defines the array to store current content if selection is positive
  45934. */
  45935. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45936. /**
  45937. * Subdivide the content into child blocks (this block will then be empty)
  45938. */
  45939. createInnerBlocks(): void;
  45940. /**
  45941. * @hidden
  45942. */
  45943. 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;
  45944. }
  45945. }
  45946. declare module BABYLON {
  45947. /**
  45948. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45949. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45950. */
  45951. export class Octree<T> {
  45952. /** 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.) */
  45953. maxDepth: number;
  45954. /**
  45955. * Blocks within the octree containing objects
  45956. */
  45957. blocks: Array<OctreeBlock<T>>;
  45958. /**
  45959. * Content stored in the octree
  45960. */
  45961. dynamicContent: T[];
  45962. private _maxBlockCapacity;
  45963. private _selectionContent;
  45964. private _creationFunc;
  45965. /**
  45966. * Creates a octree
  45967. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45968. * @param creationFunc function to be used to instatiate the octree
  45969. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45970. * @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.)
  45971. */
  45972. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45973. /** 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.) */
  45974. maxDepth?: number);
  45975. /**
  45976. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45977. * @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);
  45978. * @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);
  45979. * @param entries meshes to be added to the octree blocks
  45980. */
  45981. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45982. /**
  45983. * Adds a mesh to the octree
  45984. * @param entry Mesh to add to the octree
  45985. */
  45986. addMesh(entry: T): void;
  45987. /**
  45988. * Remove an element from the octree
  45989. * @param entry defines the element to remove
  45990. */
  45991. removeMesh(entry: T): void;
  45992. /**
  45993. * Selects an array of meshes within the frustum
  45994. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45995. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45996. * @returns array of meshes within the frustum
  45997. */
  45998. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45999. /**
  46000. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46001. * @param sphereCenter defines the bounding sphere center
  46002. * @param sphereRadius defines the bounding sphere radius
  46003. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46004. * @returns an array of objects that intersect the sphere
  46005. */
  46006. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46007. /**
  46008. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46009. * @param ray defines the ray to test with
  46010. * @returns array of intersected objects
  46011. */
  46012. intersectsRay(ray: Ray): SmartArray<T>;
  46013. /**
  46014. * Adds a mesh into the octree block if it intersects the block
  46015. */
  46016. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46017. /**
  46018. * Adds a submesh into the octree block if it intersects the block
  46019. */
  46020. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46021. }
  46022. }
  46023. declare module BABYLON {
  46024. interface Scene {
  46025. /**
  46026. * @hidden
  46027. * Backing Filed
  46028. */
  46029. _selectionOctree: Octree<AbstractMesh>;
  46030. /**
  46031. * Gets the octree used to boost mesh selection (picking)
  46032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46033. */
  46034. selectionOctree: Octree<AbstractMesh>;
  46035. /**
  46036. * Creates or updates the octree used to boost selection (picking)
  46037. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46038. * @param maxCapacity defines the maximum capacity per leaf
  46039. * @param maxDepth defines the maximum depth of the octree
  46040. * @returns an octree of AbstractMesh
  46041. */
  46042. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46043. }
  46044. interface AbstractMesh {
  46045. /**
  46046. * @hidden
  46047. * Backing Field
  46048. */
  46049. _submeshesOctree: Octree<SubMesh>;
  46050. /**
  46051. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46052. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46053. * @param maxCapacity defines the maximum size of each block (64 by default)
  46054. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46055. * @returns the new octree
  46056. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46057. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46058. */
  46059. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46060. }
  46061. /**
  46062. * Defines the octree scene component responsible to manage any octrees
  46063. * in a given scene.
  46064. */
  46065. export class OctreeSceneComponent {
  46066. /**
  46067. * The component name help to identify the component in the list of scene components.
  46068. */
  46069. readonly name: string;
  46070. /**
  46071. * The scene the component belongs to.
  46072. */
  46073. scene: Scene;
  46074. /**
  46075. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46076. */
  46077. readonly checksIsEnabled: boolean;
  46078. /**
  46079. * Creates a new instance of the component for the given scene
  46080. * @param scene Defines the scene to register the component in
  46081. */
  46082. constructor(scene: Scene);
  46083. /**
  46084. * Registers the component in a given scene
  46085. */
  46086. register(): void;
  46087. /**
  46088. * Return the list of active meshes
  46089. * @returns the list of active meshes
  46090. */
  46091. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46092. /**
  46093. * Return the list of active sub meshes
  46094. * @param mesh The mesh to get the candidates sub meshes from
  46095. * @returns the list of active sub meshes
  46096. */
  46097. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46098. private _tempRay;
  46099. /**
  46100. * Return the list of sub meshes intersecting with a given local ray
  46101. * @param mesh defines the mesh to find the submesh for
  46102. * @param localRay defines the ray in local space
  46103. * @returns the list of intersecting sub meshes
  46104. */
  46105. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46106. /**
  46107. * Return the list of sub meshes colliding with a collider
  46108. * @param mesh defines the mesh to find the submesh for
  46109. * @param collider defines the collider to evaluate the collision against
  46110. * @returns the list of colliding sub meshes
  46111. */
  46112. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46113. /**
  46114. * Rebuilds the elements related to this component in case of
  46115. * context lost for instance.
  46116. */
  46117. rebuild(): void;
  46118. /**
  46119. * Disposes the component and the associated ressources.
  46120. */
  46121. dispose(): void;
  46122. }
  46123. }
  46124. declare module BABYLON {
  46125. /**
  46126. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46127. */
  46128. export class Gizmo implements IDisposable {
  46129. /** The utility layer the gizmo will be added to */
  46130. gizmoLayer: UtilityLayerRenderer;
  46131. /**
  46132. * The root mesh of the gizmo
  46133. */
  46134. _rootMesh: Mesh;
  46135. private _attachedMesh;
  46136. /**
  46137. * Ratio for the scale of the gizmo (Default: 1)
  46138. */
  46139. scaleRatio: number;
  46140. /**
  46141. * If a custom mesh has been set (Default: false)
  46142. */
  46143. protected _customMeshSet: boolean;
  46144. /**
  46145. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46146. * * When set, interactions will be enabled
  46147. */
  46148. get attachedMesh(): Nullable<AbstractMesh>;
  46149. set attachedMesh(value: Nullable<AbstractMesh>);
  46150. /**
  46151. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46152. * @param mesh The mesh to replace the default mesh of the gizmo
  46153. */
  46154. setCustomMesh(mesh: Mesh): void;
  46155. /**
  46156. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46157. */
  46158. updateGizmoRotationToMatchAttachedMesh: boolean;
  46159. /**
  46160. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46161. */
  46162. updateGizmoPositionToMatchAttachedMesh: boolean;
  46163. /**
  46164. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46165. */
  46166. updateScale: boolean;
  46167. protected _interactionsEnabled: boolean;
  46168. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46169. private _beforeRenderObserver;
  46170. private _tempVector;
  46171. /**
  46172. * Creates a gizmo
  46173. * @param gizmoLayer The utility layer the gizmo will be added to
  46174. */
  46175. constructor(
  46176. /** The utility layer the gizmo will be added to */
  46177. gizmoLayer?: UtilityLayerRenderer);
  46178. /**
  46179. * Updates the gizmo to match the attached mesh's position/rotation
  46180. */
  46181. protected _update(): void;
  46182. /**
  46183. * Disposes of the gizmo
  46184. */
  46185. dispose(): void;
  46186. }
  46187. }
  46188. declare module BABYLON {
  46189. /**
  46190. * Single plane drag gizmo
  46191. */
  46192. export class PlaneDragGizmo extends Gizmo {
  46193. /**
  46194. * Drag behavior responsible for the gizmos dragging interactions
  46195. */
  46196. dragBehavior: PointerDragBehavior;
  46197. private _pointerObserver;
  46198. /**
  46199. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46200. */
  46201. snapDistance: number;
  46202. /**
  46203. * Event that fires each time the gizmo snaps to a new location.
  46204. * * snapDistance is the the change in distance
  46205. */
  46206. onSnapObservable: Observable<{
  46207. snapDistance: number;
  46208. }>;
  46209. private _plane;
  46210. private _coloredMaterial;
  46211. private _hoverMaterial;
  46212. private _isEnabled;
  46213. private _parent;
  46214. /** @hidden */
  46215. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46216. /** @hidden */
  46217. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46218. /**
  46219. * Creates a PlaneDragGizmo
  46220. * @param gizmoLayer The utility layer the gizmo will be added to
  46221. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46222. * @param color The color of the gizmo
  46223. */
  46224. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46225. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46226. /**
  46227. * If the gizmo is enabled
  46228. */
  46229. set isEnabled(value: boolean);
  46230. get isEnabled(): boolean;
  46231. /**
  46232. * Disposes of the gizmo
  46233. */
  46234. dispose(): void;
  46235. }
  46236. }
  46237. declare module BABYLON {
  46238. /**
  46239. * Gizmo that enables dragging a mesh along 3 axis
  46240. */
  46241. export class PositionGizmo extends Gizmo {
  46242. /**
  46243. * Internal gizmo used for interactions on the x axis
  46244. */
  46245. xGizmo: AxisDragGizmo;
  46246. /**
  46247. * Internal gizmo used for interactions on the y axis
  46248. */
  46249. yGizmo: AxisDragGizmo;
  46250. /**
  46251. * Internal gizmo used for interactions on the z axis
  46252. */
  46253. zGizmo: AxisDragGizmo;
  46254. /**
  46255. * Internal gizmo used for interactions on the yz plane
  46256. */
  46257. xPlaneGizmo: PlaneDragGizmo;
  46258. /**
  46259. * Internal gizmo used for interactions on the xz plane
  46260. */
  46261. yPlaneGizmo: PlaneDragGizmo;
  46262. /**
  46263. * Internal gizmo used for interactions on the xy plane
  46264. */
  46265. zPlaneGizmo: PlaneDragGizmo;
  46266. /**
  46267. * private variables
  46268. */
  46269. private _meshAttached;
  46270. private _updateGizmoRotationToMatchAttachedMesh;
  46271. private _snapDistance;
  46272. private _scaleRatio;
  46273. /** Fires an event when any of it's sub gizmos are dragged */
  46274. onDragStartObservable: Observable<unknown>;
  46275. /** Fires an event when any of it's sub gizmos are released from dragging */
  46276. onDragEndObservable: Observable<unknown>;
  46277. /**
  46278. * If set to true, planar drag is enabled
  46279. */
  46280. private _planarGizmoEnabled;
  46281. get attachedMesh(): Nullable<AbstractMesh>;
  46282. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46283. /**
  46284. * Creates a PositionGizmo
  46285. * @param gizmoLayer The utility layer the gizmo will be added to
  46286. */
  46287. constructor(gizmoLayer?: UtilityLayerRenderer);
  46288. /**
  46289. * If the planar drag gizmo is enabled
  46290. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46291. */
  46292. set planarGizmoEnabled(value: boolean);
  46293. get planarGizmoEnabled(): boolean;
  46294. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46295. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46296. /**
  46297. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46298. */
  46299. set snapDistance(value: number);
  46300. get snapDistance(): number;
  46301. /**
  46302. * Ratio for the scale of the gizmo (Default: 1)
  46303. */
  46304. set scaleRatio(value: number);
  46305. get scaleRatio(): number;
  46306. /**
  46307. * Disposes of the gizmo
  46308. */
  46309. dispose(): void;
  46310. /**
  46311. * CustomMeshes are not supported by this gizmo
  46312. * @param mesh The mesh to replace the default mesh of the gizmo
  46313. */
  46314. setCustomMesh(mesh: Mesh): void;
  46315. }
  46316. }
  46317. declare module BABYLON {
  46318. /**
  46319. * Single axis drag gizmo
  46320. */
  46321. export class AxisDragGizmo extends Gizmo {
  46322. /**
  46323. * Drag behavior responsible for the gizmos dragging interactions
  46324. */
  46325. dragBehavior: PointerDragBehavior;
  46326. private _pointerObserver;
  46327. /**
  46328. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46329. */
  46330. snapDistance: number;
  46331. /**
  46332. * Event that fires each time the gizmo snaps to a new location.
  46333. * * snapDistance is the the change in distance
  46334. */
  46335. onSnapObservable: Observable<{
  46336. snapDistance: number;
  46337. }>;
  46338. private _isEnabled;
  46339. private _parent;
  46340. private _arrow;
  46341. private _coloredMaterial;
  46342. private _hoverMaterial;
  46343. /** @hidden */
  46344. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46345. /** @hidden */
  46346. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46347. /**
  46348. * Creates an AxisDragGizmo
  46349. * @param gizmoLayer The utility layer the gizmo will be added to
  46350. * @param dragAxis The axis which the gizmo will be able to drag on
  46351. * @param color The color of the gizmo
  46352. */
  46353. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46354. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46355. /**
  46356. * If the gizmo is enabled
  46357. */
  46358. set isEnabled(value: boolean);
  46359. get isEnabled(): boolean;
  46360. /**
  46361. * Disposes of the gizmo
  46362. */
  46363. dispose(): void;
  46364. }
  46365. }
  46366. declare module BABYLON.Debug {
  46367. /**
  46368. * The Axes viewer will show 3 axes in a specific point in space
  46369. */
  46370. export class AxesViewer {
  46371. private _xAxis;
  46372. private _yAxis;
  46373. private _zAxis;
  46374. private _scaleLinesFactor;
  46375. private _instanced;
  46376. /**
  46377. * Gets the hosting scene
  46378. */
  46379. scene: Scene;
  46380. /**
  46381. * Gets or sets a number used to scale line length
  46382. */
  46383. scaleLines: number;
  46384. /** Gets the node hierarchy used to render x-axis */
  46385. get xAxis(): TransformNode;
  46386. /** Gets the node hierarchy used to render y-axis */
  46387. get yAxis(): TransformNode;
  46388. /** Gets the node hierarchy used to render z-axis */
  46389. get zAxis(): TransformNode;
  46390. /**
  46391. * Creates a new AxesViewer
  46392. * @param scene defines the hosting scene
  46393. * @param scaleLines defines a number used to scale line length (1 by default)
  46394. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46395. * @param xAxis defines the node hierarchy used to render the x-axis
  46396. * @param yAxis defines the node hierarchy used to render the y-axis
  46397. * @param zAxis defines the node hierarchy used to render the z-axis
  46398. */
  46399. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46400. /**
  46401. * Force the viewer to update
  46402. * @param position defines the position of the viewer
  46403. * @param xaxis defines the x axis of the viewer
  46404. * @param yaxis defines the y axis of the viewer
  46405. * @param zaxis defines the z axis of the viewer
  46406. */
  46407. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46408. /**
  46409. * Creates an instance of this axes viewer.
  46410. * @returns a new axes viewer with instanced meshes
  46411. */
  46412. createInstance(): AxesViewer;
  46413. /** Releases resources */
  46414. dispose(): void;
  46415. private static _SetRenderingGroupId;
  46416. }
  46417. }
  46418. declare module BABYLON.Debug {
  46419. /**
  46420. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46421. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46422. */
  46423. export class BoneAxesViewer extends AxesViewer {
  46424. /**
  46425. * Gets or sets the target mesh where to display the axes viewer
  46426. */
  46427. mesh: Nullable<Mesh>;
  46428. /**
  46429. * Gets or sets the target bone where to display the axes viewer
  46430. */
  46431. bone: Nullable<Bone>;
  46432. /** Gets current position */
  46433. pos: Vector3;
  46434. /** Gets direction of X axis */
  46435. xaxis: Vector3;
  46436. /** Gets direction of Y axis */
  46437. yaxis: Vector3;
  46438. /** Gets direction of Z axis */
  46439. zaxis: Vector3;
  46440. /**
  46441. * Creates a new BoneAxesViewer
  46442. * @param scene defines the hosting scene
  46443. * @param bone defines the target bone
  46444. * @param mesh defines the target mesh
  46445. * @param scaleLines defines a scaling factor for line length (1 by default)
  46446. */
  46447. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46448. /**
  46449. * Force the viewer to update
  46450. */
  46451. update(): void;
  46452. /** Releases resources */
  46453. dispose(): void;
  46454. }
  46455. }
  46456. declare module BABYLON {
  46457. /**
  46458. * Interface used to define scene explorer extensibility option
  46459. */
  46460. export interface IExplorerExtensibilityOption {
  46461. /**
  46462. * Define the option label
  46463. */
  46464. label: string;
  46465. /**
  46466. * Defines the action to execute on click
  46467. */
  46468. action: (entity: any) => void;
  46469. }
  46470. /**
  46471. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46472. */
  46473. export interface IExplorerExtensibilityGroup {
  46474. /**
  46475. * Defines a predicate to test if a given type mut be extended
  46476. */
  46477. predicate: (entity: any) => boolean;
  46478. /**
  46479. * Gets the list of options added to a type
  46480. */
  46481. entries: IExplorerExtensibilityOption[];
  46482. }
  46483. /**
  46484. * Interface used to define the options to use to create the Inspector
  46485. */
  46486. export interface IInspectorOptions {
  46487. /**
  46488. * Display in overlay mode (default: false)
  46489. */
  46490. overlay?: boolean;
  46491. /**
  46492. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46493. */
  46494. globalRoot?: HTMLElement;
  46495. /**
  46496. * Display the Scene explorer
  46497. */
  46498. showExplorer?: boolean;
  46499. /**
  46500. * Display the property inspector
  46501. */
  46502. showInspector?: boolean;
  46503. /**
  46504. * Display in embed mode (both panes on the right)
  46505. */
  46506. embedMode?: boolean;
  46507. /**
  46508. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46509. */
  46510. handleResize?: boolean;
  46511. /**
  46512. * Allow the panes to popup (default: true)
  46513. */
  46514. enablePopup?: boolean;
  46515. /**
  46516. * Allow the panes to be closed by users (default: true)
  46517. */
  46518. enableClose?: boolean;
  46519. /**
  46520. * Optional list of extensibility entries
  46521. */
  46522. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46523. /**
  46524. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46525. */
  46526. inspectorURL?: string;
  46527. /**
  46528. * Optional initial tab (default to DebugLayerTab.Properties)
  46529. */
  46530. initialTab?: DebugLayerTab;
  46531. }
  46532. interface Scene {
  46533. /**
  46534. * @hidden
  46535. * Backing field
  46536. */
  46537. _debugLayer: DebugLayer;
  46538. /**
  46539. * Gets the debug layer (aka Inspector) associated with the scene
  46540. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46541. */
  46542. debugLayer: DebugLayer;
  46543. }
  46544. /**
  46545. * Enum of inspector action tab
  46546. */
  46547. export enum DebugLayerTab {
  46548. /**
  46549. * Properties tag (default)
  46550. */
  46551. Properties = 0,
  46552. /**
  46553. * Debug tab
  46554. */
  46555. Debug = 1,
  46556. /**
  46557. * Statistics tab
  46558. */
  46559. Statistics = 2,
  46560. /**
  46561. * Tools tab
  46562. */
  46563. Tools = 3,
  46564. /**
  46565. * Settings tab
  46566. */
  46567. Settings = 4
  46568. }
  46569. /**
  46570. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46571. * what is happening in your scene
  46572. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46573. */
  46574. export class DebugLayer {
  46575. /**
  46576. * Define the url to get the inspector script from.
  46577. * By default it uses the babylonjs CDN.
  46578. * @ignoreNaming
  46579. */
  46580. static InspectorURL: string;
  46581. private _scene;
  46582. private BJSINSPECTOR;
  46583. private _onPropertyChangedObservable?;
  46584. /**
  46585. * Observable triggered when a property is changed through the inspector.
  46586. */
  46587. get onPropertyChangedObservable(): any;
  46588. /**
  46589. * Instantiates a new debug layer.
  46590. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46591. * what is happening in your scene
  46592. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46593. * @param scene Defines the scene to inspect
  46594. */
  46595. constructor(scene: Scene);
  46596. /** Creates the inspector window. */
  46597. private _createInspector;
  46598. /**
  46599. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46600. * @param entity defines the entity to select
  46601. * @param lineContainerTitle defines the specific block to highlight
  46602. */
  46603. select(entity: any, lineContainerTitle?: string): void;
  46604. /** Get the inspector from bundle or global */
  46605. private _getGlobalInspector;
  46606. /**
  46607. * Get if the inspector is visible or not.
  46608. * @returns true if visible otherwise, false
  46609. */
  46610. isVisible(): boolean;
  46611. /**
  46612. * Hide the inspector and close its window.
  46613. */
  46614. hide(): void;
  46615. /**
  46616. * Launch the debugLayer.
  46617. * @param config Define the configuration of the inspector
  46618. * @return a promise fulfilled when the debug layer is visible
  46619. */
  46620. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46621. }
  46622. }
  46623. declare module BABYLON {
  46624. /**
  46625. * Class containing static functions to help procedurally build meshes
  46626. */
  46627. export class BoxBuilder {
  46628. /**
  46629. * Creates a box mesh
  46630. * * The parameter `size` sets the size (float) of each box side (default 1)
  46631. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46632. * * 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)
  46633. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46635. * * 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
  46636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46637. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46638. * @param name defines the name of the mesh
  46639. * @param options defines the options used to create the mesh
  46640. * @param scene defines the hosting scene
  46641. * @returns the box mesh
  46642. */
  46643. static CreateBox(name: string, options: {
  46644. size?: number;
  46645. width?: number;
  46646. height?: number;
  46647. depth?: number;
  46648. faceUV?: Vector4[];
  46649. faceColors?: Color4[];
  46650. sideOrientation?: number;
  46651. frontUVs?: Vector4;
  46652. backUVs?: Vector4;
  46653. wrap?: boolean;
  46654. topBaseAt?: number;
  46655. bottomBaseAt?: number;
  46656. updatable?: boolean;
  46657. }, scene?: Nullable<Scene>): Mesh;
  46658. }
  46659. }
  46660. declare module BABYLON.Debug {
  46661. /**
  46662. * Used to show the physics impostor around the specific mesh
  46663. */
  46664. export class PhysicsViewer {
  46665. /** @hidden */
  46666. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46667. /** @hidden */
  46668. protected _meshes: Array<Nullable<AbstractMesh>>;
  46669. /** @hidden */
  46670. protected _scene: Nullable<Scene>;
  46671. /** @hidden */
  46672. protected _numMeshes: number;
  46673. /** @hidden */
  46674. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46675. private _renderFunction;
  46676. private _utilityLayer;
  46677. private _debugBoxMesh;
  46678. private _debugSphereMesh;
  46679. private _debugCylinderMesh;
  46680. private _debugMaterial;
  46681. private _debugMeshMeshes;
  46682. /**
  46683. * Creates a new PhysicsViewer
  46684. * @param scene defines the hosting scene
  46685. */
  46686. constructor(scene: Scene);
  46687. /** @hidden */
  46688. protected _updateDebugMeshes(): void;
  46689. /**
  46690. * Renders a specified physic impostor
  46691. * @param impostor defines the impostor to render
  46692. * @param targetMesh defines the mesh represented by the impostor
  46693. * @returns the new debug mesh used to render the impostor
  46694. */
  46695. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46696. /**
  46697. * Hides a specified physic impostor
  46698. * @param impostor defines the impostor to hide
  46699. */
  46700. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46701. private _getDebugMaterial;
  46702. private _getDebugBoxMesh;
  46703. private _getDebugSphereMesh;
  46704. private _getDebugCylinderMesh;
  46705. private _getDebugMeshMesh;
  46706. private _getDebugMesh;
  46707. /** Releases all resources */
  46708. dispose(): void;
  46709. }
  46710. }
  46711. declare module BABYLON {
  46712. /**
  46713. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46714. * in order to better appreciate the issue one might have.
  46715. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46716. */
  46717. export class RayHelper {
  46718. /**
  46719. * Defines the ray we are currently tryin to visualize.
  46720. */
  46721. ray: Nullable<Ray>;
  46722. private _renderPoints;
  46723. private _renderLine;
  46724. private _renderFunction;
  46725. private _scene;
  46726. private _updateToMeshFunction;
  46727. private _attachedToMesh;
  46728. private _meshSpaceDirection;
  46729. private _meshSpaceOrigin;
  46730. /**
  46731. * Helper function to create a colored helper in a scene in one line.
  46732. * @param ray Defines the ray we are currently tryin to visualize
  46733. * @param scene Defines the scene the ray is used in
  46734. * @param color Defines the color we want to see the ray in
  46735. * @returns The newly created ray helper.
  46736. */
  46737. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46738. /**
  46739. * Instantiate a new ray helper.
  46740. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46741. * in order to better appreciate the issue one might have.
  46742. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46743. * @param ray Defines the ray we are currently tryin to visualize
  46744. */
  46745. constructor(ray: Ray);
  46746. /**
  46747. * Shows the ray we are willing to debug.
  46748. * @param scene Defines the scene the ray needs to be rendered in
  46749. * @param color Defines the color the ray needs to be rendered in
  46750. */
  46751. show(scene: Scene, color?: Color3): void;
  46752. /**
  46753. * Hides the ray we are debugging.
  46754. */
  46755. hide(): void;
  46756. private _render;
  46757. /**
  46758. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46759. * @param mesh Defines the mesh we want the helper attached to
  46760. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46761. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46762. * @param length Defines the length of the ray
  46763. */
  46764. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46765. /**
  46766. * Detach the ray helper from the mesh it has previously been attached to.
  46767. */
  46768. detachFromMesh(): void;
  46769. private _updateToMesh;
  46770. /**
  46771. * Dispose the helper and release its associated resources.
  46772. */
  46773. dispose(): void;
  46774. }
  46775. }
  46776. declare module BABYLON.Debug {
  46777. /**
  46778. * Class used to render a debug view of a given skeleton
  46779. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46780. */
  46781. export class SkeletonViewer {
  46782. /** defines the skeleton to render */
  46783. skeleton: Skeleton;
  46784. /** defines the mesh attached to the skeleton */
  46785. mesh: AbstractMesh;
  46786. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46787. autoUpdateBonesMatrices: boolean;
  46788. /** defines the rendering group id to use with the viewer */
  46789. renderingGroupId: number;
  46790. /** Gets or sets the color used to render the skeleton */
  46791. color: Color3;
  46792. private _scene;
  46793. private _debugLines;
  46794. private _debugMesh;
  46795. private _isEnabled;
  46796. private _renderFunction;
  46797. private _utilityLayer;
  46798. /**
  46799. * Returns the mesh used to render the bones
  46800. */
  46801. get debugMesh(): Nullable<LinesMesh>;
  46802. /**
  46803. * Creates a new SkeletonViewer
  46804. * @param skeleton defines the skeleton to render
  46805. * @param mesh defines the mesh attached to the skeleton
  46806. * @param scene defines the hosting scene
  46807. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46808. * @param renderingGroupId defines the rendering group id to use with the viewer
  46809. */
  46810. constructor(
  46811. /** defines the skeleton to render */
  46812. skeleton: Skeleton,
  46813. /** defines the mesh attached to the skeleton */
  46814. mesh: AbstractMesh, scene: Scene,
  46815. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46816. autoUpdateBonesMatrices?: boolean,
  46817. /** defines the rendering group id to use with the viewer */
  46818. renderingGroupId?: number);
  46819. /** Gets or sets a boolean indicating if the viewer is enabled */
  46820. set isEnabled(value: boolean);
  46821. get isEnabled(): boolean;
  46822. private _getBonePosition;
  46823. private _getLinesForBonesWithLength;
  46824. private _getLinesForBonesNoLength;
  46825. /** Update the viewer to sync with current skeleton state */
  46826. update(): void;
  46827. /** Release associated resources */
  46828. dispose(): void;
  46829. }
  46830. }
  46831. declare module BABYLON {
  46832. /**
  46833. * Options to create the null engine
  46834. */
  46835. export class NullEngineOptions {
  46836. /**
  46837. * Render width (Default: 512)
  46838. */
  46839. renderWidth: number;
  46840. /**
  46841. * Render height (Default: 256)
  46842. */
  46843. renderHeight: number;
  46844. /**
  46845. * Texture size (Default: 512)
  46846. */
  46847. textureSize: number;
  46848. /**
  46849. * If delta time between frames should be constant
  46850. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46851. */
  46852. deterministicLockstep: boolean;
  46853. /**
  46854. * Maximum about of steps between frames (Default: 4)
  46855. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46856. */
  46857. lockstepMaxSteps: number;
  46858. }
  46859. /**
  46860. * The null engine class provides support for headless version of babylon.js.
  46861. * This can be used in server side scenario or for testing purposes
  46862. */
  46863. export class NullEngine extends Engine {
  46864. private _options;
  46865. /**
  46866. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46867. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46868. * @returns true if engine is in deterministic lock step mode
  46869. */
  46870. isDeterministicLockStep(): boolean;
  46871. /**
  46872. * Gets the max steps when engine is running in deterministic lock step
  46873. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46874. * @returns the max steps
  46875. */
  46876. getLockstepMaxSteps(): number;
  46877. /**
  46878. * Gets the current hardware scaling level.
  46879. * By default the hardware scaling level is computed from the window device ratio.
  46880. * 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.
  46881. * @returns a number indicating the current hardware scaling level
  46882. */
  46883. getHardwareScalingLevel(): number;
  46884. constructor(options?: NullEngineOptions);
  46885. /**
  46886. * Creates a vertex buffer
  46887. * @param vertices the data for the vertex buffer
  46888. * @returns the new WebGL static buffer
  46889. */
  46890. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46891. /**
  46892. * Creates a new index buffer
  46893. * @param indices defines the content of the index buffer
  46894. * @param updatable defines if the index buffer must be updatable
  46895. * @returns a new webGL buffer
  46896. */
  46897. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46898. /**
  46899. * Clear the current render buffer or the current render target (if any is set up)
  46900. * @param color defines the color to use
  46901. * @param backBuffer defines if the back buffer must be cleared
  46902. * @param depth defines if the depth buffer must be cleared
  46903. * @param stencil defines if the stencil buffer must be cleared
  46904. */
  46905. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46906. /**
  46907. * Gets the current render width
  46908. * @param useScreen defines if screen size must be used (or the current render target if any)
  46909. * @returns a number defining the current render width
  46910. */
  46911. getRenderWidth(useScreen?: boolean): number;
  46912. /**
  46913. * Gets the current render height
  46914. * @param useScreen defines if screen size must be used (or the current render target if any)
  46915. * @returns a number defining the current render height
  46916. */
  46917. getRenderHeight(useScreen?: boolean): number;
  46918. /**
  46919. * Set the WebGL's viewport
  46920. * @param viewport defines the viewport element to be used
  46921. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46922. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46923. */
  46924. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46925. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46926. /**
  46927. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46928. * @param pipelineContext defines the pipeline context to use
  46929. * @param uniformsNames defines the list of uniform names
  46930. * @returns an array of webGL uniform locations
  46931. */
  46932. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46933. /**
  46934. * Gets the lsit of active attributes for a given webGL program
  46935. * @param pipelineContext defines the pipeline context to use
  46936. * @param attributesNames defines the list of attribute names to get
  46937. * @returns an array of indices indicating the offset of each attribute
  46938. */
  46939. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46940. /**
  46941. * Binds an effect to the webGL context
  46942. * @param effect defines the effect to bind
  46943. */
  46944. bindSamplers(effect: Effect): void;
  46945. /**
  46946. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46947. * @param effect defines the effect to activate
  46948. */
  46949. enableEffect(effect: Effect): void;
  46950. /**
  46951. * Set various states to the webGL context
  46952. * @param culling defines backface culling state
  46953. * @param zOffset defines the value to apply to zOffset (0 by default)
  46954. * @param force defines if states must be applied even if cache is up to date
  46955. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46956. */
  46957. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46958. /**
  46959. * Set the value of an uniform to an array of int32
  46960. * @param uniform defines the webGL uniform location where to store the value
  46961. * @param array defines the array of int32 to store
  46962. */
  46963. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46964. /**
  46965. * Set the value of an uniform to an array of int32 (stored as vec2)
  46966. * @param uniform defines the webGL uniform location where to store the value
  46967. * @param array defines the array of int32 to store
  46968. */
  46969. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46970. /**
  46971. * Set the value of an uniform to an array of int32 (stored as vec3)
  46972. * @param uniform defines the webGL uniform location where to store the value
  46973. * @param array defines the array of int32 to store
  46974. */
  46975. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46976. /**
  46977. * Set the value of an uniform to an array of int32 (stored as vec4)
  46978. * @param uniform defines the webGL uniform location where to store the value
  46979. * @param array defines the array of int32 to store
  46980. */
  46981. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46982. /**
  46983. * Set the value of an uniform to an array of float32
  46984. * @param uniform defines the webGL uniform location where to store the value
  46985. * @param array defines the array of float32 to store
  46986. */
  46987. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46988. /**
  46989. * Set the value of an uniform to an array of float32 (stored as vec2)
  46990. * @param uniform defines the webGL uniform location where to store the value
  46991. * @param array defines the array of float32 to store
  46992. */
  46993. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46994. /**
  46995. * Set the value of an uniform to an array of float32 (stored as vec3)
  46996. * @param uniform defines the webGL uniform location where to store the value
  46997. * @param array defines the array of float32 to store
  46998. */
  46999. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47000. /**
  47001. * Set the value of an uniform to an array of float32 (stored as vec4)
  47002. * @param uniform defines the webGL uniform location where to store the value
  47003. * @param array defines the array of float32 to store
  47004. */
  47005. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47006. /**
  47007. * Set the value of an uniform to an array of number
  47008. * @param uniform defines the webGL uniform location where to store the value
  47009. * @param array defines the array of number to store
  47010. */
  47011. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47012. /**
  47013. * Set the value of an uniform to an array of number (stored as vec2)
  47014. * @param uniform defines the webGL uniform location where to store the value
  47015. * @param array defines the array of number to store
  47016. */
  47017. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47018. /**
  47019. * Set the value of an uniform to an array of number (stored as vec3)
  47020. * @param uniform defines the webGL uniform location where to store the value
  47021. * @param array defines the array of number to store
  47022. */
  47023. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47024. /**
  47025. * Set the value of an uniform to an array of number (stored as vec4)
  47026. * @param uniform defines the webGL uniform location where to store the value
  47027. * @param array defines the array of number to store
  47028. */
  47029. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47030. /**
  47031. * Set the value of an uniform to an array of float32 (stored as matrices)
  47032. * @param uniform defines the webGL uniform location where to store the value
  47033. * @param matrices defines the array of float32 to store
  47034. */
  47035. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47036. /**
  47037. * Set the value of an uniform to a matrix (3x3)
  47038. * @param uniform defines the webGL uniform location where to store the value
  47039. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47040. */
  47041. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47042. /**
  47043. * Set the value of an uniform to a matrix (2x2)
  47044. * @param uniform defines the webGL uniform location where to store the value
  47045. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47046. */
  47047. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47048. /**
  47049. * Set the value of an uniform to a number (float)
  47050. * @param uniform defines the webGL uniform location where to store the value
  47051. * @param value defines the float number to store
  47052. */
  47053. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47054. /**
  47055. * Set the value of an uniform to a vec2
  47056. * @param uniform defines the webGL uniform location where to store the value
  47057. * @param x defines the 1st component of the value
  47058. * @param y defines the 2nd component of the value
  47059. */
  47060. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47061. /**
  47062. * Set the value of an uniform to a vec3
  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. * @param z defines the 3rd component of the value
  47067. */
  47068. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47069. /**
  47070. * Set the value of an uniform to a boolean
  47071. * @param uniform defines the webGL uniform location where to store the value
  47072. * @param bool defines the boolean to store
  47073. */
  47074. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47075. /**
  47076. * Set the value of an uniform to a vec4
  47077. * @param uniform defines the webGL uniform location where to store the value
  47078. * @param x defines the 1st component of the value
  47079. * @param y defines the 2nd component of the value
  47080. * @param z defines the 3rd component of the value
  47081. * @param w defines the 4th component of the value
  47082. */
  47083. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47084. /**
  47085. * Sets the current alpha mode
  47086. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47087. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47088. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47089. */
  47090. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47091. /**
  47092. * Bind webGl buffers directly to the webGL context
  47093. * @param vertexBuffers defines the vertex buffer to bind
  47094. * @param indexBuffer defines the index buffer to bind
  47095. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47096. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47097. * @param effect defines the effect associated with the vertex buffer
  47098. */
  47099. bindBuffers(vertexBuffers: {
  47100. [key: string]: VertexBuffer;
  47101. }, indexBuffer: DataBuffer, effect: Effect): void;
  47102. /**
  47103. * Force the entire cache to be cleared
  47104. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47105. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47106. */
  47107. wipeCaches(bruteForce?: boolean): void;
  47108. /**
  47109. * Send a draw order
  47110. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47111. * @param indexStart defines the starting index
  47112. * @param indexCount defines the number of index to draw
  47113. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47114. */
  47115. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47116. /**
  47117. * Draw a list of indexed primitives
  47118. * @param fillMode defines the primitive to use
  47119. * @param indexStart defines the starting index
  47120. * @param indexCount defines the number of index to draw
  47121. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47122. */
  47123. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47124. /**
  47125. * Draw a list of unindexed primitives
  47126. * @param fillMode defines the primitive to use
  47127. * @param verticesStart defines the index of first vertex to draw
  47128. * @param verticesCount defines the count of vertices to draw
  47129. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47130. */
  47131. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47132. /** @hidden */
  47133. _createTexture(): WebGLTexture;
  47134. /** @hidden */
  47135. _releaseTexture(texture: InternalTexture): void;
  47136. /**
  47137. * Usually called from Texture.ts.
  47138. * Passed information to create a WebGLTexture
  47139. * @param urlArg defines a value which contains one of the following:
  47140. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47141. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47142. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47143. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47144. * @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)
  47145. * @param scene needed for loading to the correct scene
  47146. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47147. * @param onLoad optional callback to be called upon successful completion
  47148. * @param onError optional callback to be called upon failure
  47149. * @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
  47150. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47151. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47152. * @param forcedExtension defines the extension to use to pick the right loader
  47153. * @param mimeType defines an optional mime type
  47154. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47155. */
  47156. 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;
  47157. /**
  47158. * Creates a new render target texture
  47159. * @param size defines the size of the texture
  47160. * @param options defines the options used to create the texture
  47161. * @returns a new render target texture stored in an InternalTexture
  47162. */
  47163. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47164. /**
  47165. * Update the sampling mode of a given texture
  47166. * @param samplingMode defines the required sampling mode
  47167. * @param texture defines the texture to update
  47168. */
  47169. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47170. /**
  47171. * Binds the frame buffer to the specified texture.
  47172. * @param texture The texture to render to or null for the default canvas
  47173. * @param faceIndex The face of the texture to render to in case of cube texture
  47174. * @param requiredWidth The width of the target to render to
  47175. * @param requiredHeight The height of the target to render to
  47176. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47177. * @param lodLevel defines le lod level to bind to the frame buffer
  47178. */
  47179. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47180. /**
  47181. * Unbind the current render target texture from the webGL context
  47182. * @param texture defines the render target texture to unbind
  47183. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47184. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47185. */
  47186. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47187. /**
  47188. * Creates a dynamic vertex buffer
  47189. * @param vertices the data for the dynamic vertex buffer
  47190. * @returns the new WebGL dynamic buffer
  47191. */
  47192. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47193. /**
  47194. * Update the content of a dynamic texture
  47195. * @param texture defines the texture to update
  47196. * @param canvas defines the canvas containing the source
  47197. * @param invertY defines if data must be stored with Y axis inverted
  47198. * @param premulAlpha defines if alpha is stored as premultiplied
  47199. * @param format defines the format of the data
  47200. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47201. */
  47202. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47203. /**
  47204. * Gets a boolean indicating if all created effects are ready
  47205. * @returns true if all effects are ready
  47206. */
  47207. areAllEffectsReady(): boolean;
  47208. /**
  47209. * @hidden
  47210. * Get the current error code of the webGL context
  47211. * @returns the error code
  47212. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47213. */
  47214. getError(): number;
  47215. /** @hidden */
  47216. _getUnpackAlignement(): number;
  47217. /** @hidden */
  47218. _unpackFlipY(value: boolean): void;
  47219. /**
  47220. * Update a dynamic index buffer
  47221. * @param indexBuffer defines the target index buffer
  47222. * @param indices defines the data to update
  47223. * @param offset defines the offset in the target index buffer where update should start
  47224. */
  47225. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47226. /**
  47227. * Updates a dynamic vertex buffer.
  47228. * @param vertexBuffer the vertex buffer to update
  47229. * @param vertices the data used to update the vertex buffer
  47230. * @param byteOffset the byte offset of the data (optional)
  47231. * @param byteLength the byte length of the data (optional)
  47232. */
  47233. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47234. /** @hidden */
  47235. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47236. /** @hidden */
  47237. _bindTexture(channel: number, texture: InternalTexture): void;
  47238. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47239. /**
  47240. * 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
  47241. */
  47242. releaseEffects(): void;
  47243. displayLoadingUI(): void;
  47244. hideLoadingUI(): void;
  47245. /** @hidden */
  47246. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47247. /** @hidden */
  47248. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47249. /** @hidden */
  47250. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47251. /** @hidden */
  47252. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47253. }
  47254. }
  47255. declare module BABYLON {
  47256. /**
  47257. * @hidden
  47258. **/
  47259. export class _TimeToken {
  47260. _startTimeQuery: Nullable<WebGLQuery>;
  47261. _endTimeQuery: Nullable<WebGLQuery>;
  47262. _timeElapsedQuery: Nullable<WebGLQuery>;
  47263. _timeElapsedQueryEnded: boolean;
  47264. }
  47265. }
  47266. declare module BABYLON {
  47267. /** @hidden */
  47268. export class _OcclusionDataStorage {
  47269. /** @hidden */
  47270. occlusionInternalRetryCounter: number;
  47271. /** @hidden */
  47272. isOcclusionQueryInProgress: boolean;
  47273. /** @hidden */
  47274. isOccluded: boolean;
  47275. /** @hidden */
  47276. occlusionRetryCount: number;
  47277. /** @hidden */
  47278. occlusionType: number;
  47279. /** @hidden */
  47280. occlusionQueryAlgorithmType: number;
  47281. }
  47282. interface Engine {
  47283. /**
  47284. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47285. * @return the new query
  47286. */
  47287. createQuery(): WebGLQuery;
  47288. /**
  47289. * Delete and release a webGL query
  47290. * @param query defines the query to delete
  47291. * @return the current engine
  47292. */
  47293. deleteQuery(query: WebGLQuery): Engine;
  47294. /**
  47295. * Check if a given query has resolved and got its value
  47296. * @param query defines the query to check
  47297. * @returns true if the query got its value
  47298. */
  47299. isQueryResultAvailable(query: WebGLQuery): boolean;
  47300. /**
  47301. * Gets the value of a given query
  47302. * @param query defines the query to check
  47303. * @returns the value of the query
  47304. */
  47305. getQueryResult(query: WebGLQuery): number;
  47306. /**
  47307. * Initiates an occlusion query
  47308. * @param algorithmType defines the algorithm to use
  47309. * @param query defines the query to use
  47310. * @returns the current engine
  47311. * @see http://doc.babylonjs.com/features/occlusionquery
  47312. */
  47313. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47314. /**
  47315. * Ends an occlusion query
  47316. * @see http://doc.babylonjs.com/features/occlusionquery
  47317. * @param algorithmType defines the algorithm to use
  47318. * @returns the current engine
  47319. */
  47320. endOcclusionQuery(algorithmType: number): Engine;
  47321. /**
  47322. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47323. * Please note that only one query can be issued at a time
  47324. * @returns a time token used to track the time span
  47325. */
  47326. startTimeQuery(): Nullable<_TimeToken>;
  47327. /**
  47328. * Ends a time query
  47329. * @param token defines the token used to measure the time span
  47330. * @returns the time spent (in ns)
  47331. */
  47332. endTimeQuery(token: _TimeToken): int;
  47333. /** @hidden */
  47334. _currentNonTimestampToken: Nullable<_TimeToken>;
  47335. /** @hidden */
  47336. _createTimeQuery(): WebGLQuery;
  47337. /** @hidden */
  47338. _deleteTimeQuery(query: WebGLQuery): void;
  47339. /** @hidden */
  47340. _getGlAlgorithmType(algorithmType: number): number;
  47341. /** @hidden */
  47342. _getTimeQueryResult(query: WebGLQuery): any;
  47343. /** @hidden */
  47344. _getTimeQueryAvailability(query: WebGLQuery): any;
  47345. }
  47346. interface AbstractMesh {
  47347. /**
  47348. * Backing filed
  47349. * @hidden
  47350. */
  47351. __occlusionDataStorage: _OcclusionDataStorage;
  47352. /**
  47353. * Access property
  47354. * @hidden
  47355. */
  47356. _occlusionDataStorage: _OcclusionDataStorage;
  47357. /**
  47358. * 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.
  47359. * The default value is -1 which means don't break the query and wait till the result
  47360. * @see http://doc.babylonjs.com/features/occlusionquery
  47361. */
  47362. occlusionRetryCount: number;
  47363. /**
  47364. * 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:
  47365. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47366. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47367. * * 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.
  47368. * @see http://doc.babylonjs.com/features/occlusionquery
  47369. */
  47370. occlusionType: number;
  47371. /**
  47372. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47373. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47374. * * 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.
  47375. * @see http://doc.babylonjs.com/features/occlusionquery
  47376. */
  47377. occlusionQueryAlgorithmType: number;
  47378. /**
  47379. * 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
  47380. * @see http://doc.babylonjs.com/features/occlusionquery
  47381. */
  47382. isOccluded: boolean;
  47383. /**
  47384. * Flag to check the progress status of the query
  47385. * @see http://doc.babylonjs.com/features/occlusionquery
  47386. */
  47387. isOcclusionQueryInProgress: boolean;
  47388. }
  47389. }
  47390. declare module BABYLON {
  47391. /** @hidden */
  47392. export var _forceTransformFeedbackToBundle: boolean;
  47393. interface Engine {
  47394. /**
  47395. * Creates a webGL transform feedback object
  47396. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47397. * @returns the webGL transform feedback object
  47398. */
  47399. createTransformFeedback(): WebGLTransformFeedback;
  47400. /**
  47401. * Delete a webGL transform feedback object
  47402. * @param value defines the webGL transform feedback object to delete
  47403. */
  47404. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47405. /**
  47406. * Bind a webGL transform feedback object to the webgl context
  47407. * @param value defines the webGL transform feedback object to bind
  47408. */
  47409. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47410. /**
  47411. * Begins a transform feedback operation
  47412. * @param usePoints defines if points or triangles must be used
  47413. */
  47414. beginTransformFeedback(usePoints: boolean): void;
  47415. /**
  47416. * Ends a transform feedback operation
  47417. */
  47418. endTransformFeedback(): void;
  47419. /**
  47420. * Specify the varyings to use with transform feedback
  47421. * @param program defines the associated webGL program
  47422. * @param value defines the list of strings representing the varying names
  47423. */
  47424. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47425. /**
  47426. * Bind a webGL buffer for a transform feedback operation
  47427. * @param value defines the webGL buffer to bind
  47428. */
  47429. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47430. }
  47431. }
  47432. declare module BABYLON {
  47433. /**
  47434. * Creation options of the multi render target texture.
  47435. */
  47436. export interface IMultiRenderTargetOptions {
  47437. /**
  47438. * Define if the texture needs to create mip maps after render.
  47439. */
  47440. generateMipMaps?: boolean;
  47441. /**
  47442. * Define the types of all the draw buffers we want to create
  47443. */
  47444. types?: number[];
  47445. /**
  47446. * Define the sampling modes of all the draw buffers we want to create
  47447. */
  47448. samplingModes?: number[];
  47449. /**
  47450. * Define if a depth buffer is required
  47451. */
  47452. generateDepthBuffer?: boolean;
  47453. /**
  47454. * Define if a stencil buffer is required
  47455. */
  47456. generateStencilBuffer?: boolean;
  47457. /**
  47458. * Define if a depth texture is required instead of a depth buffer
  47459. */
  47460. generateDepthTexture?: boolean;
  47461. /**
  47462. * Define the number of desired draw buffers
  47463. */
  47464. textureCount?: number;
  47465. /**
  47466. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47467. */
  47468. doNotChangeAspectRatio?: boolean;
  47469. /**
  47470. * Define the default type of the buffers we are creating
  47471. */
  47472. defaultType?: number;
  47473. }
  47474. /**
  47475. * A multi render target, like a render target provides the ability to render to a texture.
  47476. * Unlike the render target, it can render to several draw buffers in one draw.
  47477. * This is specially interesting in deferred rendering or for any effects requiring more than
  47478. * just one color from a single pass.
  47479. */
  47480. export class MultiRenderTarget extends RenderTargetTexture {
  47481. private _internalTextures;
  47482. private _textures;
  47483. private _multiRenderTargetOptions;
  47484. /**
  47485. * Get if draw buffers are currently supported by the used hardware and browser.
  47486. */
  47487. get isSupported(): boolean;
  47488. /**
  47489. * Get the list of textures generated by the multi render target.
  47490. */
  47491. get textures(): Texture[];
  47492. /**
  47493. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47494. */
  47495. get depthTexture(): Texture;
  47496. /**
  47497. * Set the wrapping mode on U of all the textures we are rendering to.
  47498. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47499. */
  47500. set wrapU(wrap: number);
  47501. /**
  47502. * Set the wrapping mode on V of all the textures we are rendering to.
  47503. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47504. */
  47505. set wrapV(wrap: number);
  47506. /**
  47507. * Instantiate a new multi render target texture.
  47508. * A multi render target, like a render target provides the ability to render to a texture.
  47509. * Unlike the render target, it can render to several draw buffers in one draw.
  47510. * This is specially interesting in deferred rendering or for any effects requiring more than
  47511. * just one color from a single pass.
  47512. * @param name Define the name of the texture
  47513. * @param size Define the size of the buffers to render to
  47514. * @param count Define the number of target we are rendering into
  47515. * @param scene Define the scene the texture belongs to
  47516. * @param options Define the options used to create the multi render target
  47517. */
  47518. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47519. /** @hidden */
  47520. _rebuild(): void;
  47521. private _createInternalTextures;
  47522. private _createTextures;
  47523. /**
  47524. * Define the number of samples used if MSAA is enabled.
  47525. */
  47526. get samples(): number;
  47527. set samples(value: number);
  47528. /**
  47529. * Resize all the textures in the multi render target.
  47530. * Be carrefull as it will recreate all the data in the new texture.
  47531. * @param size Define the new size
  47532. */
  47533. resize(size: any): void;
  47534. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47535. /**
  47536. * Dispose the render targets and their associated resources
  47537. */
  47538. dispose(): void;
  47539. /**
  47540. * Release all the underlying texture used as draw buffers.
  47541. */
  47542. releaseInternalTextures(): void;
  47543. }
  47544. }
  47545. declare module BABYLON {
  47546. interface ThinEngine {
  47547. /**
  47548. * Unbind a list of render target textures from the webGL context
  47549. * This is used only when drawBuffer extension or webGL2 are active
  47550. * @param textures defines the render target textures to unbind
  47551. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47552. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47553. */
  47554. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47555. /**
  47556. * Create a multi render target texture
  47557. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47558. * @param size defines the size of the texture
  47559. * @param options defines the creation options
  47560. * @returns the cube texture as an InternalTexture
  47561. */
  47562. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47563. /**
  47564. * Update the sample count for a given multiple render target texture
  47565. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47566. * @param textures defines the textures to update
  47567. * @param samples defines the sample count to set
  47568. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47569. */
  47570. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47571. }
  47572. }
  47573. declare module BABYLON {
  47574. /**
  47575. * Class used to define an additional view for the engine
  47576. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47577. */
  47578. export class EngineView {
  47579. /** Defines the canvas where to render the view */
  47580. target: HTMLCanvasElement;
  47581. /** Defines an optional camera used to render the view (will use active camera else) */
  47582. camera?: Camera;
  47583. }
  47584. interface Engine {
  47585. /**
  47586. * Gets or sets the HTML element to use for attaching events
  47587. */
  47588. inputElement: Nullable<HTMLElement>;
  47589. /**
  47590. * Gets the current engine view
  47591. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47592. */
  47593. activeView: Nullable<EngineView>;
  47594. /** Gets or sets the list of views */
  47595. views: EngineView[];
  47596. /**
  47597. * Register a new child canvas
  47598. * @param canvas defines the canvas to register
  47599. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47600. * @returns the associated view
  47601. */
  47602. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47603. /**
  47604. * Remove a registered child canvas
  47605. * @param canvas defines the canvas to remove
  47606. * @returns the current engine
  47607. */
  47608. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47609. }
  47610. }
  47611. declare module BABYLON {
  47612. interface Engine {
  47613. /** @hidden */
  47614. _excludedCompressedTextures: string[];
  47615. /** @hidden */
  47616. _textureFormatInUse: string;
  47617. /**
  47618. * Gets the list of texture formats supported
  47619. */
  47620. readonly texturesSupported: Array<string>;
  47621. /**
  47622. * Gets the texture format in use
  47623. */
  47624. readonly textureFormatInUse: Nullable<string>;
  47625. /**
  47626. * Set the compressed texture extensions or file names to skip.
  47627. *
  47628. * @param skippedFiles defines the list of those texture files you want to skip
  47629. * Example: [".dds", ".env", "myfile.png"]
  47630. */
  47631. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47632. /**
  47633. * Set the compressed texture format to use, based on the formats you have, and the formats
  47634. * supported by the hardware / browser.
  47635. *
  47636. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47637. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47638. * to API arguments needed to compressed textures. This puts the burden on the container
  47639. * generator to house the arcane code for determining these for current & future formats.
  47640. *
  47641. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47642. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47643. *
  47644. * Note: The result of this call is not taken into account when a texture is base64.
  47645. *
  47646. * @param formatsAvailable defines the list of those format families you have created
  47647. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47648. *
  47649. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47650. * @returns The extension selected.
  47651. */
  47652. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47653. }
  47654. }
  47655. declare module BABYLON {
  47656. /**
  47657. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47658. */
  47659. export interface CubeMapInfo {
  47660. /**
  47661. * The pixel array for the front face.
  47662. * This is stored in format, left to right, up to down format.
  47663. */
  47664. front: Nullable<ArrayBufferView>;
  47665. /**
  47666. * The pixel array for the back face.
  47667. * This is stored in format, left to right, up to down format.
  47668. */
  47669. back: Nullable<ArrayBufferView>;
  47670. /**
  47671. * The pixel array for the left face.
  47672. * This is stored in format, left to right, up to down format.
  47673. */
  47674. left: Nullable<ArrayBufferView>;
  47675. /**
  47676. * The pixel array for the right face.
  47677. * This is stored in format, left to right, up to down format.
  47678. */
  47679. right: Nullable<ArrayBufferView>;
  47680. /**
  47681. * The pixel array for the up face.
  47682. * This is stored in format, left to right, up to down format.
  47683. */
  47684. up: Nullable<ArrayBufferView>;
  47685. /**
  47686. * The pixel array for the down face.
  47687. * This is stored in format, left to right, up to down format.
  47688. */
  47689. down: Nullable<ArrayBufferView>;
  47690. /**
  47691. * The size of the cubemap stored.
  47692. *
  47693. * Each faces will be size * size pixels.
  47694. */
  47695. size: number;
  47696. /**
  47697. * The format of the texture.
  47698. *
  47699. * RGBA, RGB.
  47700. */
  47701. format: number;
  47702. /**
  47703. * The type of the texture data.
  47704. *
  47705. * UNSIGNED_INT, FLOAT.
  47706. */
  47707. type: number;
  47708. /**
  47709. * Specifies whether the texture is in gamma space.
  47710. */
  47711. gammaSpace: boolean;
  47712. }
  47713. /**
  47714. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47715. */
  47716. export class PanoramaToCubeMapTools {
  47717. private static FACE_FRONT;
  47718. private static FACE_BACK;
  47719. private static FACE_RIGHT;
  47720. private static FACE_LEFT;
  47721. private static FACE_DOWN;
  47722. private static FACE_UP;
  47723. /**
  47724. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47725. *
  47726. * @param float32Array The source data.
  47727. * @param inputWidth The width of the input panorama.
  47728. * @param inputHeight The height of the input panorama.
  47729. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47730. * @return The cubemap data
  47731. */
  47732. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47733. private static CreateCubemapTexture;
  47734. private static CalcProjectionSpherical;
  47735. }
  47736. }
  47737. declare module BABYLON {
  47738. /**
  47739. * Helper class dealing with the extraction of spherical polynomial dataArray
  47740. * from a cube map.
  47741. */
  47742. export class CubeMapToSphericalPolynomialTools {
  47743. private static FileFaces;
  47744. /**
  47745. * Converts a texture to the according Spherical Polynomial data.
  47746. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47747. *
  47748. * @param texture The texture to extract the information from.
  47749. * @return The Spherical Polynomial data.
  47750. */
  47751. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47752. /**
  47753. * Converts a cubemap to the according Spherical Polynomial data.
  47754. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47755. *
  47756. * @param cubeInfo The Cube map to extract the information from.
  47757. * @return The Spherical Polynomial data.
  47758. */
  47759. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47760. }
  47761. }
  47762. declare module BABYLON {
  47763. interface BaseTexture {
  47764. /**
  47765. * Get the polynomial representation of the texture data.
  47766. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47767. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47768. */
  47769. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47770. }
  47771. }
  47772. declare module BABYLON {
  47773. /** @hidden */
  47774. export var rgbdEncodePixelShader: {
  47775. name: string;
  47776. shader: string;
  47777. };
  47778. }
  47779. declare module BABYLON {
  47780. /** @hidden */
  47781. export var rgbdDecodePixelShader: {
  47782. name: string;
  47783. shader: string;
  47784. };
  47785. }
  47786. declare module BABYLON {
  47787. /**
  47788. * Raw texture data and descriptor sufficient for WebGL texture upload
  47789. */
  47790. export interface EnvironmentTextureInfo {
  47791. /**
  47792. * Version of the environment map
  47793. */
  47794. version: number;
  47795. /**
  47796. * Width of image
  47797. */
  47798. width: number;
  47799. /**
  47800. * Irradiance information stored in the file.
  47801. */
  47802. irradiance: any;
  47803. /**
  47804. * Specular information stored in the file.
  47805. */
  47806. specular: any;
  47807. }
  47808. /**
  47809. * Defines One Image in the file. It requires only the position in the file
  47810. * as well as the length.
  47811. */
  47812. interface BufferImageData {
  47813. /**
  47814. * Length of the image data.
  47815. */
  47816. length: number;
  47817. /**
  47818. * Position of the data from the null terminator delimiting the end of the JSON.
  47819. */
  47820. position: number;
  47821. }
  47822. /**
  47823. * Defines the specular data enclosed in the file.
  47824. * This corresponds to the version 1 of the data.
  47825. */
  47826. export interface EnvironmentTextureSpecularInfoV1 {
  47827. /**
  47828. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47829. */
  47830. specularDataPosition?: number;
  47831. /**
  47832. * This contains all the images data needed to reconstruct the cubemap.
  47833. */
  47834. mipmaps: Array<BufferImageData>;
  47835. /**
  47836. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47837. */
  47838. lodGenerationScale: number;
  47839. }
  47840. /**
  47841. * Sets of helpers addressing the serialization and deserialization of environment texture
  47842. * stored in a BabylonJS env file.
  47843. * Those files are usually stored as .env files.
  47844. */
  47845. export class EnvironmentTextureTools {
  47846. /**
  47847. * Magic number identifying the env file.
  47848. */
  47849. private static _MagicBytes;
  47850. /**
  47851. * Gets the environment info from an env file.
  47852. * @param data The array buffer containing the .env bytes.
  47853. * @returns the environment file info (the json header) if successfully parsed.
  47854. */
  47855. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47856. /**
  47857. * Creates an environment texture from a loaded cube texture.
  47858. * @param texture defines the cube texture to convert in env file
  47859. * @return a promise containing the environment data if succesfull.
  47860. */
  47861. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47862. /**
  47863. * Creates a JSON representation of the spherical data.
  47864. * @param texture defines the texture containing the polynomials
  47865. * @return the JSON representation of the spherical info
  47866. */
  47867. private static _CreateEnvTextureIrradiance;
  47868. /**
  47869. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47870. * @param data the image data
  47871. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47872. * @return the views described by info providing access to the underlying buffer
  47873. */
  47874. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47875. /**
  47876. * Uploads the texture info contained in the env file to the GPU.
  47877. * @param texture defines the internal texture to upload to
  47878. * @param data defines the data to load
  47879. * @param info defines the texture info retrieved through the GetEnvInfo method
  47880. * @returns a promise
  47881. */
  47882. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47883. private static _OnImageReadyAsync;
  47884. /**
  47885. * Uploads the levels of image data to the GPU.
  47886. * @param texture defines the internal texture to upload to
  47887. * @param imageData defines the array buffer views of image data [mipmap][face]
  47888. * @returns a promise
  47889. */
  47890. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47891. /**
  47892. * Uploads spherical polynomials information to the texture.
  47893. * @param texture defines the texture we are trying to upload the information to
  47894. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47895. */
  47896. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47897. /** @hidden */
  47898. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47899. }
  47900. }
  47901. declare module BABYLON {
  47902. /**
  47903. * Contains position and normal vectors for a vertex
  47904. */
  47905. export class PositionNormalVertex {
  47906. /** the position of the vertex (defaut: 0,0,0) */
  47907. position: Vector3;
  47908. /** the normal of the vertex (defaut: 0,1,0) */
  47909. normal: Vector3;
  47910. /**
  47911. * Creates a PositionNormalVertex
  47912. * @param position the position of the vertex (defaut: 0,0,0)
  47913. * @param normal the normal of the vertex (defaut: 0,1,0)
  47914. */
  47915. constructor(
  47916. /** the position of the vertex (defaut: 0,0,0) */
  47917. position?: Vector3,
  47918. /** the normal of the vertex (defaut: 0,1,0) */
  47919. normal?: Vector3);
  47920. /**
  47921. * Clones the PositionNormalVertex
  47922. * @returns the cloned PositionNormalVertex
  47923. */
  47924. clone(): PositionNormalVertex;
  47925. }
  47926. /**
  47927. * Contains position, normal and uv vectors for a vertex
  47928. */
  47929. export class PositionNormalTextureVertex {
  47930. /** the position of the vertex (defaut: 0,0,0) */
  47931. position: Vector3;
  47932. /** the normal of the vertex (defaut: 0,1,0) */
  47933. normal: Vector3;
  47934. /** the uv of the vertex (default: 0,0) */
  47935. uv: Vector2;
  47936. /**
  47937. * Creates a PositionNormalTextureVertex
  47938. * @param position the position of the vertex (defaut: 0,0,0)
  47939. * @param normal the normal of the vertex (defaut: 0,1,0)
  47940. * @param uv the uv of the vertex (default: 0,0)
  47941. */
  47942. constructor(
  47943. /** the position of the vertex (defaut: 0,0,0) */
  47944. position?: Vector3,
  47945. /** the normal of the vertex (defaut: 0,1,0) */
  47946. normal?: Vector3,
  47947. /** the uv of the vertex (default: 0,0) */
  47948. uv?: Vector2);
  47949. /**
  47950. * Clones the PositionNormalTextureVertex
  47951. * @returns the cloned PositionNormalTextureVertex
  47952. */
  47953. clone(): PositionNormalTextureVertex;
  47954. }
  47955. }
  47956. declare module BABYLON {
  47957. /** @hidden */
  47958. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47959. private _genericAttributeLocation;
  47960. private _varyingLocationCount;
  47961. private _varyingLocationMap;
  47962. private _replacements;
  47963. private _textureCount;
  47964. private _uniforms;
  47965. lineProcessor(line: string): string;
  47966. attributeProcessor(attribute: string): string;
  47967. varyingProcessor(varying: string, isFragment: boolean): string;
  47968. uniformProcessor(uniform: string): string;
  47969. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47970. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47971. }
  47972. }
  47973. declare module BABYLON {
  47974. /**
  47975. * Container for accessors for natively-stored mesh data buffers.
  47976. */
  47977. class NativeDataBuffer extends DataBuffer {
  47978. /**
  47979. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47980. */
  47981. nativeIndexBuffer?: any;
  47982. /**
  47983. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47984. */
  47985. nativeVertexBuffer?: any;
  47986. }
  47987. /** @hidden */
  47988. class NativeTexture extends InternalTexture {
  47989. getInternalTexture(): InternalTexture;
  47990. getViewCount(): number;
  47991. }
  47992. /** @hidden */
  47993. export class NativeEngine extends Engine {
  47994. private readonly _native;
  47995. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47996. private readonly INVALID_HANDLE;
  47997. getHardwareScalingLevel(): number;
  47998. constructor();
  47999. /**
  48000. * Can be used to override the current requestAnimationFrame requester.
  48001. * @hidden
  48002. */
  48003. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48004. /**
  48005. * Override default engine behavior.
  48006. * @param color
  48007. * @param backBuffer
  48008. * @param depth
  48009. * @param stencil
  48010. */
  48011. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48012. /**
  48013. * Gets host document
  48014. * @returns the host document object
  48015. */
  48016. getHostDocument(): Nullable<Document>;
  48017. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48018. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48019. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48020. recordVertexArrayObject(vertexBuffers: {
  48021. [key: string]: VertexBuffer;
  48022. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48023. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48024. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48025. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48026. /**
  48027. * Draw a list of indexed primitives
  48028. * @param fillMode defines the primitive to use
  48029. * @param indexStart defines the starting index
  48030. * @param indexCount defines the number of index to draw
  48031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48032. */
  48033. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48034. /**
  48035. * Draw a list of unindexed primitives
  48036. * @param fillMode defines the primitive to use
  48037. * @param verticesStart defines the index of first vertex to draw
  48038. * @param verticesCount defines the count of vertices to draw
  48039. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48040. */
  48041. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48042. createPipelineContext(): IPipelineContext;
  48043. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48044. /** @hidden */
  48045. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48046. /** @hidden */
  48047. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48048. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48049. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48050. protected _setProgram(program: WebGLProgram): void;
  48051. _releaseEffect(effect: Effect): void;
  48052. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48053. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48054. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48055. bindSamplers(effect: Effect): void;
  48056. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48057. getRenderWidth(useScreen?: boolean): number;
  48058. getRenderHeight(useScreen?: boolean): number;
  48059. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48060. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48061. /**
  48062. * Set the z offset to apply to current rendering
  48063. * @param value defines the offset to apply
  48064. */
  48065. setZOffset(value: number): void;
  48066. /**
  48067. * Gets the current value of the zOffset
  48068. * @returns the current zOffset state
  48069. */
  48070. getZOffset(): number;
  48071. /**
  48072. * Enable or disable depth buffering
  48073. * @param enable defines the state to set
  48074. */
  48075. setDepthBuffer(enable: boolean): void;
  48076. /**
  48077. * Gets a boolean indicating if depth writing is enabled
  48078. * @returns the current depth writing state
  48079. */
  48080. getDepthWrite(): boolean;
  48081. /**
  48082. * Enable or disable depth writing
  48083. * @param enable defines the state to set
  48084. */
  48085. setDepthWrite(enable: boolean): void;
  48086. /**
  48087. * Enable or disable color writing
  48088. * @param enable defines the state to set
  48089. */
  48090. setColorWrite(enable: boolean): void;
  48091. /**
  48092. * Gets a boolean indicating if color writing is enabled
  48093. * @returns the current color writing state
  48094. */
  48095. getColorWrite(): boolean;
  48096. /**
  48097. * Sets alpha constants used by some alpha blending modes
  48098. * @param r defines the red component
  48099. * @param g defines the green component
  48100. * @param b defines the blue component
  48101. * @param a defines the alpha component
  48102. */
  48103. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48104. /**
  48105. * Sets the current alpha mode
  48106. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48107. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48108. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48109. */
  48110. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48111. /**
  48112. * Gets the current alpha mode
  48113. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48114. * @returns the current alpha mode
  48115. */
  48116. getAlphaMode(): number;
  48117. setInt(uniform: WebGLUniformLocation, int: number): void;
  48118. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48119. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48120. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48121. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48122. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48123. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48124. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48125. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48126. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48127. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48128. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48129. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48130. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48131. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48132. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48133. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48134. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48135. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48136. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48137. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48138. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48139. wipeCaches(bruteForce?: boolean): void;
  48140. _createTexture(): WebGLTexture;
  48141. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48142. /**
  48143. * Usually called from Texture.ts.
  48144. * Passed information to create a WebGLTexture
  48145. * @param urlArg defines a value which contains one of the following:
  48146. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48147. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48148. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48149. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48150. * @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)
  48151. * @param scene needed for loading to the correct scene
  48152. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48153. * @param onLoad optional callback to be called upon successful completion
  48154. * @param onError optional callback to be called upon failure
  48155. * @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
  48156. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48157. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48158. * @param forcedExtension defines the extension to use to pick the right loader
  48159. * @param mimeType defines an optional mime type
  48160. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48161. */
  48162. 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;
  48163. /**
  48164. * Creates a cube texture
  48165. * @param rootUrl defines the url where the files to load is located
  48166. * @param scene defines the current scene
  48167. * @param files defines the list of files to load (1 per face)
  48168. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48169. * @param onLoad defines an optional callback raised when the texture is loaded
  48170. * @param onError defines an optional callback raised if there is an issue to load the texture
  48171. * @param format defines the format of the data
  48172. * @param forcedExtension defines the extension to use to pick the right loader
  48173. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48174. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48175. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48176. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48177. * @returns the cube texture as an InternalTexture
  48178. */
  48179. 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;
  48180. private _getSamplingFilter;
  48181. private static _GetNativeTextureFormat;
  48182. createRenderTargetTexture(size: number | {
  48183. width: number;
  48184. height: number;
  48185. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48186. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48187. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48188. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48189. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48190. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48191. /**
  48192. * Updates a dynamic vertex buffer.
  48193. * @param vertexBuffer the vertex buffer to update
  48194. * @param data the data used to update the vertex buffer
  48195. * @param byteOffset the byte offset of the data (optional)
  48196. * @param byteLength the byte length of the data (optional)
  48197. */
  48198. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48199. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48200. private _updateAnisotropicLevel;
  48201. private _getAddressMode;
  48202. /** @hidden */
  48203. _bindTexture(channel: number, texture: InternalTexture): void;
  48204. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48205. releaseEffects(): void;
  48206. /** @hidden */
  48207. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48208. /** @hidden */
  48209. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48210. /** @hidden */
  48211. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48212. /** @hidden */
  48213. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48214. }
  48215. }
  48216. declare module BABYLON {
  48217. /**
  48218. * Gather the list of clipboard event types as constants.
  48219. */
  48220. export class ClipboardEventTypes {
  48221. /**
  48222. * The clipboard event is fired when a copy command is active (pressed).
  48223. */
  48224. static readonly COPY: number;
  48225. /**
  48226. * The clipboard event is fired when a cut command is active (pressed).
  48227. */
  48228. static readonly CUT: number;
  48229. /**
  48230. * The clipboard event is fired when a paste command is active (pressed).
  48231. */
  48232. static readonly PASTE: number;
  48233. }
  48234. /**
  48235. * This class is used to store clipboard related info for the onClipboardObservable event.
  48236. */
  48237. export class ClipboardInfo {
  48238. /**
  48239. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48240. */
  48241. type: number;
  48242. /**
  48243. * Defines the related dom event
  48244. */
  48245. event: ClipboardEvent;
  48246. /**
  48247. *Creates an instance of ClipboardInfo.
  48248. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48249. * @param event Defines the related dom event
  48250. */
  48251. constructor(
  48252. /**
  48253. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48254. */
  48255. type: number,
  48256. /**
  48257. * Defines the related dom event
  48258. */
  48259. event: ClipboardEvent);
  48260. /**
  48261. * Get the clipboard event's type from the keycode.
  48262. * @param keyCode Defines the keyCode for the current keyboard event.
  48263. * @return {number}
  48264. */
  48265. static GetTypeFromCharacter(keyCode: number): number;
  48266. }
  48267. }
  48268. declare module BABYLON {
  48269. /**
  48270. * Google Daydream controller
  48271. */
  48272. export class DaydreamController extends WebVRController {
  48273. /**
  48274. * Base Url for the controller model.
  48275. */
  48276. static MODEL_BASE_URL: string;
  48277. /**
  48278. * File name for the controller model.
  48279. */
  48280. static MODEL_FILENAME: string;
  48281. /**
  48282. * Gamepad Id prefix used to identify Daydream Controller.
  48283. */
  48284. static readonly GAMEPAD_ID_PREFIX: string;
  48285. /**
  48286. * Creates a new DaydreamController from a gamepad
  48287. * @param vrGamepad the gamepad that the controller should be created from
  48288. */
  48289. constructor(vrGamepad: any);
  48290. /**
  48291. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48292. * @param scene scene in which to add meshes
  48293. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48294. */
  48295. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48296. /**
  48297. * Called once for each button that changed state since the last frame
  48298. * @param buttonIdx Which button index changed
  48299. * @param state New state of the button
  48300. * @param changes Which properties on the state changed since last frame
  48301. */
  48302. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48303. }
  48304. }
  48305. declare module BABYLON {
  48306. /**
  48307. * Gear VR Controller
  48308. */
  48309. export class GearVRController extends WebVRController {
  48310. /**
  48311. * Base Url for the controller model.
  48312. */
  48313. static MODEL_BASE_URL: string;
  48314. /**
  48315. * File name for the controller model.
  48316. */
  48317. static MODEL_FILENAME: string;
  48318. /**
  48319. * Gamepad Id prefix used to identify this controller.
  48320. */
  48321. static readonly GAMEPAD_ID_PREFIX: string;
  48322. private readonly _buttonIndexToObservableNameMap;
  48323. /**
  48324. * Creates a new GearVRController from a gamepad
  48325. * @param vrGamepad the gamepad that the controller should be created from
  48326. */
  48327. constructor(vrGamepad: any);
  48328. /**
  48329. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48330. * @param scene scene in which to add meshes
  48331. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48332. */
  48333. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48334. /**
  48335. * Called once for each button that changed state since the last frame
  48336. * @param buttonIdx Which button index changed
  48337. * @param state New state of the button
  48338. * @param changes Which properties on the state changed since last frame
  48339. */
  48340. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48341. }
  48342. }
  48343. declare module BABYLON {
  48344. /**
  48345. * Generic Controller
  48346. */
  48347. export class GenericController extends WebVRController {
  48348. /**
  48349. * Base Url for the controller model.
  48350. */
  48351. static readonly MODEL_BASE_URL: string;
  48352. /**
  48353. * File name for the controller model.
  48354. */
  48355. static readonly MODEL_FILENAME: string;
  48356. /**
  48357. * Creates a new GenericController from a gamepad
  48358. * @param vrGamepad the gamepad that the controller should be created from
  48359. */
  48360. constructor(vrGamepad: any);
  48361. /**
  48362. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48363. * @param scene scene in which to add meshes
  48364. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48365. */
  48366. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48367. /**
  48368. * Called once for each button that changed state since the last frame
  48369. * @param buttonIdx Which button index changed
  48370. * @param state New state of the button
  48371. * @param changes Which properties on the state changed since last frame
  48372. */
  48373. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48374. }
  48375. }
  48376. declare module BABYLON {
  48377. /**
  48378. * Oculus Touch Controller
  48379. */
  48380. export class OculusTouchController extends WebVRController {
  48381. /**
  48382. * Base Url for the controller model.
  48383. */
  48384. static MODEL_BASE_URL: string;
  48385. /**
  48386. * File name for the left controller model.
  48387. */
  48388. static MODEL_LEFT_FILENAME: string;
  48389. /**
  48390. * File name for the right controller model.
  48391. */
  48392. static MODEL_RIGHT_FILENAME: string;
  48393. /**
  48394. * Base Url for the Quest controller model.
  48395. */
  48396. static QUEST_MODEL_BASE_URL: string;
  48397. /**
  48398. * @hidden
  48399. * If the controllers are running on a device that needs the updated Quest controller models
  48400. */
  48401. static _IsQuest: boolean;
  48402. /**
  48403. * Fired when the secondary trigger on this controller is modified
  48404. */
  48405. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48406. /**
  48407. * Fired when the thumb rest on this controller is modified
  48408. */
  48409. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48410. /**
  48411. * Creates a new OculusTouchController from a gamepad
  48412. * @param vrGamepad the gamepad that the controller should be created from
  48413. */
  48414. constructor(vrGamepad: any);
  48415. /**
  48416. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48417. * @param scene scene in which to add meshes
  48418. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48419. */
  48420. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48421. /**
  48422. * Fired when the A button on this controller is modified
  48423. */
  48424. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48425. /**
  48426. * Fired when the B button on this controller is modified
  48427. */
  48428. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48429. /**
  48430. * Fired when the X button on this controller is modified
  48431. */
  48432. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48433. /**
  48434. * Fired when the Y button on this controller is modified
  48435. */
  48436. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48437. /**
  48438. * Called once for each button that changed state since the last frame
  48439. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48440. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48441. * 2) secondary trigger (same)
  48442. * 3) A (right) X (left), touch, pressed = value
  48443. * 4) B / Y
  48444. * 5) thumb rest
  48445. * @param buttonIdx Which button index changed
  48446. * @param state New state of the button
  48447. * @param changes Which properties on the state changed since last frame
  48448. */
  48449. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48450. }
  48451. }
  48452. declare module BABYLON {
  48453. /**
  48454. * Vive Controller
  48455. */
  48456. export class ViveController extends WebVRController {
  48457. /**
  48458. * Base Url for the controller model.
  48459. */
  48460. static MODEL_BASE_URL: string;
  48461. /**
  48462. * File name for the controller model.
  48463. */
  48464. static MODEL_FILENAME: string;
  48465. /**
  48466. * Creates a new ViveController from a gamepad
  48467. * @param vrGamepad the gamepad that the controller should be created from
  48468. */
  48469. constructor(vrGamepad: any);
  48470. /**
  48471. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48472. * @param scene scene in which to add meshes
  48473. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48474. */
  48475. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48476. /**
  48477. * Fired when the left button on this controller is modified
  48478. */
  48479. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48480. /**
  48481. * Fired when the right button on this controller is modified
  48482. */
  48483. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48484. /**
  48485. * Fired when the menu button on this controller is modified
  48486. */
  48487. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48488. /**
  48489. * Called once for each button that changed state since the last frame
  48490. * Vive mapping:
  48491. * 0: touchpad
  48492. * 1: trigger
  48493. * 2: left AND right buttons
  48494. * 3: menu button
  48495. * @param buttonIdx Which button index changed
  48496. * @param state New state of the button
  48497. * @param changes Which properties on the state changed since last frame
  48498. */
  48499. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48500. }
  48501. }
  48502. declare module BABYLON {
  48503. /**
  48504. * Defines the WindowsMotionController object that the state of the windows motion controller
  48505. */
  48506. export class WindowsMotionController extends WebVRController {
  48507. /**
  48508. * The base url used to load the left and right controller models
  48509. */
  48510. static MODEL_BASE_URL: string;
  48511. /**
  48512. * The name of the left controller model file
  48513. */
  48514. static MODEL_LEFT_FILENAME: string;
  48515. /**
  48516. * The name of the right controller model file
  48517. */
  48518. static MODEL_RIGHT_FILENAME: string;
  48519. /**
  48520. * The controller name prefix for this controller type
  48521. */
  48522. static readonly GAMEPAD_ID_PREFIX: string;
  48523. /**
  48524. * The controller id pattern for this controller type
  48525. */
  48526. private static readonly GAMEPAD_ID_PATTERN;
  48527. private _loadedMeshInfo;
  48528. protected readonly _mapping: {
  48529. buttons: string[];
  48530. buttonMeshNames: {
  48531. trigger: string;
  48532. menu: string;
  48533. grip: string;
  48534. thumbstick: string;
  48535. trackpad: string;
  48536. };
  48537. buttonObservableNames: {
  48538. trigger: string;
  48539. menu: string;
  48540. grip: string;
  48541. thumbstick: string;
  48542. trackpad: string;
  48543. };
  48544. axisMeshNames: string[];
  48545. pointingPoseMeshName: string;
  48546. };
  48547. /**
  48548. * Fired when the trackpad on this controller is clicked
  48549. */
  48550. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48551. /**
  48552. * Fired when the trackpad on this controller is modified
  48553. */
  48554. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48555. /**
  48556. * The current x and y values of this controller's trackpad
  48557. */
  48558. trackpad: StickValues;
  48559. /**
  48560. * Creates a new WindowsMotionController from a gamepad
  48561. * @param vrGamepad the gamepad that the controller should be created from
  48562. */
  48563. constructor(vrGamepad: any);
  48564. /**
  48565. * Fired when the trigger on this controller is modified
  48566. */
  48567. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48568. /**
  48569. * Fired when the menu button on this controller is modified
  48570. */
  48571. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48572. /**
  48573. * Fired when the grip button on this controller is modified
  48574. */
  48575. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48576. /**
  48577. * Fired when the thumbstick button on this controller is modified
  48578. */
  48579. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48580. /**
  48581. * Fired when the touchpad button on this controller is modified
  48582. */
  48583. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48584. /**
  48585. * Fired when the touchpad values on this controller are modified
  48586. */
  48587. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48588. protected _updateTrackpad(): void;
  48589. /**
  48590. * Called once per frame by the engine.
  48591. */
  48592. update(): void;
  48593. /**
  48594. * Called once for each button that changed state since the last frame
  48595. * @param buttonIdx Which button index changed
  48596. * @param state New state of the button
  48597. * @param changes Which properties on the state changed since last frame
  48598. */
  48599. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48600. /**
  48601. * Moves the buttons on the controller mesh based on their current state
  48602. * @param buttonName the name of the button to move
  48603. * @param buttonValue the value of the button which determines the buttons new position
  48604. */
  48605. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48606. /**
  48607. * Moves the axis on the controller mesh based on its current state
  48608. * @param axis the index of the axis
  48609. * @param axisValue the value of the axis which determines the meshes new position
  48610. * @hidden
  48611. */
  48612. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48613. /**
  48614. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48615. * @param scene scene in which to add meshes
  48616. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48617. */
  48618. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48619. /**
  48620. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48621. * can be transformed by button presses and axes values, based on this._mapping.
  48622. *
  48623. * @param scene scene in which the meshes exist
  48624. * @param meshes list of meshes that make up the controller model to process
  48625. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48626. */
  48627. private processModel;
  48628. private createMeshInfo;
  48629. /**
  48630. * Gets the ray of the controller in the direction the controller is pointing
  48631. * @param length the length the resulting ray should be
  48632. * @returns a ray in the direction the controller is pointing
  48633. */
  48634. getForwardRay(length?: number): Ray;
  48635. /**
  48636. * Disposes of the controller
  48637. */
  48638. dispose(): void;
  48639. }
  48640. /**
  48641. * This class represents a new windows motion controller in XR.
  48642. */
  48643. export class XRWindowsMotionController extends WindowsMotionController {
  48644. /**
  48645. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48646. */
  48647. protected readonly _mapping: {
  48648. buttons: string[];
  48649. buttonMeshNames: {
  48650. trigger: string;
  48651. menu: string;
  48652. grip: string;
  48653. thumbstick: string;
  48654. trackpad: string;
  48655. };
  48656. buttonObservableNames: {
  48657. trigger: string;
  48658. menu: string;
  48659. grip: string;
  48660. thumbstick: string;
  48661. trackpad: string;
  48662. };
  48663. axisMeshNames: string[];
  48664. pointingPoseMeshName: string;
  48665. };
  48666. /**
  48667. * Construct a new XR-Based windows motion controller
  48668. *
  48669. * @param gamepadInfo the gamepad object from the browser
  48670. */
  48671. constructor(gamepadInfo: any);
  48672. /**
  48673. * holds the thumbstick values (X,Y)
  48674. */
  48675. thumbstickValues: StickValues;
  48676. /**
  48677. * Fired when the thumbstick on this controller is clicked
  48678. */
  48679. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48680. /**
  48681. * Fired when the thumbstick on this controller is modified
  48682. */
  48683. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48684. /**
  48685. * Fired when the touchpad button on this controller is modified
  48686. */
  48687. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48688. /**
  48689. * Fired when the touchpad values on this controller are modified
  48690. */
  48691. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48692. /**
  48693. * Fired when the thumbstick button on this controller is modified
  48694. * here to prevent breaking changes
  48695. */
  48696. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48697. /**
  48698. * updating the thumbstick(!) and not the trackpad.
  48699. * This is named this way due to the difference between WebVR and XR and to avoid
  48700. * changing the parent class.
  48701. */
  48702. protected _updateTrackpad(): void;
  48703. /**
  48704. * Disposes the class with joy
  48705. */
  48706. dispose(): void;
  48707. }
  48708. }
  48709. declare module BABYLON {
  48710. /**
  48711. * Class containing static functions to help procedurally build meshes
  48712. */
  48713. export class PolyhedronBuilder {
  48714. /**
  48715. * Creates a polyhedron mesh
  48716. * * 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
  48717. * * The parameter `size` (positive float, default 1) sets the polygon size
  48718. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48719. * * 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`
  48720. * * 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
  48721. * * 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)`)
  48722. * * 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
  48723. * * 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
  48724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48725. * * 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
  48726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48727. * @param name defines the name of the mesh
  48728. * @param options defines the options used to create the mesh
  48729. * @param scene defines the hosting scene
  48730. * @returns the polyhedron mesh
  48731. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48732. */
  48733. static CreatePolyhedron(name: string, options: {
  48734. type?: number;
  48735. size?: number;
  48736. sizeX?: number;
  48737. sizeY?: number;
  48738. sizeZ?: number;
  48739. custom?: any;
  48740. faceUV?: Vector4[];
  48741. faceColors?: Color4[];
  48742. flat?: boolean;
  48743. updatable?: boolean;
  48744. sideOrientation?: number;
  48745. frontUVs?: Vector4;
  48746. backUVs?: Vector4;
  48747. }, scene?: Nullable<Scene>): Mesh;
  48748. }
  48749. }
  48750. declare module BABYLON {
  48751. /**
  48752. * Gizmo that enables scaling a mesh along 3 axis
  48753. */
  48754. export class ScaleGizmo extends Gizmo {
  48755. /**
  48756. * Internal gizmo used for interactions on the x axis
  48757. */
  48758. xGizmo: AxisScaleGizmo;
  48759. /**
  48760. * Internal gizmo used for interactions on the y axis
  48761. */
  48762. yGizmo: AxisScaleGizmo;
  48763. /**
  48764. * Internal gizmo used for interactions on the z axis
  48765. */
  48766. zGizmo: AxisScaleGizmo;
  48767. /**
  48768. * Internal gizmo used to scale all axis equally
  48769. */
  48770. uniformScaleGizmo: AxisScaleGizmo;
  48771. private _meshAttached;
  48772. private _updateGizmoRotationToMatchAttachedMesh;
  48773. private _snapDistance;
  48774. private _scaleRatio;
  48775. private _uniformScalingMesh;
  48776. private _octahedron;
  48777. private _sensitivity;
  48778. /** Fires an event when any of it's sub gizmos are dragged */
  48779. onDragStartObservable: Observable<unknown>;
  48780. /** Fires an event when any of it's sub gizmos are released from dragging */
  48781. onDragEndObservable: Observable<unknown>;
  48782. get attachedMesh(): Nullable<AbstractMesh>;
  48783. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48784. /**
  48785. * Creates a ScaleGizmo
  48786. * @param gizmoLayer The utility layer the gizmo will be added to
  48787. */
  48788. constructor(gizmoLayer?: UtilityLayerRenderer);
  48789. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48790. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48791. /**
  48792. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48793. */
  48794. set snapDistance(value: number);
  48795. get snapDistance(): number;
  48796. /**
  48797. * Ratio for the scale of the gizmo (Default: 1)
  48798. */
  48799. set scaleRatio(value: number);
  48800. get scaleRatio(): number;
  48801. /**
  48802. * Sensitivity factor for dragging (Default: 1)
  48803. */
  48804. set sensitivity(value: number);
  48805. get sensitivity(): number;
  48806. /**
  48807. * Disposes of the gizmo
  48808. */
  48809. dispose(): void;
  48810. }
  48811. }
  48812. declare module BABYLON {
  48813. /**
  48814. * Single axis scale gizmo
  48815. */
  48816. export class AxisScaleGizmo extends Gizmo {
  48817. /**
  48818. * Drag behavior responsible for the gizmos dragging interactions
  48819. */
  48820. dragBehavior: PointerDragBehavior;
  48821. private _pointerObserver;
  48822. /**
  48823. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48824. */
  48825. snapDistance: number;
  48826. /**
  48827. * Event that fires each time the gizmo snaps to a new location.
  48828. * * snapDistance is the the change in distance
  48829. */
  48830. onSnapObservable: Observable<{
  48831. snapDistance: number;
  48832. }>;
  48833. /**
  48834. * If the scaling operation should be done on all axis (default: false)
  48835. */
  48836. uniformScaling: boolean;
  48837. /**
  48838. * Custom sensitivity value for the drag strength
  48839. */
  48840. sensitivity: number;
  48841. private _isEnabled;
  48842. private _parent;
  48843. private _arrow;
  48844. private _coloredMaterial;
  48845. private _hoverMaterial;
  48846. /**
  48847. * Creates an AxisScaleGizmo
  48848. * @param gizmoLayer The utility layer the gizmo will be added to
  48849. * @param dragAxis The axis which the gizmo will be able to scale on
  48850. * @param color The color of the gizmo
  48851. */
  48852. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48853. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48854. /**
  48855. * If the gizmo is enabled
  48856. */
  48857. set isEnabled(value: boolean);
  48858. get isEnabled(): boolean;
  48859. /**
  48860. * Disposes of the gizmo
  48861. */
  48862. dispose(): void;
  48863. /**
  48864. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48865. * @param mesh The mesh to replace the default mesh of the gizmo
  48866. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48867. */
  48868. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48869. }
  48870. }
  48871. declare module BABYLON {
  48872. /**
  48873. * Bounding box gizmo
  48874. */
  48875. export class BoundingBoxGizmo extends Gizmo {
  48876. private _lineBoundingBox;
  48877. private _rotateSpheresParent;
  48878. private _scaleBoxesParent;
  48879. private _boundingDimensions;
  48880. private _renderObserver;
  48881. private _pointerObserver;
  48882. private _scaleDragSpeed;
  48883. private _tmpQuaternion;
  48884. private _tmpVector;
  48885. private _tmpRotationMatrix;
  48886. /**
  48887. * 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)
  48888. */
  48889. ignoreChildren: boolean;
  48890. /**
  48891. * 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)
  48892. */
  48893. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48894. /**
  48895. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48896. */
  48897. rotationSphereSize: number;
  48898. /**
  48899. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48900. */
  48901. scaleBoxSize: number;
  48902. /**
  48903. * 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)
  48904. */
  48905. fixedDragMeshScreenSize: boolean;
  48906. /**
  48907. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48908. */
  48909. fixedDragMeshScreenSizeDistanceFactor: number;
  48910. /**
  48911. * Fired when a rotation sphere or scale box is dragged
  48912. */
  48913. onDragStartObservable: Observable<{}>;
  48914. /**
  48915. * Fired when a scale box is dragged
  48916. */
  48917. onScaleBoxDragObservable: Observable<{}>;
  48918. /**
  48919. * Fired when a scale box drag is ended
  48920. */
  48921. onScaleBoxDragEndObservable: Observable<{}>;
  48922. /**
  48923. * Fired when a rotation sphere is dragged
  48924. */
  48925. onRotationSphereDragObservable: Observable<{}>;
  48926. /**
  48927. * Fired when a rotation sphere drag is ended
  48928. */
  48929. onRotationSphereDragEndObservable: Observable<{}>;
  48930. /**
  48931. * 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)
  48932. */
  48933. scalePivot: Nullable<Vector3>;
  48934. /**
  48935. * Mesh used as a pivot to rotate the attached mesh
  48936. */
  48937. private _anchorMesh;
  48938. private _existingMeshScale;
  48939. private _dragMesh;
  48940. private pointerDragBehavior;
  48941. private coloredMaterial;
  48942. private hoverColoredMaterial;
  48943. /**
  48944. * Sets the color of the bounding box gizmo
  48945. * @param color the color to set
  48946. */
  48947. setColor(color: Color3): void;
  48948. /**
  48949. * Creates an BoundingBoxGizmo
  48950. * @param gizmoLayer The utility layer the gizmo will be added to
  48951. * @param color The color of the gizmo
  48952. */
  48953. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48954. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48955. private _selectNode;
  48956. /**
  48957. * Updates the bounding box information for the Gizmo
  48958. */
  48959. updateBoundingBox(): void;
  48960. private _updateRotationSpheres;
  48961. private _updateScaleBoxes;
  48962. /**
  48963. * Enables rotation on the specified axis and disables rotation on the others
  48964. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48965. */
  48966. setEnabledRotationAxis(axis: string): void;
  48967. /**
  48968. * Enables/disables scaling
  48969. * @param enable if scaling should be enabled
  48970. * @param homogeneousScaling defines if scaling should only be homogeneous
  48971. */
  48972. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  48973. private _updateDummy;
  48974. /**
  48975. * Enables a pointer drag behavior on the bounding box of the gizmo
  48976. */
  48977. enableDragBehavior(): void;
  48978. /**
  48979. * Disposes of the gizmo
  48980. */
  48981. dispose(): void;
  48982. /**
  48983. * 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)
  48984. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48985. * @returns the bounding box mesh with the passed in mesh as a child
  48986. */
  48987. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48988. /**
  48989. * CustomMeshes are not supported by this gizmo
  48990. * @param mesh The mesh to replace the default mesh of the gizmo
  48991. */
  48992. setCustomMesh(mesh: Mesh): void;
  48993. }
  48994. }
  48995. declare module BABYLON {
  48996. /**
  48997. * Single plane rotation gizmo
  48998. */
  48999. export class PlaneRotationGizmo extends Gizmo {
  49000. /**
  49001. * Drag behavior responsible for the gizmos dragging interactions
  49002. */
  49003. dragBehavior: PointerDragBehavior;
  49004. private _pointerObserver;
  49005. /**
  49006. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49007. */
  49008. snapDistance: number;
  49009. /**
  49010. * Event that fires each time the gizmo snaps to a new location.
  49011. * * snapDistance is the the change in distance
  49012. */
  49013. onSnapObservable: Observable<{
  49014. snapDistance: number;
  49015. }>;
  49016. private _isEnabled;
  49017. private _parent;
  49018. /**
  49019. * Creates a PlaneRotationGizmo
  49020. * @param gizmoLayer The utility layer the gizmo will be added to
  49021. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49022. * @param color The color of the gizmo
  49023. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49024. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49025. */
  49026. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49027. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49028. /**
  49029. * If the gizmo is enabled
  49030. */
  49031. set isEnabled(value: boolean);
  49032. get isEnabled(): boolean;
  49033. /**
  49034. * Disposes of the gizmo
  49035. */
  49036. dispose(): void;
  49037. }
  49038. }
  49039. declare module BABYLON {
  49040. /**
  49041. * Gizmo that enables rotating a mesh along 3 axis
  49042. */
  49043. export class RotationGizmo extends Gizmo {
  49044. /**
  49045. * Internal gizmo used for interactions on the x axis
  49046. */
  49047. xGizmo: PlaneRotationGizmo;
  49048. /**
  49049. * Internal gizmo used for interactions on the y axis
  49050. */
  49051. yGizmo: PlaneRotationGizmo;
  49052. /**
  49053. * Internal gizmo used for interactions on the z axis
  49054. */
  49055. zGizmo: PlaneRotationGizmo;
  49056. /** Fires an event when any of it's sub gizmos are dragged */
  49057. onDragStartObservable: Observable<unknown>;
  49058. /** Fires an event when any of it's sub gizmos are released from dragging */
  49059. onDragEndObservable: Observable<unknown>;
  49060. private _meshAttached;
  49061. get attachedMesh(): Nullable<AbstractMesh>;
  49062. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49063. /**
  49064. * Creates a RotationGizmo
  49065. * @param gizmoLayer The utility layer the gizmo will be added to
  49066. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49067. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49068. */
  49069. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49070. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49071. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49072. /**
  49073. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49074. */
  49075. set snapDistance(value: number);
  49076. get snapDistance(): number;
  49077. /**
  49078. * Ratio for the scale of the gizmo (Default: 1)
  49079. */
  49080. set scaleRatio(value: number);
  49081. get scaleRatio(): number;
  49082. /**
  49083. * Disposes of the gizmo
  49084. */
  49085. dispose(): void;
  49086. /**
  49087. * CustomMeshes are not supported by this gizmo
  49088. * @param mesh The mesh to replace the default mesh of the gizmo
  49089. */
  49090. setCustomMesh(mesh: Mesh): void;
  49091. }
  49092. }
  49093. declare module BABYLON {
  49094. /**
  49095. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49096. */
  49097. export class GizmoManager implements IDisposable {
  49098. private scene;
  49099. /**
  49100. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49101. */
  49102. gizmos: {
  49103. positionGizmo: Nullable<PositionGizmo>;
  49104. rotationGizmo: Nullable<RotationGizmo>;
  49105. scaleGizmo: Nullable<ScaleGizmo>;
  49106. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49107. };
  49108. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49109. clearGizmoOnEmptyPointerEvent: boolean;
  49110. /** Fires an event when the manager is attached to a mesh */
  49111. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49112. private _gizmosEnabled;
  49113. private _pointerObserver;
  49114. private _attachedMesh;
  49115. private _boundingBoxColor;
  49116. private _defaultUtilityLayer;
  49117. private _defaultKeepDepthUtilityLayer;
  49118. /**
  49119. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49120. */
  49121. boundingBoxDragBehavior: SixDofDragBehavior;
  49122. /**
  49123. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49124. */
  49125. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49126. /**
  49127. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49128. */
  49129. usePointerToAttachGizmos: boolean;
  49130. /**
  49131. * Utility layer that the bounding box gizmo belongs to
  49132. */
  49133. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49134. /**
  49135. * Utility layer that all gizmos besides bounding box belong to
  49136. */
  49137. get utilityLayer(): UtilityLayerRenderer;
  49138. /**
  49139. * Instatiates a gizmo manager
  49140. * @param scene the scene to overlay the gizmos on top of
  49141. */
  49142. constructor(scene: Scene);
  49143. /**
  49144. * Attaches a set of gizmos to the specified mesh
  49145. * @param mesh The mesh the gizmo's should be attached to
  49146. */
  49147. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49148. /**
  49149. * If the position gizmo is enabled
  49150. */
  49151. set positionGizmoEnabled(value: boolean);
  49152. get positionGizmoEnabled(): boolean;
  49153. /**
  49154. * If the rotation gizmo is enabled
  49155. */
  49156. set rotationGizmoEnabled(value: boolean);
  49157. get rotationGizmoEnabled(): boolean;
  49158. /**
  49159. * If the scale gizmo is enabled
  49160. */
  49161. set scaleGizmoEnabled(value: boolean);
  49162. get scaleGizmoEnabled(): boolean;
  49163. /**
  49164. * If the boundingBox gizmo is enabled
  49165. */
  49166. set boundingBoxGizmoEnabled(value: boolean);
  49167. get boundingBoxGizmoEnabled(): boolean;
  49168. /**
  49169. * Disposes of the gizmo manager
  49170. */
  49171. dispose(): void;
  49172. }
  49173. }
  49174. declare module BABYLON {
  49175. /**
  49176. * A directional light is defined by a direction (what a surprise!).
  49177. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49178. * 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.
  49179. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49180. */
  49181. export class DirectionalLight extends ShadowLight {
  49182. private _shadowFrustumSize;
  49183. /**
  49184. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49185. */
  49186. get shadowFrustumSize(): number;
  49187. /**
  49188. * Specifies a fix frustum size for the shadow generation.
  49189. */
  49190. set shadowFrustumSize(value: number);
  49191. private _shadowOrthoScale;
  49192. /**
  49193. * Gets the shadow projection scale against the optimal computed one.
  49194. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49195. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49196. */
  49197. get shadowOrthoScale(): number;
  49198. /**
  49199. * Sets the shadow projection scale against the optimal computed one.
  49200. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49201. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49202. */
  49203. set shadowOrthoScale(value: number);
  49204. /**
  49205. * Automatically compute the projection matrix to best fit (including all the casters)
  49206. * on each frame.
  49207. */
  49208. autoUpdateExtends: boolean;
  49209. /**
  49210. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49211. * on each frame. autoUpdateExtends must be set to true for this to work
  49212. */
  49213. autoCalcShadowZBounds: boolean;
  49214. private _orthoLeft;
  49215. private _orthoRight;
  49216. private _orthoTop;
  49217. private _orthoBottom;
  49218. /**
  49219. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49220. * The directional light is emitted from everywhere in the given direction.
  49221. * It can cast shadows.
  49222. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49223. * @param name The friendly name of the light
  49224. * @param direction The direction of the light
  49225. * @param scene The scene the light belongs to
  49226. */
  49227. constructor(name: string, direction: Vector3, scene: Scene);
  49228. /**
  49229. * Returns the string "DirectionalLight".
  49230. * @return The class name
  49231. */
  49232. getClassName(): string;
  49233. /**
  49234. * Returns the integer 1.
  49235. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49236. */
  49237. getTypeID(): number;
  49238. /**
  49239. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49240. * Returns the DirectionalLight Shadow projection matrix.
  49241. */
  49242. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49243. /**
  49244. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49245. * Returns the DirectionalLight Shadow projection matrix.
  49246. */
  49247. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49248. /**
  49249. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49250. * Returns the DirectionalLight Shadow projection matrix.
  49251. */
  49252. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49253. protected _buildUniformLayout(): void;
  49254. /**
  49255. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49256. * @param effect The effect to update
  49257. * @param lightIndex The index of the light in the effect to update
  49258. * @returns The directional light
  49259. */
  49260. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49261. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49262. /**
  49263. * Gets the minZ used for shadow according to both the scene and the light.
  49264. *
  49265. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49266. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49267. * @param activeCamera The camera we are returning the min for
  49268. * @returns the depth min z
  49269. */
  49270. getDepthMinZ(activeCamera: Camera): number;
  49271. /**
  49272. * Gets the maxZ used for shadow according to both the scene and the light.
  49273. *
  49274. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49275. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49276. * @param activeCamera The camera we are returning the max for
  49277. * @returns the depth max z
  49278. */
  49279. getDepthMaxZ(activeCamera: Camera): number;
  49280. /**
  49281. * Prepares the list of defines specific to the light type.
  49282. * @param defines the list of defines
  49283. * @param lightIndex defines the index of the light for the effect
  49284. */
  49285. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49286. }
  49287. }
  49288. declare module BABYLON {
  49289. /**
  49290. * Class containing static functions to help procedurally build meshes
  49291. */
  49292. export class HemisphereBuilder {
  49293. /**
  49294. * Creates a hemisphere mesh
  49295. * @param name defines the name of the mesh
  49296. * @param options defines the options used to create the mesh
  49297. * @param scene defines the hosting scene
  49298. * @returns the hemisphere mesh
  49299. */
  49300. static CreateHemisphere(name: string, options: {
  49301. segments?: number;
  49302. diameter?: number;
  49303. sideOrientation?: number;
  49304. }, scene: any): Mesh;
  49305. }
  49306. }
  49307. declare module BABYLON {
  49308. /**
  49309. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49310. * These values define a cone of light starting from the position, emitting toward the direction.
  49311. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49312. * and the exponent defines the speed of the decay of the light with distance (reach).
  49313. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49314. */
  49315. export class SpotLight extends ShadowLight {
  49316. private _angle;
  49317. private _innerAngle;
  49318. private _cosHalfAngle;
  49319. private _lightAngleScale;
  49320. private _lightAngleOffset;
  49321. /**
  49322. * Gets the cone angle of the spot light in Radians.
  49323. */
  49324. get angle(): number;
  49325. /**
  49326. * Sets the cone angle of the spot light in Radians.
  49327. */
  49328. set angle(value: number);
  49329. /**
  49330. * Only used in gltf falloff mode, this defines the angle where
  49331. * the directional falloff will start before cutting at angle which could be seen
  49332. * as outer angle.
  49333. */
  49334. get innerAngle(): number;
  49335. /**
  49336. * Only used in gltf falloff mode, this defines the angle where
  49337. * the directional falloff will start before cutting at angle which could be seen
  49338. * as outer angle.
  49339. */
  49340. set innerAngle(value: number);
  49341. private _shadowAngleScale;
  49342. /**
  49343. * Allows scaling the angle of the light for shadow generation only.
  49344. */
  49345. get shadowAngleScale(): number;
  49346. /**
  49347. * Allows scaling the angle of the light for shadow generation only.
  49348. */
  49349. set shadowAngleScale(value: number);
  49350. /**
  49351. * The light decay speed with the distance from the emission spot.
  49352. */
  49353. exponent: number;
  49354. private _projectionTextureMatrix;
  49355. /**
  49356. * Allows reading the projecton texture
  49357. */
  49358. get projectionTextureMatrix(): Matrix;
  49359. protected _projectionTextureLightNear: number;
  49360. /**
  49361. * Gets the near clip of the Spotlight for texture projection.
  49362. */
  49363. get projectionTextureLightNear(): number;
  49364. /**
  49365. * Sets the near clip of the Spotlight for texture projection.
  49366. */
  49367. set projectionTextureLightNear(value: number);
  49368. protected _projectionTextureLightFar: number;
  49369. /**
  49370. * Gets the far clip of the Spotlight for texture projection.
  49371. */
  49372. get projectionTextureLightFar(): number;
  49373. /**
  49374. * Sets the far clip of the Spotlight for texture projection.
  49375. */
  49376. set projectionTextureLightFar(value: number);
  49377. protected _projectionTextureUpDirection: Vector3;
  49378. /**
  49379. * Gets the Up vector of the Spotlight for texture projection.
  49380. */
  49381. get projectionTextureUpDirection(): Vector3;
  49382. /**
  49383. * Sets the Up vector of the Spotlight for texture projection.
  49384. */
  49385. set projectionTextureUpDirection(value: Vector3);
  49386. private _projectionTexture;
  49387. /**
  49388. * Gets the projection texture of the light.
  49389. */
  49390. get projectionTexture(): Nullable<BaseTexture>;
  49391. /**
  49392. * Sets the projection texture of the light.
  49393. */
  49394. set projectionTexture(value: Nullable<BaseTexture>);
  49395. private _projectionTextureViewLightDirty;
  49396. private _projectionTextureProjectionLightDirty;
  49397. private _projectionTextureDirty;
  49398. private _projectionTextureViewTargetVector;
  49399. private _projectionTextureViewLightMatrix;
  49400. private _projectionTextureProjectionLightMatrix;
  49401. private _projectionTextureScalingMatrix;
  49402. /**
  49403. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49404. * It can cast shadows.
  49405. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49406. * @param name The light friendly name
  49407. * @param position The position of the spot light in the scene
  49408. * @param direction The direction of the light in the scene
  49409. * @param angle The cone angle of the light in Radians
  49410. * @param exponent The light decay speed with the distance from the emission spot
  49411. * @param scene The scene the lights belongs to
  49412. */
  49413. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49414. /**
  49415. * Returns the string "SpotLight".
  49416. * @returns the class name
  49417. */
  49418. getClassName(): string;
  49419. /**
  49420. * Returns the integer 2.
  49421. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49422. */
  49423. getTypeID(): number;
  49424. /**
  49425. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49426. */
  49427. protected _setDirection(value: Vector3): void;
  49428. /**
  49429. * Overrides the position setter to recompute the projection texture view light Matrix.
  49430. */
  49431. protected _setPosition(value: Vector3): void;
  49432. /**
  49433. * 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.
  49434. * Returns the SpotLight.
  49435. */
  49436. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49437. protected _computeProjectionTextureViewLightMatrix(): void;
  49438. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49439. /**
  49440. * Main function for light texture projection matrix computing.
  49441. */
  49442. protected _computeProjectionTextureMatrix(): void;
  49443. protected _buildUniformLayout(): void;
  49444. private _computeAngleValues;
  49445. /**
  49446. * Sets the passed Effect "effect" with the Light textures.
  49447. * @param effect The effect to update
  49448. * @param lightIndex The index of the light in the effect to update
  49449. * @returns The light
  49450. */
  49451. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49452. /**
  49453. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49454. * @param effect The effect to update
  49455. * @param lightIndex The index of the light in the effect to update
  49456. * @returns The spot light
  49457. */
  49458. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49459. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49460. /**
  49461. * Disposes the light and the associated resources.
  49462. */
  49463. dispose(): void;
  49464. /**
  49465. * Prepares the list of defines specific to the light type.
  49466. * @param defines the list of defines
  49467. * @param lightIndex defines the index of the light for the effect
  49468. */
  49469. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49470. }
  49471. }
  49472. declare module BABYLON {
  49473. /**
  49474. * Gizmo that enables viewing a light
  49475. */
  49476. export class LightGizmo extends Gizmo {
  49477. private _lightMesh;
  49478. private _material;
  49479. private _cachedPosition;
  49480. private _cachedForward;
  49481. private _attachedMeshParent;
  49482. /**
  49483. * Creates a LightGizmo
  49484. * @param gizmoLayer The utility layer the gizmo will be added to
  49485. */
  49486. constructor(gizmoLayer?: UtilityLayerRenderer);
  49487. private _light;
  49488. /**
  49489. * The light that the gizmo is attached to
  49490. */
  49491. set light(light: Nullable<Light>);
  49492. get light(): Nullable<Light>;
  49493. /**
  49494. * Gets the material used to render the light gizmo
  49495. */
  49496. get material(): StandardMaterial;
  49497. /**
  49498. * @hidden
  49499. * Updates the gizmo to match the attached mesh's position/rotation
  49500. */
  49501. protected _update(): void;
  49502. private static _Scale;
  49503. /**
  49504. * Creates the lines for a light mesh
  49505. */
  49506. private static _CreateLightLines;
  49507. /**
  49508. * Disposes of the light gizmo
  49509. */
  49510. dispose(): void;
  49511. private static _CreateHemisphericLightMesh;
  49512. private static _CreatePointLightMesh;
  49513. private static _CreateSpotLightMesh;
  49514. private static _CreateDirectionalLightMesh;
  49515. }
  49516. }
  49517. declare module BABYLON {
  49518. /** @hidden */
  49519. export var backgroundFragmentDeclaration: {
  49520. name: string;
  49521. shader: string;
  49522. };
  49523. }
  49524. declare module BABYLON {
  49525. /** @hidden */
  49526. export var backgroundUboDeclaration: {
  49527. name: string;
  49528. shader: string;
  49529. };
  49530. }
  49531. declare module BABYLON {
  49532. /** @hidden */
  49533. export var backgroundPixelShader: {
  49534. name: string;
  49535. shader: string;
  49536. };
  49537. }
  49538. declare module BABYLON {
  49539. /** @hidden */
  49540. export var backgroundVertexDeclaration: {
  49541. name: string;
  49542. shader: string;
  49543. };
  49544. }
  49545. declare module BABYLON {
  49546. /** @hidden */
  49547. export var backgroundVertexShader: {
  49548. name: string;
  49549. shader: string;
  49550. };
  49551. }
  49552. declare module BABYLON {
  49553. /**
  49554. * Background material used to create an efficient environement around your scene.
  49555. */
  49556. export class BackgroundMaterial extends PushMaterial {
  49557. /**
  49558. * Standard reflectance value at parallel view angle.
  49559. */
  49560. static StandardReflectance0: number;
  49561. /**
  49562. * Standard reflectance value at grazing angle.
  49563. */
  49564. static StandardReflectance90: number;
  49565. protected _primaryColor: Color3;
  49566. /**
  49567. * Key light Color (multiply against the environement texture)
  49568. */
  49569. primaryColor: Color3;
  49570. protected __perceptualColor: Nullable<Color3>;
  49571. /**
  49572. * Experimental Internal Use Only.
  49573. *
  49574. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49575. * This acts as a helper to set the primary color to a more "human friendly" value.
  49576. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49577. * output color as close as possible from the chosen value.
  49578. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49579. * part of lighting setup.)
  49580. */
  49581. get _perceptualColor(): Nullable<Color3>;
  49582. set _perceptualColor(value: Nullable<Color3>);
  49583. protected _primaryColorShadowLevel: float;
  49584. /**
  49585. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49586. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49587. */
  49588. get primaryColorShadowLevel(): float;
  49589. set primaryColorShadowLevel(value: float);
  49590. protected _primaryColorHighlightLevel: float;
  49591. /**
  49592. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49593. * The primary color is used at the level chosen to define what the white area would look.
  49594. */
  49595. get primaryColorHighlightLevel(): float;
  49596. set primaryColorHighlightLevel(value: float);
  49597. protected _reflectionTexture: Nullable<BaseTexture>;
  49598. /**
  49599. * Reflection Texture used in the material.
  49600. * Should be author in a specific way for the best result (refer to the documentation).
  49601. */
  49602. reflectionTexture: Nullable<BaseTexture>;
  49603. protected _reflectionBlur: float;
  49604. /**
  49605. * Reflection Texture level of blur.
  49606. *
  49607. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49608. * texture twice.
  49609. */
  49610. reflectionBlur: float;
  49611. protected _diffuseTexture: Nullable<BaseTexture>;
  49612. /**
  49613. * Diffuse Texture used in the material.
  49614. * Should be author in a specific way for the best result (refer to the documentation).
  49615. */
  49616. diffuseTexture: Nullable<BaseTexture>;
  49617. protected _shadowLights: Nullable<IShadowLight[]>;
  49618. /**
  49619. * Specify the list of lights casting shadow on the material.
  49620. * All scene shadow lights will be included if null.
  49621. */
  49622. shadowLights: Nullable<IShadowLight[]>;
  49623. protected _shadowLevel: float;
  49624. /**
  49625. * Helps adjusting the shadow to a softer level if required.
  49626. * 0 means black shadows and 1 means no shadows.
  49627. */
  49628. shadowLevel: float;
  49629. protected _sceneCenter: Vector3;
  49630. /**
  49631. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49632. * It is usually zero but might be interesting to modify according to your setup.
  49633. */
  49634. sceneCenter: Vector3;
  49635. protected _opacityFresnel: boolean;
  49636. /**
  49637. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49638. * This helps ensuring a nice transition when the camera goes under the ground.
  49639. */
  49640. opacityFresnel: boolean;
  49641. protected _reflectionFresnel: boolean;
  49642. /**
  49643. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49644. * This helps adding a mirror texture on the ground.
  49645. */
  49646. reflectionFresnel: boolean;
  49647. protected _reflectionFalloffDistance: number;
  49648. /**
  49649. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49650. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49651. */
  49652. reflectionFalloffDistance: number;
  49653. protected _reflectionAmount: number;
  49654. /**
  49655. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49656. */
  49657. reflectionAmount: number;
  49658. protected _reflectionReflectance0: number;
  49659. /**
  49660. * This specifies the weight of the reflection at grazing angle.
  49661. */
  49662. reflectionReflectance0: number;
  49663. protected _reflectionReflectance90: number;
  49664. /**
  49665. * This specifies the weight of the reflection at a perpendicular point of view.
  49666. */
  49667. reflectionReflectance90: number;
  49668. /**
  49669. * Sets the reflection reflectance fresnel values according to the default standard
  49670. * empirically know to work well :-)
  49671. */
  49672. set reflectionStandardFresnelWeight(value: number);
  49673. protected _useRGBColor: boolean;
  49674. /**
  49675. * Helps to directly use the maps channels instead of their level.
  49676. */
  49677. useRGBColor: boolean;
  49678. protected _enableNoise: boolean;
  49679. /**
  49680. * This helps reducing the banding effect that could occur on the background.
  49681. */
  49682. enableNoise: boolean;
  49683. /**
  49684. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49685. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49686. * Recommended to be keep at 1.0 except for special cases.
  49687. */
  49688. get fovMultiplier(): number;
  49689. set fovMultiplier(value: number);
  49690. private _fovMultiplier;
  49691. /**
  49692. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49693. */
  49694. useEquirectangularFOV: boolean;
  49695. private _maxSimultaneousLights;
  49696. /**
  49697. * Number of Simultaneous lights allowed on the material.
  49698. */
  49699. maxSimultaneousLights: int;
  49700. /**
  49701. * Default configuration related to image processing available in the Background Material.
  49702. */
  49703. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49704. /**
  49705. * Keep track of the image processing observer to allow dispose and replace.
  49706. */
  49707. private _imageProcessingObserver;
  49708. /**
  49709. * Attaches a new image processing configuration to the PBR Material.
  49710. * @param configuration (if null the scene configuration will be use)
  49711. */
  49712. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49713. /**
  49714. * Gets the image processing configuration used either in this material.
  49715. */
  49716. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49717. /**
  49718. * Sets the Default image processing configuration used either in the this material.
  49719. *
  49720. * If sets to null, the scene one is in use.
  49721. */
  49722. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49723. /**
  49724. * Gets wether the color curves effect is enabled.
  49725. */
  49726. get cameraColorCurvesEnabled(): boolean;
  49727. /**
  49728. * Sets wether the color curves effect is enabled.
  49729. */
  49730. set cameraColorCurvesEnabled(value: boolean);
  49731. /**
  49732. * Gets wether the color grading effect is enabled.
  49733. */
  49734. get cameraColorGradingEnabled(): boolean;
  49735. /**
  49736. * Gets wether the color grading effect is enabled.
  49737. */
  49738. set cameraColorGradingEnabled(value: boolean);
  49739. /**
  49740. * Gets wether tonemapping is enabled or not.
  49741. */
  49742. get cameraToneMappingEnabled(): boolean;
  49743. /**
  49744. * Sets wether tonemapping is enabled or not
  49745. */
  49746. set cameraToneMappingEnabled(value: boolean);
  49747. /**
  49748. * The camera exposure used on this material.
  49749. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49750. * This corresponds to a photographic exposure.
  49751. */
  49752. get cameraExposure(): float;
  49753. /**
  49754. * The camera exposure used on this material.
  49755. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49756. * This corresponds to a photographic exposure.
  49757. */
  49758. set cameraExposure(value: float);
  49759. /**
  49760. * Gets The camera contrast used on this material.
  49761. */
  49762. get cameraContrast(): float;
  49763. /**
  49764. * Sets The camera contrast used on this material.
  49765. */
  49766. set cameraContrast(value: float);
  49767. /**
  49768. * Gets the Color Grading 2D Lookup Texture.
  49769. */
  49770. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49771. /**
  49772. * Sets the Color Grading 2D Lookup Texture.
  49773. */
  49774. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49775. /**
  49776. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49777. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49778. * 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;
  49779. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49780. */
  49781. get cameraColorCurves(): Nullable<ColorCurves>;
  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. set cameraColorCurves(value: Nullable<ColorCurves>);
  49789. /**
  49790. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49791. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49792. */
  49793. switchToBGR: boolean;
  49794. private _renderTargets;
  49795. private _reflectionControls;
  49796. private _white;
  49797. private _primaryShadowColor;
  49798. private _primaryHighlightColor;
  49799. /**
  49800. * Instantiates a Background Material in the given scene
  49801. * @param name The friendly name of the material
  49802. * @param scene The scene to add the material to
  49803. */
  49804. constructor(name: string, scene: Scene);
  49805. /**
  49806. * Gets a boolean indicating that current material needs to register RTT
  49807. */
  49808. get hasRenderTargetTextures(): boolean;
  49809. /**
  49810. * The entire material has been created in order to prevent overdraw.
  49811. * @returns false
  49812. */
  49813. needAlphaTesting(): boolean;
  49814. /**
  49815. * The entire material has been created in order to prevent overdraw.
  49816. * @returns true if blending is enable
  49817. */
  49818. needAlphaBlending(): boolean;
  49819. /**
  49820. * Checks wether the material is ready to be rendered for a given mesh.
  49821. * @param mesh The mesh to render
  49822. * @param subMesh The submesh to check against
  49823. * @param useInstances Specify wether or not the material is used with instances
  49824. * @returns true if all the dependencies are ready (Textures, Effects...)
  49825. */
  49826. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49827. /**
  49828. * Compute the primary color according to the chosen perceptual color.
  49829. */
  49830. private _computePrimaryColorFromPerceptualColor;
  49831. /**
  49832. * Compute the highlights and shadow colors according to their chosen levels.
  49833. */
  49834. private _computePrimaryColors;
  49835. /**
  49836. * Build the uniform buffer used in the material.
  49837. */
  49838. buildUniformLayout(): void;
  49839. /**
  49840. * Unbind the material.
  49841. */
  49842. unbind(): void;
  49843. /**
  49844. * Bind only the world matrix to the material.
  49845. * @param world The world matrix to bind.
  49846. */
  49847. bindOnlyWorldMatrix(world: Matrix): void;
  49848. /**
  49849. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49850. * @param world The world matrix to bind.
  49851. * @param subMesh The submesh to bind for.
  49852. */
  49853. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49854. /**
  49855. * Checks to see if a texture is used in the material.
  49856. * @param texture - Base texture to use.
  49857. * @returns - Boolean specifying if a texture is used in the material.
  49858. */
  49859. hasTexture(texture: BaseTexture): boolean;
  49860. /**
  49861. * Dispose the material.
  49862. * @param forceDisposeEffect Force disposal of the associated effect.
  49863. * @param forceDisposeTextures Force disposal of the associated textures.
  49864. */
  49865. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49866. /**
  49867. * Clones the material.
  49868. * @param name The cloned name.
  49869. * @returns The cloned material.
  49870. */
  49871. clone(name: string): BackgroundMaterial;
  49872. /**
  49873. * Serializes the current material to its JSON representation.
  49874. * @returns The JSON representation.
  49875. */
  49876. serialize(): any;
  49877. /**
  49878. * Gets the class name of the material
  49879. * @returns "BackgroundMaterial"
  49880. */
  49881. getClassName(): string;
  49882. /**
  49883. * Parse a JSON input to create back a background material.
  49884. * @param source The JSON data to parse
  49885. * @param scene The scene to create the parsed material in
  49886. * @param rootUrl The root url of the assets the material depends upon
  49887. * @returns the instantiated BackgroundMaterial.
  49888. */
  49889. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49890. }
  49891. }
  49892. declare module BABYLON {
  49893. /**
  49894. * Represents the different options available during the creation of
  49895. * a Environment helper.
  49896. *
  49897. * This can control the default ground, skybox and image processing setup of your scene.
  49898. */
  49899. export interface IEnvironmentHelperOptions {
  49900. /**
  49901. * Specifies whether or not to create a ground.
  49902. * True by default.
  49903. */
  49904. createGround: boolean;
  49905. /**
  49906. * Specifies the ground size.
  49907. * 15 by default.
  49908. */
  49909. groundSize: number;
  49910. /**
  49911. * The texture used on the ground for the main color.
  49912. * Comes from the BabylonJS CDN by default.
  49913. *
  49914. * Remarks: Can be either a texture or a url.
  49915. */
  49916. groundTexture: string | BaseTexture;
  49917. /**
  49918. * The color mixed in the ground texture by default.
  49919. * BabylonJS clearColor by default.
  49920. */
  49921. groundColor: Color3;
  49922. /**
  49923. * Specifies the ground opacity.
  49924. * 1 by default.
  49925. */
  49926. groundOpacity: number;
  49927. /**
  49928. * Enables the ground to receive shadows.
  49929. * True by default.
  49930. */
  49931. enableGroundShadow: boolean;
  49932. /**
  49933. * Helps preventing the shadow to be fully black on the ground.
  49934. * 0.5 by default.
  49935. */
  49936. groundShadowLevel: number;
  49937. /**
  49938. * Creates a mirror texture attach to the ground.
  49939. * false by default.
  49940. */
  49941. enableGroundMirror: boolean;
  49942. /**
  49943. * Specifies the ground mirror size ratio.
  49944. * 0.3 by default as the default kernel is 64.
  49945. */
  49946. groundMirrorSizeRatio: number;
  49947. /**
  49948. * Specifies the ground mirror blur kernel size.
  49949. * 64 by default.
  49950. */
  49951. groundMirrorBlurKernel: number;
  49952. /**
  49953. * Specifies the ground mirror visibility amount.
  49954. * 1 by default
  49955. */
  49956. groundMirrorAmount: number;
  49957. /**
  49958. * Specifies the ground mirror reflectance weight.
  49959. * This uses the standard weight of the background material to setup the fresnel effect
  49960. * of the mirror.
  49961. * 1 by default.
  49962. */
  49963. groundMirrorFresnelWeight: number;
  49964. /**
  49965. * Specifies the ground mirror Falloff distance.
  49966. * This can helps reducing the size of the reflection.
  49967. * 0 by Default.
  49968. */
  49969. groundMirrorFallOffDistance: number;
  49970. /**
  49971. * Specifies the ground mirror texture type.
  49972. * Unsigned Int by Default.
  49973. */
  49974. groundMirrorTextureType: number;
  49975. /**
  49976. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49977. * the shown objects.
  49978. */
  49979. groundYBias: number;
  49980. /**
  49981. * Specifies whether or not to create a skybox.
  49982. * True by default.
  49983. */
  49984. createSkybox: boolean;
  49985. /**
  49986. * Specifies the skybox size.
  49987. * 20 by default.
  49988. */
  49989. skyboxSize: number;
  49990. /**
  49991. * The texture used on the skybox for the main color.
  49992. * Comes from the BabylonJS CDN by default.
  49993. *
  49994. * Remarks: Can be either a texture or a url.
  49995. */
  49996. skyboxTexture: string | BaseTexture;
  49997. /**
  49998. * The color mixed in the skybox texture by default.
  49999. * BabylonJS clearColor by default.
  50000. */
  50001. skyboxColor: Color3;
  50002. /**
  50003. * The background rotation around the Y axis of the scene.
  50004. * This helps aligning the key lights of your scene with the background.
  50005. * 0 by default.
  50006. */
  50007. backgroundYRotation: number;
  50008. /**
  50009. * Compute automatically the size of the elements to best fit with the scene.
  50010. */
  50011. sizeAuto: boolean;
  50012. /**
  50013. * Default position of the rootMesh if autoSize is not true.
  50014. */
  50015. rootPosition: Vector3;
  50016. /**
  50017. * Sets up the image processing in the scene.
  50018. * true by default.
  50019. */
  50020. setupImageProcessing: boolean;
  50021. /**
  50022. * The texture used as your environment texture in the scene.
  50023. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50024. *
  50025. * Remarks: Can be either a texture or a url.
  50026. */
  50027. environmentTexture: string | BaseTexture;
  50028. /**
  50029. * The value of the exposure to apply to the scene.
  50030. * 0.6 by default if setupImageProcessing is true.
  50031. */
  50032. cameraExposure: number;
  50033. /**
  50034. * The value of the contrast to apply to the scene.
  50035. * 1.6 by default if setupImageProcessing is true.
  50036. */
  50037. cameraContrast: number;
  50038. /**
  50039. * Specifies whether or not tonemapping should be enabled in the scene.
  50040. * true by default if setupImageProcessing is true.
  50041. */
  50042. toneMappingEnabled: boolean;
  50043. }
  50044. /**
  50045. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50046. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50047. * It also helps with the default setup of your imageProcessing configuration.
  50048. */
  50049. export class EnvironmentHelper {
  50050. /**
  50051. * Default ground texture URL.
  50052. */
  50053. private static _groundTextureCDNUrl;
  50054. /**
  50055. * Default skybox texture URL.
  50056. */
  50057. private static _skyboxTextureCDNUrl;
  50058. /**
  50059. * Default environment texture URL.
  50060. */
  50061. private static _environmentTextureCDNUrl;
  50062. /**
  50063. * Creates the default options for the helper.
  50064. */
  50065. private static _getDefaultOptions;
  50066. private _rootMesh;
  50067. /**
  50068. * Gets the root mesh created by the helper.
  50069. */
  50070. get rootMesh(): Mesh;
  50071. private _skybox;
  50072. /**
  50073. * Gets the skybox created by the helper.
  50074. */
  50075. get skybox(): Nullable<Mesh>;
  50076. private _skyboxTexture;
  50077. /**
  50078. * Gets the skybox texture created by the helper.
  50079. */
  50080. get skyboxTexture(): Nullable<BaseTexture>;
  50081. private _skyboxMaterial;
  50082. /**
  50083. * Gets the skybox material created by the helper.
  50084. */
  50085. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50086. private _ground;
  50087. /**
  50088. * Gets the ground mesh created by the helper.
  50089. */
  50090. get ground(): Nullable<Mesh>;
  50091. private _groundTexture;
  50092. /**
  50093. * Gets the ground texture created by the helper.
  50094. */
  50095. get groundTexture(): Nullable<BaseTexture>;
  50096. private _groundMirror;
  50097. /**
  50098. * Gets the ground mirror created by the helper.
  50099. */
  50100. get groundMirror(): Nullable<MirrorTexture>;
  50101. /**
  50102. * Gets the ground mirror render list to helps pushing the meshes
  50103. * you wish in the ground reflection.
  50104. */
  50105. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50106. private _groundMaterial;
  50107. /**
  50108. * Gets the ground material created by the helper.
  50109. */
  50110. get groundMaterial(): Nullable<BackgroundMaterial>;
  50111. /**
  50112. * Stores the creation options.
  50113. */
  50114. private readonly _scene;
  50115. private _options;
  50116. /**
  50117. * This observable will be notified with any error during the creation of the environment,
  50118. * mainly texture creation errors.
  50119. */
  50120. onErrorObservable: Observable<{
  50121. message?: string;
  50122. exception?: any;
  50123. }>;
  50124. /**
  50125. * constructor
  50126. * @param options Defines the options we want to customize the helper
  50127. * @param scene The scene to add the material to
  50128. */
  50129. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50130. /**
  50131. * Updates the background according to the new options
  50132. * @param options
  50133. */
  50134. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50135. /**
  50136. * Sets the primary color of all the available elements.
  50137. * @param color the main color to affect to the ground and the background
  50138. */
  50139. setMainColor(color: Color3): void;
  50140. /**
  50141. * Setup the image processing according to the specified options.
  50142. */
  50143. private _setupImageProcessing;
  50144. /**
  50145. * Setup the environment texture according to the specified options.
  50146. */
  50147. private _setupEnvironmentTexture;
  50148. /**
  50149. * Setup the background according to the specified options.
  50150. */
  50151. private _setupBackground;
  50152. /**
  50153. * Get the scene sizes according to the setup.
  50154. */
  50155. private _getSceneSize;
  50156. /**
  50157. * Setup the ground according to the specified options.
  50158. */
  50159. private _setupGround;
  50160. /**
  50161. * Setup the ground material according to the specified options.
  50162. */
  50163. private _setupGroundMaterial;
  50164. /**
  50165. * Setup the ground diffuse texture according to the specified options.
  50166. */
  50167. private _setupGroundDiffuseTexture;
  50168. /**
  50169. * Setup the ground mirror texture according to the specified options.
  50170. */
  50171. private _setupGroundMirrorTexture;
  50172. /**
  50173. * Setup the ground to receive the mirror texture.
  50174. */
  50175. private _setupMirrorInGroundMaterial;
  50176. /**
  50177. * Setup the skybox according to the specified options.
  50178. */
  50179. private _setupSkybox;
  50180. /**
  50181. * Setup the skybox material according to the specified options.
  50182. */
  50183. private _setupSkyboxMaterial;
  50184. /**
  50185. * Setup the skybox reflection texture according to the specified options.
  50186. */
  50187. private _setupSkyboxReflectionTexture;
  50188. private _errorHandler;
  50189. /**
  50190. * Dispose all the elements created by the Helper.
  50191. */
  50192. dispose(): void;
  50193. }
  50194. }
  50195. declare module BABYLON {
  50196. /**
  50197. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50198. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50199. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50200. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50201. */
  50202. export class PhotoDome extends TransformNode {
  50203. /**
  50204. * Define the image as a Monoscopic panoramic 360 image.
  50205. */
  50206. static readonly MODE_MONOSCOPIC: number;
  50207. /**
  50208. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50209. */
  50210. static readonly MODE_TOPBOTTOM: number;
  50211. /**
  50212. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50213. */
  50214. static readonly MODE_SIDEBYSIDE: number;
  50215. private _useDirectMapping;
  50216. /**
  50217. * The texture being displayed on the sphere
  50218. */
  50219. protected _photoTexture: Texture;
  50220. /**
  50221. * Gets or sets the texture being displayed on the sphere
  50222. */
  50223. get photoTexture(): Texture;
  50224. set photoTexture(value: Texture);
  50225. /**
  50226. * Observable raised when an error occured while loading the 360 image
  50227. */
  50228. onLoadErrorObservable: Observable<string>;
  50229. /**
  50230. * The skybox material
  50231. */
  50232. protected _material: BackgroundMaterial;
  50233. /**
  50234. * The surface used for the skybox
  50235. */
  50236. protected _mesh: Mesh;
  50237. /**
  50238. * Gets the mesh used for the skybox.
  50239. */
  50240. get mesh(): Mesh;
  50241. /**
  50242. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50243. * Also see the options.resolution property.
  50244. */
  50245. get fovMultiplier(): number;
  50246. set fovMultiplier(value: number);
  50247. private _imageMode;
  50248. /**
  50249. * Gets or set the current video mode for the video. It can be:
  50250. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50251. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50252. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50253. */
  50254. get imageMode(): number;
  50255. set imageMode(value: number);
  50256. /**
  50257. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50258. * @param name Element's name, child elements will append suffixes for their own names.
  50259. * @param urlsOfPhoto defines the url of the photo to display
  50260. * @param options defines an object containing optional or exposed sub element properties
  50261. * @param onError defines a callback called when an error occured while loading the texture
  50262. */
  50263. constructor(name: string, urlOfPhoto: string, options: {
  50264. resolution?: number;
  50265. size?: number;
  50266. useDirectMapping?: boolean;
  50267. faceForward?: boolean;
  50268. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50269. private _onBeforeCameraRenderObserver;
  50270. private _changeImageMode;
  50271. /**
  50272. * Releases resources associated with this node.
  50273. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50274. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50275. */
  50276. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50277. }
  50278. }
  50279. declare module BABYLON {
  50280. /**
  50281. * Class used to host RGBD texture specific utilities
  50282. */
  50283. export class RGBDTextureTools {
  50284. /**
  50285. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50286. * @param texture the texture to expand.
  50287. */
  50288. static ExpandRGBDTexture(texture: Texture): void;
  50289. }
  50290. }
  50291. declare module BABYLON {
  50292. /**
  50293. * Class used to host texture specific utilities
  50294. */
  50295. export class BRDFTextureTools {
  50296. /**
  50297. * Prevents texture cache collision
  50298. */
  50299. private static _instanceNumber;
  50300. /**
  50301. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50302. * @param scene defines the hosting scene
  50303. * @returns the environment BRDF texture
  50304. */
  50305. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50306. private static _environmentBRDFBase64Texture;
  50307. }
  50308. }
  50309. declare module BABYLON {
  50310. /**
  50311. * @hidden
  50312. */
  50313. export interface IMaterialClearCoatDefines {
  50314. CLEARCOAT: boolean;
  50315. CLEARCOAT_DEFAULTIOR: boolean;
  50316. CLEARCOAT_TEXTURE: boolean;
  50317. CLEARCOAT_TEXTUREDIRECTUV: number;
  50318. CLEARCOAT_BUMP: boolean;
  50319. CLEARCOAT_BUMPDIRECTUV: number;
  50320. CLEARCOAT_TINT: boolean;
  50321. CLEARCOAT_TINT_TEXTURE: boolean;
  50322. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50323. /** @hidden */
  50324. _areTexturesDirty: boolean;
  50325. }
  50326. /**
  50327. * Define the code related to the clear coat parameters of the pbr material.
  50328. */
  50329. export class PBRClearCoatConfiguration {
  50330. /**
  50331. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50332. * The default fits with a polyurethane material.
  50333. */
  50334. private static readonly _DefaultIndexOfRefraction;
  50335. private _isEnabled;
  50336. /**
  50337. * Defines if the clear coat is enabled in the material.
  50338. */
  50339. isEnabled: boolean;
  50340. /**
  50341. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50342. */
  50343. intensity: number;
  50344. /**
  50345. * Defines the clear coat layer roughness.
  50346. */
  50347. roughness: number;
  50348. private _indexOfRefraction;
  50349. /**
  50350. * Defines the index of refraction of the clear coat.
  50351. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50352. * The default fits with a polyurethane material.
  50353. * Changing the default value is more performance intensive.
  50354. */
  50355. indexOfRefraction: number;
  50356. private _texture;
  50357. /**
  50358. * Stores the clear coat values in a texture.
  50359. */
  50360. texture: Nullable<BaseTexture>;
  50361. private _bumpTexture;
  50362. /**
  50363. * Define the clear coat specific bump texture.
  50364. */
  50365. bumpTexture: Nullable<BaseTexture>;
  50366. private _isTintEnabled;
  50367. /**
  50368. * Defines if the clear coat tint is enabled in the material.
  50369. */
  50370. isTintEnabled: boolean;
  50371. /**
  50372. * Defines the clear coat tint of the material.
  50373. * This is only use if tint is enabled
  50374. */
  50375. tintColor: Color3;
  50376. /**
  50377. * Defines the distance at which the tint color should be found in the
  50378. * clear coat media.
  50379. * This is only use if tint is enabled
  50380. */
  50381. tintColorAtDistance: number;
  50382. /**
  50383. * Defines the clear coat layer thickness.
  50384. * This is only use if tint is enabled
  50385. */
  50386. tintThickness: number;
  50387. private _tintTexture;
  50388. /**
  50389. * Stores the clear tint values in a texture.
  50390. * rgb is tint
  50391. * a is a thickness factor
  50392. */
  50393. tintTexture: Nullable<BaseTexture>;
  50394. /** @hidden */
  50395. private _internalMarkAllSubMeshesAsTexturesDirty;
  50396. /** @hidden */
  50397. _markAllSubMeshesAsTexturesDirty(): void;
  50398. /**
  50399. * Instantiate a new istance of clear coat configuration.
  50400. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50401. */
  50402. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50403. /**
  50404. * Gets wehter the submesh is ready to be used or not.
  50405. * @param defines the list of "defines" to update.
  50406. * @param scene defines the scene the material belongs to.
  50407. * @param engine defines the engine the material belongs to.
  50408. * @param disableBumpMap defines wether the material disables bump or not.
  50409. * @returns - boolean indicating that the submesh is ready or not.
  50410. */
  50411. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50412. /**
  50413. * Checks to see if a texture is used in the material.
  50414. * @param defines the list of "defines" to update.
  50415. * @param scene defines the scene to the material belongs to.
  50416. */
  50417. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50418. /**
  50419. * Binds the material data.
  50420. * @param uniformBuffer defines the Uniform buffer to fill in.
  50421. * @param scene defines the scene the material belongs to.
  50422. * @param engine defines the engine the material belongs to.
  50423. * @param disableBumpMap defines wether the material disables bump or not.
  50424. * @param isFrozen defines wether the material is frozen or not.
  50425. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50426. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50427. */
  50428. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50429. /**
  50430. * Checks to see if a texture is used in the material.
  50431. * @param texture - Base texture to use.
  50432. * @returns - Boolean specifying if a texture is used in the material.
  50433. */
  50434. hasTexture(texture: BaseTexture): boolean;
  50435. /**
  50436. * Returns an array of the actively used textures.
  50437. * @param activeTextures Array of BaseTextures
  50438. */
  50439. getActiveTextures(activeTextures: BaseTexture[]): void;
  50440. /**
  50441. * Returns the animatable textures.
  50442. * @param animatables Array of animatable textures.
  50443. */
  50444. getAnimatables(animatables: IAnimatable[]): void;
  50445. /**
  50446. * Disposes the resources of the material.
  50447. * @param forceDisposeTextures - Forces the disposal of all textures.
  50448. */
  50449. dispose(forceDisposeTextures?: boolean): void;
  50450. /**
  50451. * Get the current class name of the texture useful for serialization or dynamic coding.
  50452. * @returns "PBRClearCoatConfiguration"
  50453. */
  50454. getClassName(): string;
  50455. /**
  50456. * Add fallbacks to the effect fallbacks list.
  50457. * @param defines defines the Base texture to use.
  50458. * @param fallbacks defines the current fallback list.
  50459. * @param currentRank defines the current fallback rank.
  50460. * @returns the new fallback rank.
  50461. */
  50462. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50463. /**
  50464. * Add the required uniforms to the current list.
  50465. * @param uniforms defines the current uniform list.
  50466. */
  50467. static AddUniforms(uniforms: string[]): void;
  50468. /**
  50469. * Add the required samplers to the current list.
  50470. * @param samplers defines the current sampler list.
  50471. */
  50472. static AddSamplers(samplers: string[]): void;
  50473. /**
  50474. * Add the required uniforms to the current buffer.
  50475. * @param uniformBuffer defines the current uniform buffer.
  50476. */
  50477. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50478. /**
  50479. * Makes a duplicate of the current configuration into another one.
  50480. * @param clearCoatConfiguration define the config where to copy the info
  50481. */
  50482. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50483. /**
  50484. * Serializes this clear coat configuration.
  50485. * @returns - An object with the serialized config.
  50486. */
  50487. serialize(): any;
  50488. /**
  50489. * Parses a anisotropy Configuration from a serialized object.
  50490. * @param source - Serialized object.
  50491. * @param scene Defines the scene we are parsing for
  50492. * @param rootUrl Defines the rootUrl to load from
  50493. */
  50494. parse(source: any, scene: Scene, rootUrl: string): void;
  50495. }
  50496. }
  50497. declare module BABYLON {
  50498. /**
  50499. * @hidden
  50500. */
  50501. export interface IMaterialAnisotropicDefines {
  50502. ANISOTROPIC: boolean;
  50503. ANISOTROPIC_TEXTURE: boolean;
  50504. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50505. MAINUV1: boolean;
  50506. _areTexturesDirty: boolean;
  50507. _needUVs: boolean;
  50508. }
  50509. /**
  50510. * Define the code related to the anisotropic parameters of the pbr material.
  50511. */
  50512. export class PBRAnisotropicConfiguration {
  50513. private _isEnabled;
  50514. /**
  50515. * Defines if the anisotropy is enabled in the material.
  50516. */
  50517. isEnabled: boolean;
  50518. /**
  50519. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50520. */
  50521. intensity: number;
  50522. /**
  50523. * Defines if the effect is along the tangents, bitangents or in between.
  50524. * By default, the effect is "strectching" the highlights along the tangents.
  50525. */
  50526. direction: Vector2;
  50527. private _texture;
  50528. /**
  50529. * Stores the anisotropy values in a texture.
  50530. * rg is direction (like normal from -1 to 1)
  50531. * b is a intensity
  50532. */
  50533. texture: Nullable<BaseTexture>;
  50534. /** @hidden */
  50535. private _internalMarkAllSubMeshesAsTexturesDirty;
  50536. /** @hidden */
  50537. _markAllSubMeshesAsTexturesDirty(): void;
  50538. /**
  50539. * Instantiate a new istance of anisotropy configuration.
  50540. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50541. */
  50542. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50543. /**
  50544. * Specifies that the submesh is ready to be used.
  50545. * @param defines the list of "defines" to update.
  50546. * @param scene defines the scene the material belongs to.
  50547. * @returns - boolean indicating that the submesh is ready or not.
  50548. */
  50549. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50550. /**
  50551. * Checks to see if a texture is used in the material.
  50552. * @param defines the list of "defines" to update.
  50553. * @param mesh the mesh we are preparing the defines for.
  50554. * @param scene defines the scene the material belongs to.
  50555. */
  50556. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50557. /**
  50558. * Binds the material data.
  50559. * @param uniformBuffer defines the Uniform buffer to fill in.
  50560. * @param scene defines the scene the material belongs to.
  50561. * @param isFrozen defines wether the material is frozen or not.
  50562. */
  50563. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50564. /**
  50565. * Checks to see if a texture is used in the material.
  50566. * @param texture - Base texture to use.
  50567. * @returns - Boolean specifying if a texture is used in the material.
  50568. */
  50569. hasTexture(texture: BaseTexture): boolean;
  50570. /**
  50571. * Returns an array of the actively used textures.
  50572. * @param activeTextures Array of BaseTextures
  50573. */
  50574. getActiveTextures(activeTextures: BaseTexture[]): void;
  50575. /**
  50576. * Returns the animatable textures.
  50577. * @param animatables Array of animatable textures.
  50578. */
  50579. getAnimatables(animatables: IAnimatable[]): void;
  50580. /**
  50581. * Disposes the resources of the material.
  50582. * @param forceDisposeTextures - Forces the disposal of all textures.
  50583. */
  50584. dispose(forceDisposeTextures?: boolean): void;
  50585. /**
  50586. * Get the current class name of the texture useful for serialization or dynamic coding.
  50587. * @returns "PBRAnisotropicConfiguration"
  50588. */
  50589. getClassName(): string;
  50590. /**
  50591. * Add fallbacks to the effect fallbacks list.
  50592. * @param defines defines the Base texture to use.
  50593. * @param fallbacks defines the current fallback list.
  50594. * @param currentRank defines the current fallback rank.
  50595. * @returns the new fallback rank.
  50596. */
  50597. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50598. /**
  50599. * Add the required uniforms to the current list.
  50600. * @param uniforms defines the current uniform list.
  50601. */
  50602. static AddUniforms(uniforms: string[]): void;
  50603. /**
  50604. * Add the required uniforms to the current buffer.
  50605. * @param uniformBuffer defines the current uniform buffer.
  50606. */
  50607. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50608. /**
  50609. * Add the required samplers to the current list.
  50610. * @param samplers defines the current sampler list.
  50611. */
  50612. static AddSamplers(samplers: string[]): void;
  50613. /**
  50614. * Makes a duplicate of the current configuration into another one.
  50615. * @param anisotropicConfiguration define the config where to copy the info
  50616. */
  50617. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50618. /**
  50619. * Serializes this anisotropy configuration.
  50620. * @returns - An object with the serialized config.
  50621. */
  50622. serialize(): any;
  50623. /**
  50624. * Parses a anisotropy Configuration from a serialized object.
  50625. * @param source - Serialized object.
  50626. * @param scene Defines the scene we are parsing for
  50627. * @param rootUrl Defines the rootUrl to load from
  50628. */
  50629. parse(source: any, scene: Scene, rootUrl: string): void;
  50630. }
  50631. }
  50632. declare module BABYLON {
  50633. /**
  50634. * @hidden
  50635. */
  50636. export interface IMaterialBRDFDefines {
  50637. BRDF_V_HEIGHT_CORRELATED: boolean;
  50638. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50639. SPHERICAL_HARMONICS: boolean;
  50640. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50641. /** @hidden */
  50642. _areMiscDirty: boolean;
  50643. }
  50644. /**
  50645. * Define the code related to the BRDF parameters of the pbr material.
  50646. */
  50647. export class PBRBRDFConfiguration {
  50648. /**
  50649. * Default value used for the energy conservation.
  50650. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50651. */
  50652. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50653. /**
  50654. * Default value used for the Smith Visibility Height Correlated mode.
  50655. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50656. */
  50657. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50658. /**
  50659. * Default value used for the IBL diffuse part.
  50660. * This can help switching back to the polynomials mode globally which is a tiny bit
  50661. * less GPU intensive at the drawback of a lower quality.
  50662. */
  50663. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50664. /**
  50665. * Default value used for activating energy conservation for the specular workflow.
  50666. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50667. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50668. */
  50669. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50670. private _useEnergyConservation;
  50671. /**
  50672. * Defines if the material uses energy conservation.
  50673. */
  50674. useEnergyConservation: boolean;
  50675. private _useSmithVisibilityHeightCorrelated;
  50676. /**
  50677. * LEGACY Mode set to false
  50678. * Defines if the material uses height smith correlated visibility term.
  50679. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50680. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50681. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50682. * Not relying on height correlated will also disable energy conservation.
  50683. */
  50684. useSmithVisibilityHeightCorrelated: boolean;
  50685. private _useSphericalHarmonics;
  50686. /**
  50687. * LEGACY Mode set to false
  50688. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50689. * diffuse part of the IBL.
  50690. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50691. * to the ground truth.
  50692. */
  50693. useSphericalHarmonics: boolean;
  50694. private _useSpecularGlossinessInputEnergyConservation;
  50695. /**
  50696. * Defines if the material uses energy conservation, when the specular workflow is active.
  50697. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50698. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50699. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50700. */
  50701. useSpecularGlossinessInputEnergyConservation: boolean;
  50702. /** @hidden */
  50703. private _internalMarkAllSubMeshesAsMiscDirty;
  50704. /** @hidden */
  50705. _markAllSubMeshesAsMiscDirty(): void;
  50706. /**
  50707. * Instantiate a new istance of clear coat configuration.
  50708. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50709. */
  50710. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50711. /**
  50712. * Checks to see if a texture is used in the material.
  50713. * @param defines the list of "defines" to update.
  50714. */
  50715. prepareDefines(defines: IMaterialBRDFDefines): void;
  50716. /**
  50717. * Get the current class name of the texture useful for serialization or dynamic coding.
  50718. * @returns "PBRClearCoatConfiguration"
  50719. */
  50720. getClassName(): string;
  50721. /**
  50722. * Makes a duplicate of the current configuration into another one.
  50723. * @param brdfConfiguration define the config where to copy the info
  50724. */
  50725. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50726. /**
  50727. * Serializes this BRDF configuration.
  50728. * @returns - An object with the serialized config.
  50729. */
  50730. serialize(): any;
  50731. /**
  50732. * Parses a anisotropy Configuration from a serialized object.
  50733. * @param source - Serialized object.
  50734. * @param scene Defines the scene we are parsing for
  50735. * @param rootUrl Defines the rootUrl to load from
  50736. */
  50737. parse(source: any, scene: Scene, rootUrl: string): void;
  50738. }
  50739. }
  50740. declare module BABYLON {
  50741. /**
  50742. * @hidden
  50743. */
  50744. export interface IMaterialSheenDefines {
  50745. SHEEN: boolean;
  50746. SHEEN_TEXTURE: boolean;
  50747. SHEEN_TEXTUREDIRECTUV: number;
  50748. SHEEN_LINKWITHALBEDO: boolean;
  50749. SHEEN_ROUGHNESS: boolean;
  50750. SHEEN_ALBEDOSCALING: boolean;
  50751. /** @hidden */
  50752. _areTexturesDirty: boolean;
  50753. }
  50754. /**
  50755. * Define the code related to the Sheen parameters of the pbr material.
  50756. */
  50757. export class PBRSheenConfiguration {
  50758. private _isEnabled;
  50759. /**
  50760. * Defines if the material uses sheen.
  50761. */
  50762. isEnabled: boolean;
  50763. private _linkSheenWithAlbedo;
  50764. /**
  50765. * Defines if the sheen is linked to the sheen color.
  50766. */
  50767. linkSheenWithAlbedo: boolean;
  50768. /**
  50769. * Defines the sheen intensity.
  50770. */
  50771. intensity: number;
  50772. /**
  50773. * Defines the sheen color.
  50774. */
  50775. color: Color3;
  50776. private _texture;
  50777. /**
  50778. * Stores the sheen tint values in a texture.
  50779. * rgb is tint
  50780. * a is a intensity
  50781. */
  50782. texture: Nullable<BaseTexture>;
  50783. private _roughness;
  50784. /**
  50785. * Defines the sheen roughness.
  50786. * It is not taken into account if linkSheenWithAlbedo is true.
  50787. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50788. */
  50789. roughness: Nullable<number>;
  50790. private _albedoScaling;
  50791. /**
  50792. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50793. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50794. * making it easier to setup and tweak the effect
  50795. */
  50796. albedoScaling: boolean;
  50797. /** @hidden */
  50798. private _internalMarkAllSubMeshesAsTexturesDirty;
  50799. /** @hidden */
  50800. _markAllSubMeshesAsTexturesDirty(): void;
  50801. /**
  50802. * Instantiate a new istance of clear coat configuration.
  50803. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50804. */
  50805. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50806. /**
  50807. * Specifies that the submesh is ready to be used.
  50808. * @param defines the list of "defines" to update.
  50809. * @param scene defines the scene the material belongs to.
  50810. * @returns - boolean indicating that the submesh is ready or not.
  50811. */
  50812. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50813. /**
  50814. * Checks to see if a texture is used in the material.
  50815. * @param defines the list of "defines" to update.
  50816. * @param scene defines the scene the material belongs to.
  50817. */
  50818. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50819. /**
  50820. * Binds the material data.
  50821. * @param uniformBuffer defines the Uniform buffer to fill in.
  50822. * @param scene defines the scene the material belongs to.
  50823. * @param isFrozen defines wether the material is frozen or not.
  50824. */
  50825. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50826. /**
  50827. * Checks to see if a texture is used in the material.
  50828. * @param texture - Base texture to use.
  50829. * @returns - Boolean specifying if a texture is used in the material.
  50830. */
  50831. hasTexture(texture: BaseTexture): boolean;
  50832. /**
  50833. * Returns an array of the actively used textures.
  50834. * @param activeTextures Array of BaseTextures
  50835. */
  50836. getActiveTextures(activeTextures: BaseTexture[]): void;
  50837. /**
  50838. * Returns the animatable textures.
  50839. * @param animatables Array of animatable textures.
  50840. */
  50841. getAnimatables(animatables: IAnimatable[]): void;
  50842. /**
  50843. * Disposes the resources of the material.
  50844. * @param forceDisposeTextures - Forces the disposal of all textures.
  50845. */
  50846. dispose(forceDisposeTextures?: boolean): void;
  50847. /**
  50848. * Get the current class name of the texture useful for serialization or dynamic coding.
  50849. * @returns "PBRSheenConfiguration"
  50850. */
  50851. getClassName(): string;
  50852. /**
  50853. * Add fallbacks to the effect fallbacks list.
  50854. * @param defines defines the Base texture to use.
  50855. * @param fallbacks defines the current fallback list.
  50856. * @param currentRank defines the current fallback rank.
  50857. * @returns the new fallback rank.
  50858. */
  50859. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50860. /**
  50861. * Add the required uniforms to the current list.
  50862. * @param uniforms defines the current uniform list.
  50863. */
  50864. static AddUniforms(uniforms: string[]): void;
  50865. /**
  50866. * Add the required uniforms to the current buffer.
  50867. * @param uniformBuffer defines the current uniform buffer.
  50868. */
  50869. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50870. /**
  50871. * Add the required samplers to the current list.
  50872. * @param samplers defines the current sampler list.
  50873. */
  50874. static AddSamplers(samplers: string[]): void;
  50875. /**
  50876. * Makes a duplicate of the current configuration into another one.
  50877. * @param sheenConfiguration define the config where to copy the info
  50878. */
  50879. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50880. /**
  50881. * Serializes this BRDF configuration.
  50882. * @returns - An object with the serialized config.
  50883. */
  50884. serialize(): any;
  50885. /**
  50886. * Parses a anisotropy Configuration from a serialized object.
  50887. * @param source - Serialized object.
  50888. * @param scene Defines the scene we are parsing for
  50889. * @param rootUrl Defines the rootUrl to load from
  50890. */
  50891. parse(source: any, scene: Scene, rootUrl: string): void;
  50892. }
  50893. }
  50894. declare module BABYLON {
  50895. /**
  50896. * @hidden
  50897. */
  50898. export interface IMaterialSubSurfaceDefines {
  50899. SUBSURFACE: boolean;
  50900. SS_REFRACTION: boolean;
  50901. SS_TRANSLUCENCY: boolean;
  50902. SS_SCATERRING: boolean;
  50903. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50904. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50905. SS_REFRACTIONMAP_3D: boolean;
  50906. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50907. SS_LODINREFRACTIONALPHA: boolean;
  50908. SS_GAMMAREFRACTION: boolean;
  50909. SS_RGBDREFRACTION: boolean;
  50910. SS_LINEARSPECULARREFRACTION: boolean;
  50911. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50912. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50913. /** @hidden */
  50914. _areTexturesDirty: boolean;
  50915. }
  50916. /**
  50917. * Define the code related to the sub surface parameters of the pbr material.
  50918. */
  50919. export class PBRSubSurfaceConfiguration {
  50920. private _isRefractionEnabled;
  50921. /**
  50922. * Defines if the refraction is enabled in the material.
  50923. */
  50924. isRefractionEnabled: boolean;
  50925. private _isTranslucencyEnabled;
  50926. /**
  50927. * Defines if the translucency is enabled in the material.
  50928. */
  50929. isTranslucencyEnabled: boolean;
  50930. private _isScatteringEnabled;
  50931. /**
  50932. * Defines the refraction intensity of the material.
  50933. * The refraction when enabled replaces the Diffuse part of the material.
  50934. * The intensity helps transitionning between diffuse and refraction.
  50935. */
  50936. refractionIntensity: number;
  50937. /**
  50938. * Defines the translucency intensity of the material.
  50939. * When translucency has been enabled, this defines how much of the "translucency"
  50940. * is addded to the diffuse part of the material.
  50941. */
  50942. translucencyIntensity: number;
  50943. /**
  50944. * Defines the scattering intensity of the material.
  50945. * When scattering has been enabled, this defines how much of the "scattered light"
  50946. * is addded to the diffuse part of the material.
  50947. */
  50948. scatteringIntensity: number;
  50949. private _thicknessTexture;
  50950. /**
  50951. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50952. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50953. * 0 would mean minimumThickness
  50954. * 1 would mean maximumThickness
  50955. * The other channels might be use as a mask to vary the different effects intensity.
  50956. */
  50957. thicknessTexture: Nullable<BaseTexture>;
  50958. private _refractionTexture;
  50959. /**
  50960. * Defines the texture to use for refraction.
  50961. */
  50962. refractionTexture: Nullable<BaseTexture>;
  50963. private _indexOfRefraction;
  50964. /**
  50965. * Defines the index of refraction used in the material.
  50966. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50967. */
  50968. indexOfRefraction: number;
  50969. private _invertRefractionY;
  50970. /**
  50971. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50972. */
  50973. invertRefractionY: boolean;
  50974. private _linkRefractionWithTransparency;
  50975. /**
  50976. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50977. * Materials half opaque for instance using refraction could benefit from this control.
  50978. */
  50979. linkRefractionWithTransparency: boolean;
  50980. /**
  50981. * Defines the minimum thickness stored in the thickness map.
  50982. * If no thickness map is defined, this value will be used to simulate thickness.
  50983. */
  50984. minimumThickness: number;
  50985. /**
  50986. * Defines the maximum thickness stored in the thickness map.
  50987. */
  50988. maximumThickness: number;
  50989. /**
  50990. * Defines the volume tint of the material.
  50991. * This is used for both translucency and scattering.
  50992. */
  50993. tintColor: Color3;
  50994. /**
  50995. * Defines the distance at which the tint color should be found in the media.
  50996. * This is used for refraction only.
  50997. */
  50998. tintColorAtDistance: number;
  50999. /**
  51000. * Defines how far each channel transmit through the media.
  51001. * It is defined as a color to simplify it selection.
  51002. */
  51003. diffusionDistance: Color3;
  51004. private _useMaskFromThicknessTexture;
  51005. /**
  51006. * Stores the intensity of the different subsurface effects in the thickness texture.
  51007. * * the green channel is the translucency intensity.
  51008. * * the blue channel is the scattering intensity.
  51009. * * the alpha channel is the refraction intensity.
  51010. */
  51011. useMaskFromThicknessTexture: boolean;
  51012. /** @hidden */
  51013. private _internalMarkAllSubMeshesAsTexturesDirty;
  51014. /** @hidden */
  51015. _markAllSubMeshesAsTexturesDirty(): void;
  51016. /**
  51017. * Instantiate a new istance of sub surface configuration.
  51018. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51019. */
  51020. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51021. /**
  51022. * Gets wehter the submesh is ready to be used or not.
  51023. * @param defines the list of "defines" to update.
  51024. * @param scene defines the scene the material belongs to.
  51025. * @returns - boolean indicating that the submesh is ready or not.
  51026. */
  51027. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51028. /**
  51029. * Checks to see if a texture is used in the material.
  51030. * @param defines the list of "defines" to update.
  51031. * @param scene defines the scene to the material belongs to.
  51032. */
  51033. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51034. /**
  51035. * Binds the material data.
  51036. * @param uniformBuffer defines the Uniform buffer to fill in.
  51037. * @param scene defines the scene the material belongs to.
  51038. * @param engine defines the engine the material belongs to.
  51039. * @param isFrozen defines wether the material is frozen or not.
  51040. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51041. */
  51042. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51043. /**
  51044. * Unbinds the material from the mesh.
  51045. * @param activeEffect defines the effect that should be unbound from.
  51046. * @returns true if unbound, otherwise false
  51047. */
  51048. unbind(activeEffect: Effect): boolean;
  51049. /**
  51050. * Returns the texture used for refraction or null if none is used.
  51051. * @param scene defines the scene the material belongs to.
  51052. * @returns - Refraction texture if present. If no refraction texture and refraction
  51053. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51054. */
  51055. private _getRefractionTexture;
  51056. /**
  51057. * Returns true if alpha blending should be disabled.
  51058. */
  51059. get disableAlphaBlending(): boolean;
  51060. /**
  51061. * Fills the list of render target textures.
  51062. * @param renderTargets the list of render targets to update
  51063. */
  51064. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51065. /**
  51066. * Checks to see if a texture is used in the material.
  51067. * @param texture - Base texture to use.
  51068. * @returns - Boolean specifying if a texture is used in the material.
  51069. */
  51070. hasTexture(texture: BaseTexture): boolean;
  51071. /**
  51072. * Gets a boolean indicating that current material needs to register RTT
  51073. * @returns true if this uses a render target otherwise false.
  51074. */
  51075. hasRenderTargetTextures(): boolean;
  51076. /**
  51077. * Returns an array of the actively used textures.
  51078. * @param activeTextures Array of BaseTextures
  51079. */
  51080. getActiveTextures(activeTextures: BaseTexture[]): void;
  51081. /**
  51082. * Returns the animatable textures.
  51083. * @param animatables Array of animatable textures.
  51084. */
  51085. getAnimatables(animatables: IAnimatable[]): void;
  51086. /**
  51087. * Disposes the resources of the material.
  51088. * @param forceDisposeTextures - Forces the disposal of all textures.
  51089. */
  51090. dispose(forceDisposeTextures?: boolean): void;
  51091. /**
  51092. * Get the current class name of the texture useful for serialization or dynamic coding.
  51093. * @returns "PBRSubSurfaceConfiguration"
  51094. */
  51095. getClassName(): string;
  51096. /**
  51097. * Add fallbacks to the effect fallbacks list.
  51098. * @param defines defines the Base texture to use.
  51099. * @param fallbacks defines the current fallback list.
  51100. * @param currentRank defines the current fallback rank.
  51101. * @returns the new fallback rank.
  51102. */
  51103. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51104. /**
  51105. * Add the required uniforms to the current list.
  51106. * @param uniforms defines the current uniform list.
  51107. */
  51108. static AddUniforms(uniforms: string[]): void;
  51109. /**
  51110. * Add the required samplers to the current list.
  51111. * @param samplers defines the current sampler list.
  51112. */
  51113. static AddSamplers(samplers: string[]): void;
  51114. /**
  51115. * Add the required uniforms to the current buffer.
  51116. * @param uniformBuffer defines the current uniform buffer.
  51117. */
  51118. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51119. /**
  51120. * Makes a duplicate of the current configuration into another one.
  51121. * @param configuration define the config where to copy the info
  51122. */
  51123. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51124. /**
  51125. * Serializes this Sub Surface configuration.
  51126. * @returns - An object with the serialized config.
  51127. */
  51128. serialize(): any;
  51129. /**
  51130. * Parses a anisotropy Configuration from a serialized object.
  51131. * @param source - Serialized object.
  51132. * @param scene Defines the scene we are parsing for
  51133. * @param rootUrl Defines the rootUrl to load from
  51134. */
  51135. parse(source: any, scene: Scene, rootUrl: string): void;
  51136. }
  51137. }
  51138. declare module BABYLON {
  51139. /** @hidden */
  51140. export var pbrFragmentDeclaration: {
  51141. name: string;
  51142. shader: string;
  51143. };
  51144. }
  51145. declare module BABYLON {
  51146. /** @hidden */
  51147. export var pbrUboDeclaration: {
  51148. name: string;
  51149. shader: string;
  51150. };
  51151. }
  51152. declare module BABYLON {
  51153. /** @hidden */
  51154. export var pbrFragmentExtraDeclaration: {
  51155. name: string;
  51156. shader: string;
  51157. };
  51158. }
  51159. declare module BABYLON {
  51160. /** @hidden */
  51161. export var pbrFragmentSamplersDeclaration: {
  51162. name: string;
  51163. shader: string;
  51164. };
  51165. }
  51166. declare module BABYLON {
  51167. /** @hidden */
  51168. export var pbrHelperFunctions: {
  51169. name: string;
  51170. shader: string;
  51171. };
  51172. }
  51173. declare module BABYLON {
  51174. /** @hidden */
  51175. export var harmonicsFunctions: {
  51176. name: string;
  51177. shader: string;
  51178. };
  51179. }
  51180. declare module BABYLON {
  51181. /** @hidden */
  51182. export var pbrDirectLightingSetupFunctions: {
  51183. name: string;
  51184. shader: string;
  51185. };
  51186. }
  51187. declare module BABYLON {
  51188. /** @hidden */
  51189. export var pbrDirectLightingFalloffFunctions: {
  51190. name: string;
  51191. shader: string;
  51192. };
  51193. }
  51194. declare module BABYLON {
  51195. /** @hidden */
  51196. export var pbrBRDFFunctions: {
  51197. name: string;
  51198. shader: string;
  51199. };
  51200. }
  51201. declare module BABYLON {
  51202. /** @hidden */
  51203. export var pbrDirectLightingFunctions: {
  51204. name: string;
  51205. shader: string;
  51206. };
  51207. }
  51208. declare module BABYLON {
  51209. /** @hidden */
  51210. export var pbrIBLFunctions: {
  51211. name: string;
  51212. shader: string;
  51213. };
  51214. }
  51215. declare module BABYLON {
  51216. /** @hidden */
  51217. export var pbrBlockAlbedoOpacity: {
  51218. name: string;
  51219. shader: string;
  51220. };
  51221. }
  51222. declare module BABYLON {
  51223. /** @hidden */
  51224. export var pbrBlockReflectivity: {
  51225. name: string;
  51226. shader: string;
  51227. };
  51228. }
  51229. declare module BABYLON {
  51230. /** @hidden */
  51231. export var pbrBlockAmbientOcclusion: {
  51232. name: string;
  51233. shader: string;
  51234. };
  51235. }
  51236. declare module BABYLON {
  51237. /** @hidden */
  51238. export var pbrBlockAlphaFresnel: {
  51239. name: string;
  51240. shader: string;
  51241. };
  51242. }
  51243. declare module BABYLON {
  51244. /** @hidden */
  51245. export var pbrBlockAnisotropic: {
  51246. name: string;
  51247. shader: string;
  51248. };
  51249. }
  51250. declare module BABYLON {
  51251. /** @hidden */
  51252. export var pbrBlockReflection: {
  51253. name: string;
  51254. shader: string;
  51255. };
  51256. }
  51257. declare module BABYLON {
  51258. /** @hidden */
  51259. export var pbrBlockSheen: {
  51260. name: string;
  51261. shader: string;
  51262. };
  51263. }
  51264. declare module BABYLON {
  51265. /** @hidden */
  51266. export var pbrBlockClearcoat: {
  51267. name: string;
  51268. shader: string;
  51269. };
  51270. }
  51271. declare module BABYLON {
  51272. /** @hidden */
  51273. export var pbrBlockSubSurface: {
  51274. name: string;
  51275. shader: string;
  51276. };
  51277. }
  51278. declare module BABYLON {
  51279. /** @hidden */
  51280. export var pbrBlockNormalGeometric: {
  51281. name: string;
  51282. shader: string;
  51283. };
  51284. }
  51285. declare module BABYLON {
  51286. /** @hidden */
  51287. export var pbrBlockNormalFinal: {
  51288. name: string;
  51289. shader: string;
  51290. };
  51291. }
  51292. declare module BABYLON {
  51293. /** @hidden */
  51294. export var pbrBlockGeometryInfo: {
  51295. name: string;
  51296. shader: string;
  51297. };
  51298. }
  51299. declare module BABYLON {
  51300. /** @hidden */
  51301. export var pbrBlockReflectance0: {
  51302. name: string;
  51303. shader: string;
  51304. };
  51305. }
  51306. declare module BABYLON {
  51307. /** @hidden */
  51308. export var pbrBlockReflectance: {
  51309. name: string;
  51310. shader: string;
  51311. };
  51312. }
  51313. declare module BABYLON {
  51314. /** @hidden */
  51315. export var pbrBlockDirectLighting: {
  51316. name: string;
  51317. shader: string;
  51318. };
  51319. }
  51320. declare module BABYLON {
  51321. /** @hidden */
  51322. export var pbrBlockFinalLitComponents: {
  51323. name: string;
  51324. shader: string;
  51325. };
  51326. }
  51327. declare module BABYLON {
  51328. /** @hidden */
  51329. export var pbrBlockFinalUnlitComponents: {
  51330. name: string;
  51331. shader: string;
  51332. };
  51333. }
  51334. declare module BABYLON {
  51335. /** @hidden */
  51336. export var pbrBlockFinalColorComposition: {
  51337. name: string;
  51338. shader: string;
  51339. };
  51340. }
  51341. declare module BABYLON {
  51342. /** @hidden */
  51343. export var pbrBlockImageProcessing: {
  51344. name: string;
  51345. shader: string;
  51346. };
  51347. }
  51348. declare module BABYLON {
  51349. /** @hidden */
  51350. export var pbrDebug: {
  51351. name: string;
  51352. shader: string;
  51353. };
  51354. }
  51355. declare module BABYLON {
  51356. /** @hidden */
  51357. export var pbrPixelShader: {
  51358. name: string;
  51359. shader: string;
  51360. };
  51361. }
  51362. declare module BABYLON {
  51363. /** @hidden */
  51364. export var pbrVertexDeclaration: {
  51365. name: string;
  51366. shader: string;
  51367. };
  51368. }
  51369. declare module BABYLON {
  51370. /** @hidden */
  51371. export var pbrVertexShader: {
  51372. name: string;
  51373. shader: string;
  51374. };
  51375. }
  51376. declare module BABYLON {
  51377. /**
  51378. * Manages the defines for the PBR Material.
  51379. * @hidden
  51380. */
  51381. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51382. PBR: boolean;
  51383. MAINUV1: boolean;
  51384. MAINUV2: boolean;
  51385. UV1: boolean;
  51386. UV2: boolean;
  51387. ALBEDO: boolean;
  51388. GAMMAALBEDO: boolean;
  51389. ALBEDODIRECTUV: number;
  51390. VERTEXCOLOR: boolean;
  51391. AMBIENT: boolean;
  51392. AMBIENTDIRECTUV: number;
  51393. AMBIENTINGRAYSCALE: boolean;
  51394. OPACITY: boolean;
  51395. VERTEXALPHA: boolean;
  51396. OPACITYDIRECTUV: number;
  51397. OPACITYRGB: boolean;
  51398. ALPHATEST: boolean;
  51399. DEPTHPREPASS: boolean;
  51400. ALPHABLEND: boolean;
  51401. ALPHAFROMALBEDO: boolean;
  51402. ALPHATESTVALUE: string;
  51403. SPECULAROVERALPHA: boolean;
  51404. RADIANCEOVERALPHA: boolean;
  51405. ALPHAFRESNEL: boolean;
  51406. LINEARALPHAFRESNEL: boolean;
  51407. PREMULTIPLYALPHA: boolean;
  51408. EMISSIVE: boolean;
  51409. EMISSIVEDIRECTUV: number;
  51410. REFLECTIVITY: boolean;
  51411. REFLECTIVITYDIRECTUV: number;
  51412. SPECULARTERM: boolean;
  51413. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51414. MICROSURFACEAUTOMATIC: boolean;
  51415. LODBASEDMICROSFURACE: boolean;
  51416. MICROSURFACEMAP: boolean;
  51417. MICROSURFACEMAPDIRECTUV: number;
  51418. METALLICWORKFLOW: boolean;
  51419. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51420. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51421. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51422. AOSTOREINMETALMAPRED: boolean;
  51423. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51424. ENVIRONMENTBRDF: boolean;
  51425. ENVIRONMENTBRDF_RGBD: boolean;
  51426. NORMAL: boolean;
  51427. TANGENT: boolean;
  51428. BUMP: boolean;
  51429. BUMPDIRECTUV: number;
  51430. OBJECTSPACE_NORMALMAP: boolean;
  51431. PARALLAX: boolean;
  51432. PARALLAXOCCLUSION: boolean;
  51433. NORMALXYSCALE: boolean;
  51434. LIGHTMAP: boolean;
  51435. LIGHTMAPDIRECTUV: number;
  51436. USELIGHTMAPASSHADOWMAP: boolean;
  51437. GAMMALIGHTMAP: boolean;
  51438. RGBDLIGHTMAP: boolean;
  51439. REFLECTION: boolean;
  51440. REFLECTIONMAP_3D: boolean;
  51441. REFLECTIONMAP_SPHERICAL: boolean;
  51442. REFLECTIONMAP_PLANAR: boolean;
  51443. REFLECTIONMAP_CUBIC: boolean;
  51444. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51445. REFLECTIONMAP_PROJECTION: boolean;
  51446. REFLECTIONMAP_SKYBOX: boolean;
  51447. REFLECTIONMAP_EXPLICIT: boolean;
  51448. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51449. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51450. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51451. INVERTCUBICMAP: boolean;
  51452. USESPHERICALFROMREFLECTIONMAP: boolean;
  51453. USEIRRADIANCEMAP: boolean;
  51454. SPHERICAL_HARMONICS: boolean;
  51455. USESPHERICALINVERTEX: boolean;
  51456. REFLECTIONMAP_OPPOSITEZ: boolean;
  51457. LODINREFLECTIONALPHA: boolean;
  51458. GAMMAREFLECTION: boolean;
  51459. RGBDREFLECTION: boolean;
  51460. LINEARSPECULARREFLECTION: boolean;
  51461. RADIANCEOCCLUSION: boolean;
  51462. HORIZONOCCLUSION: boolean;
  51463. INSTANCES: boolean;
  51464. NUM_BONE_INFLUENCERS: number;
  51465. BonesPerMesh: number;
  51466. BONETEXTURE: boolean;
  51467. NONUNIFORMSCALING: boolean;
  51468. MORPHTARGETS: boolean;
  51469. MORPHTARGETS_NORMAL: boolean;
  51470. MORPHTARGETS_TANGENT: boolean;
  51471. MORPHTARGETS_UV: boolean;
  51472. NUM_MORPH_INFLUENCERS: number;
  51473. IMAGEPROCESSING: boolean;
  51474. VIGNETTE: boolean;
  51475. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51476. VIGNETTEBLENDMODEOPAQUE: boolean;
  51477. TONEMAPPING: boolean;
  51478. TONEMAPPING_ACES: boolean;
  51479. CONTRAST: boolean;
  51480. COLORCURVES: boolean;
  51481. COLORGRADING: boolean;
  51482. COLORGRADING3D: boolean;
  51483. SAMPLER3DGREENDEPTH: boolean;
  51484. SAMPLER3DBGRMAP: boolean;
  51485. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51486. EXPOSURE: boolean;
  51487. MULTIVIEW: boolean;
  51488. USEPHYSICALLIGHTFALLOFF: boolean;
  51489. USEGLTFLIGHTFALLOFF: boolean;
  51490. TWOSIDEDLIGHTING: boolean;
  51491. SHADOWFLOAT: boolean;
  51492. CLIPPLANE: boolean;
  51493. CLIPPLANE2: boolean;
  51494. CLIPPLANE3: boolean;
  51495. CLIPPLANE4: boolean;
  51496. CLIPPLANE5: boolean;
  51497. CLIPPLANE6: boolean;
  51498. POINTSIZE: boolean;
  51499. FOG: boolean;
  51500. LOGARITHMICDEPTH: boolean;
  51501. FORCENORMALFORWARD: boolean;
  51502. SPECULARAA: boolean;
  51503. CLEARCOAT: boolean;
  51504. CLEARCOAT_DEFAULTIOR: boolean;
  51505. CLEARCOAT_TEXTURE: boolean;
  51506. CLEARCOAT_TEXTUREDIRECTUV: number;
  51507. CLEARCOAT_BUMP: boolean;
  51508. CLEARCOAT_BUMPDIRECTUV: number;
  51509. CLEARCOAT_TINT: boolean;
  51510. CLEARCOAT_TINT_TEXTURE: boolean;
  51511. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51512. ANISOTROPIC: boolean;
  51513. ANISOTROPIC_TEXTURE: boolean;
  51514. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51515. BRDF_V_HEIGHT_CORRELATED: boolean;
  51516. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51517. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51518. SHEEN: boolean;
  51519. SHEEN_TEXTURE: boolean;
  51520. SHEEN_TEXTUREDIRECTUV: number;
  51521. SHEEN_LINKWITHALBEDO: boolean;
  51522. SHEEN_ROUGHNESS: boolean;
  51523. SHEEN_ALBEDOSCALING: boolean;
  51524. SUBSURFACE: boolean;
  51525. SS_REFRACTION: boolean;
  51526. SS_TRANSLUCENCY: boolean;
  51527. SS_SCATERRING: boolean;
  51528. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51529. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51530. SS_REFRACTIONMAP_3D: boolean;
  51531. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51532. SS_LODINREFRACTIONALPHA: boolean;
  51533. SS_GAMMAREFRACTION: boolean;
  51534. SS_RGBDREFRACTION: boolean;
  51535. SS_LINEARSPECULARREFRACTION: boolean;
  51536. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51537. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51538. UNLIT: boolean;
  51539. DEBUGMODE: number;
  51540. /**
  51541. * Initializes the PBR Material defines.
  51542. */
  51543. constructor();
  51544. /**
  51545. * Resets the PBR Material defines.
  51546. */
  51547. reset(): void;
  51548. }
  51549. /**
  51550. * The Physically based material base class of BJS.
  51551. *
  51552. * This offers the main features of a standard PBR material.
  51553. * For more information, please refer to the documentation :
  51554. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51555. */
  51556. export abstract class PBRBaseMaterial extends PushMaterial {
  51557. /**
  51558. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51559. */
  51560. static readonly PBRMATERIAL_OPAQUE: number;
  51561. /**
  51562. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51563. */
  51564. static readonly PBRMATERIAL_ALPHATEST: number;
  51565. /**
  51566. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51567. */
  51568. static readonly PBRMATERIAL_ALPHABLEND: number;
  51569. /**
  51570. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51571. * They are also discarded below the alpha cutoff threshold to improve performances.
  51572. */
  51573. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51574. /**
  51575. * Defines the default value of how much AO map is occluding the analytical lights
  51576. * (point spot...).
  51577. */
  51578. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51579. /**
  51580. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51581. */
  51582. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51583. /**
  51584. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51585. * to enhance interoperability with other engines.
  51586. */
  51587. static readonly LIGHTFALLOFF_GLTF: number;
  51588. /**
  51589. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51590. * to enhance interoperability with other materials.
  51591. */
  51592. static readonly LIGHTFALLOFF_STANDARD: number;
  51593. /**
  51594. * Intensity of the direct lights e.g. the four lights available in your scene.
  51595. * This impacts both the direct diffuse and specular highlights.
  51596. */
  51597. protected _directIntensity: number;
  51598. /**
  51599. * Intensity of the emissive part of the material.
  51600. * This helps controlling the emissive effect without modifying the emissive color.
  51601. */
  51602. protected _emissiveIntensity: number;
  51603. /**
  51604. * Intensity of the environment e.g. how much the environment will light the object
  51605. * either through harmonics for rough material or through the refelction for shiny ones.
  51606. */
  51607. protected _environmentIntensity: number;
  51608. /**
  51609. * This is a special control allowing the reduction of the specular highlights coming from the
  51610. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51611. */
  51612. protected _specularIntensity: number;
  51613. /**
  51614. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51615. */
  51616. private _lightingInfos;
  51617. /**
  51618. * Debug Control allowing disabling the bump map on this material.
  51619. */
  51620. protected _disableBumpMap: boolean;
  51621. /**
  51622. * AKA Diffuse Texture in standard nomenclature.
  51623. */
  51624. protected _albedoTexture: Nullable<BaseTexture>;
  51625. /**
  51626. * AKA Occlusion Texture in other nomenclature.
  51627. */
  51628. protected _ambientTexture: Nullable<BaseTexture>;
  51629. /**
  51630. * AKA Occlusion Texture Intensity in other nomenclature.
  51631. */
  51632. protected _ambientTextureStrength: number;
  51633. /**
  51634. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51635. * 1 means it completely occludes it
  51636. * 0 mean it has no impact
  51637. */
  51638. protected _ambientTextureImpactOnAnalyticalLights: number;
  51639. /**
  51640. * Stores the alpha values in a texture.
  51641. */
  51642. protected _opacityTexture: Nullable<BaseTexture>;
  51643. /**
  51644. * Stores the reflection values in a texture.
  51645. */
  51646. protected _reflectionTexture: Nullable<BaseTexture>;
  51647. /**
  51648. * Stores the emissive values in a texture.
  51649. */
  51650. protected _emissiveTexture: Nullable<BaseTexture>;
  51651. /**
  51652. * AKA Specular texture in other nomenclature.
  51653. */
  51654. protected _reflectivityTexture: Nullable<BaseTexture>;
  51655. /**
  51656. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51657. */
  51658. protected _metallicTexture: Nullable<BaseTexture>;
  51659. /**
  51660. * Specifies the metallic scalar of the metallic/roughness workflow.
  51661. * Can also be used to scale the metalness values of the metallic texture.
  51662. */
  51663. protected _metallic: Nullable<number>;
  51664. /**
  51665. * Specifies the roughness scalar of the metallic/roughness workflow.
  51666. * Can also be used to scale the roughness values of the metallic texture.
  51667. */
  51668. protected _roughness: Nullable<number>;
  51669. /**
  51670. * Specifies the an F0 factor to help configuring the material F0.
  51671. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51672. * to 0.5 the previously hard coded value stays the same.
  51673. * Can also be used to scale the F0 values of the metallic texture.
  51674. */
  51675. protected _metallicF0Factor: number;
  51676. /**
  51677. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51678. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51679. * your expectation as it multiplies with the texture data.
  51680. */
  51681. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51682. /**
  51683. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51684. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51685. */
  51686. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51687. /**
  51688. * Stores surface normal data used to displace a mesh in a texture.
  51689. */
  51690. protected _bumpTexture: Nullable<BaseTexture>;
  51691. /**
  51692. * Stores the pre-calculated light information of a mesh in a texture.
  51693. */
  51694. protected _lightmapTexture: Nullable<BaseTexture>;
  51695. /**
  51696. * The color of a material in ambient lighting.
  51697. */
  51698. protected _ambientColor: Color3;
  51699. /**
  51700. * AKA Diffuse Color in other nomenclature.
  51701. */
  51702. protected _albedoColor: Color3;
  51703. /**
  51704. * AKA Specular Color in other nomenclature.
  51705. */
  51706. protected _reflectivityColor: Color3;
  51707. /**
  51708. * The color applied when light is reflected from a material.
  51709. */
  51710. protected _reflectionColor: Color3;
  51711. /**
  51712. * The color applied when light is emitted from a material.
  51713. */
  51714. protected _emissiveColor: Color3;
  51715. /**
  51716. * AKA Glossiness in other nomenclature.
  51717. */
  51718. protected _microSurface: number;
  51719. /**
  51720. * Specifies that the material will use the light map as a show map.
  51721. */
  51722. protected _useLightmapAsShadowmap: boolean;
  51723. /**
  51724. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51725. * makes the reflect vector face the model (under horizon).
  51726. */
  51727. protected _useHorizonOcclusion: boolean;
  51728. /**
  51729. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51730. * too much the area relying on ambient texture to define their ambient occlusion.
  51731. */
  51732. protected _useRadianceOcclusion: boolean;
  51733. /**
  51734. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51735. */
  51736. protected _useAlphaFromAlbedoTexture: boolean;
  51737. /**
  51738. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51739. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51740. */
  51741. protected _useSpecularOverAlpha: boolean;
  51742. /**
  51743. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51744. */
  51745. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51746. /**
  51747. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51748. */
  51749. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51750. /**
  51751. * Specifies if the metallic texture contains the roughness information in its green channel.
  51752. */
  51753. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51754. /**
  51755. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51756. */
  51757. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51758. /**
  51759. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51760. */
  51761. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51762. /**
  51763. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51764. */
  51765. protected _useAmbientInGrayScale: boolean;
  51766. /**
  51767. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51768. * The material will try to infer what glossiness each pixel should be.
  51769. */
  51770. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51771. /**
  51772. * Defines the falloff type used in this material.
  51773. * It by default is Physical.
  51774. */
  51775. protected _lightFalloff: number;
  51776. /**
  51777. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51778. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51779. */
  51780. protected _useRadianceOverAlpha: boolean;
  51781. /**
  51782. * Allows using an object space normal map (instead of tangent space).
  51783. */
  51784. protected _useObjectSpaceNormalMap: boolean;
  51785. /**
  51786. * Allows using the bump map in parallax mode.
  51787. */
  51788. protected _useParallax: boolean;
  51789. /**
  51790. * Allows using the bump map in parallax occlusion mode.
  51791. */
  51792. protected _useParallaxOcclusion: boolean;
  51793. /**
  51794. * Controls the scale bias of the parallax mode.
  51795. */
  51796. protected _parallaxScaleBias: number;
  51797. /**
  51798. * If sets to true, disables all the lights affecting the material.
  51799. */
  51800. protected _disableLighting: boolean;
  51801. /**
  51802. * Number of Simultaneous lights allowed on the material.
  51803. */
  51804. protected _maxSimultaneousLights: number;
  51805. /**
  51806. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51807. */
  51808. protected _invertNormalMapX: boolean;
  51809. /**
  51810. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51811. */
  51812. protected _invertNormalMapY: boolean;
  51813. /**
  51814. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51815. */
  51816. protected _twoSidedLighting: boolean;
  51817. /**
  51818. * Defines the alpha limits in alpha test mode.
  51819. */
  51820. protected _alphaCutOff: number;
  51821. /**
  51822. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51823. */
  51824. protected _forceAlphaTest: boolean;
  51825. /**
  51826. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51827. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51828. */
  51829. protected _useAlphaFresnel: boolean;
  51830. /**
  51831. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51832. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51833. */
  51834. protected _useLinearAlphaFresnel: boolean;
  51835. /**
  51836. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51837. * from cos thetav and roughness:
  51838. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51839. */
  51840. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51841. /**
  51842. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51843. */
  51844. protected _forceIrradianceInFragment: boolean;
  51845. /**
  51846. * Force normal to face away from face.
  51847. */
  51848. protected _forceNormalForward: boolean;
  51849. /**
  51850. * Enables specular anti aliasing in the PBR shader.
  51851. * It will both interacts on the Geometry for analytical and IBL lighting.
  51852. * It also prefilter the roughness map based on the bump values.
  51853. */
  51854. protected _enableSpecularAntiAliasing: boolean;
  51855. /**
  51856. * Default configuration related to image processing available in the PBR Material.
  51857. */
  51858. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51859. /**
  51860. * Keep track of the image processing observer to allow dispose and replace.
  51861. */
  51862. private _imageProcessingObserver;
  51863. /**
  51864. * Attaches a new image processing configuration to the PBR Material.
  51865. * @param configuration
  51866. */
  51867. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51868. /**
  51869. * Stores the available render targets.
  51870. */
  51871. private _renderTargets;
  51872. /**
  51873. * Sets the global ambient color for the material used in lighting calculations.
  51874. */
  51875. private _globalAmbientColor;
  51876. /**
  51877. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51878. */
  51879. private _useLogarithmicDepth;
  51880. /**
  51881. * If set to true, no lighting calculations will be applied.
  51882. */
  51883. private _unlit;
  51884. private _debugMode;
  51885. /**
  51886. * @hidden
  51887. * This is reserved for the inspector.
  51888. * Defines the material debug mode.
  51889. * It helps seeing only some components of the material while troubleshooting.
  51890. */
  51891. debugMode: number;
  51892. /**
  51893. * @hidden
  51894. * This is reserved for the inspector.
  51895. * Specify from where on screen the debug mode should start.
  51896. * The value goes from -1 (full screen) to 1 (not visible)
  51897. * It helps with side by side comparison against the final render
  51898. * This defaults to -1
  51899. */
  51900. private debugLimit;
  51901. /**
  51902. * @hidden
  51903. * This is reserved for the inspector.
  51904. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51905. * You can use the factor to better multiply the final value.
  51906. */
  51907. private debugFactor;
  51908. /**
  51909. * Defines the clear coat layer parameters for the material.
  51910. */
  51911. readonly clearCoat: PBRClearCoatConfiguration;
  51912. /**
  51913. * Defines the anisotropic parameters for the material.
  51914. */
  51915. readonly anisotropy: PBRAnisotropicConfiguration;
  51916. /**
  51917. * Defines the BRDF parameters for the material.
  51918. */
  51919. readonly brdf: PBRBRDFConfiguration;
  51920. /**
  51921. * Defines the Sheen parameters for the material.
  51922. */
  51923. readonly sheen: PBRSheenConfiguration;
  51924. /**
  51925. * Defines the SubSurface parameters for the material.
  51926. */
  51927. readonly subSurface: PBRSubSurfaceConfiguration;
  51928. /**
  51929. * Custom callback helping to override the default shader used in the material.
  51930. */
  51931. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  51932. protected _rebuildInParallel: boolean;
  51933. /**
  51934. * Instantiates a new PBRMaterial instance.
  51935. *
  51936. * @param name The material name
  51937. * @param scene The scene the material will be use in.
  51938. */
  51939. constructor(name: string, scene: Scene);
  51940. /**
  51941. * Gets a boolean indicating that current material needs to register RTT
  51942. */
  51943. get hasRenderTargetTextures(): boolean;
  51944. /**
  51945. * Gets the name of the material class.
  51946. */
  51947. getClassName(): string;
  51948. /**
  51949. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51950. */
  51951. get useLogarithmicDepth(): boolean;
  51952. /**
  51953. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51954. */
  51955. set useLogarithmicDepth(value: boolean);
  51956. /**
  51957. * Returns true if alpha blending should be disabled.
  51958. */
  51959. protected get _disableAlphaBlending(): boolean;
  51960. /**
  51961. * Specifies whether or not this material should be rendered in alpha blend mode.
  51962. */
  51963. needAlphaBlending(): boolean;
  51964. /**
  51965. * Specifies whether or not this material should be rendered in alpha test mode.
  51966. */
  51967. needAlphaTesting(): boolean;
  51968. /**
  51969. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51970. */
  51971. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51972. /**
  51973. * Gets the texture used for the alpha test.
  51974. */
  51975. getAlphaTestTexture(): Nullable<BaseTexture>;
  51976. /**
  51977. * Specifies that the submesh is ready to be used.
  51978. * @param mesh - BJS mesh.
  51979. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51980. * @param useInstances - Specifies that instances should be used.
  51981. * @returns - boolean indicating that the submesh is ready or not.
  51982. */
  51983. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51984. /**
  51985. * Specifies if the material uses metallic roughness workflow.
  51986. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51987. */
  51988. isMetallicWorkflow(): boolean;
  51989. private _prepareEffect;
  51990. private _prepareDefines;
  51991. /**
  51992. * Force shader compilation
  51993. */
  51994. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51995. /**
  51996. * Initializes the uniform buffer layout for the shader.
  51997. */
  51998. buildUniformLayout(): void;
  51999. /**
  52000. * Unbinds the material from the mesh
  52001. */
  52002. unbind(): void;
  52003. /**
  52004. * Binds the submesh data.
  52005. * @param world - The world matrix.
  52006. * @param mesh - The BJS mesh.
  52007. * @param subMesh - A submesh of the BJS mesh.
  52008. */
  52009. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52010. /**
  52011. * Returns the animatable textures.
  52012. * @returns - Array of animatable textures.
  52013. */
  52014. getAnimatables(): IAnimatable[];
  52015. /**
  52016. * Returns the texture used for reflections.
  52017. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52018. */
  52019. private _getReflectionTexture;
  52020. /**
  52021. * Returns an array of the actively used textures.
  52022. * @returns - Array of BaseTextures
  52023. */
  52024. getActiveTextures(): BaseTexture[];
  52025. /**
  52026. * Checks to see if a texture is used in the material.
  52027. * @param texture - Base texture to use.
  52028. * @returns - Boolean specifying if a texture is used in the material.
  52029. */
  52030. hasTexture(texture: BaseTexture): boolean;
  52031. /**
  52032. * Disposes the resources of the material.
  52033. * @param forceDisposeEffect - Forces the disposal of effects.
  52034. * @param forceDisposeTextures - Forces the disposal of all textures.
  52035. */
  52036. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52037. }
  52038. }
  52039. declare module BABYLON {
  52040. /**
  52041. * The Physically based material of BJS.
  52042. *
  52043. * This offers the main features of a standard PBR material.
  52044. * For more information, please refer to the documentation :
  52045. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52046. */
  52047. export class PBRMaterial extends PBRBaseMaterial {
  52048. /**
  52049. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52050. */
  52051. static readonly PBRMATERIAL_OPAQUE: number;
  52052. /**
  52053. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52054. */
  52055. static readonly PBRMATERIAL_ALPHATEST: number;
  52056. /**
  52057. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52058. */
  52059. static readonly PBRMATERIAL_ALPHABLEND: number;
  52060. /**
  52061. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52062. * They are also discarded below the alpha cutoff threshold to improve performances.
  52063. */
  52064. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52065. /**
  52066. * Defines the default value of how much AO map is occluding the analytical lights
  52067. * (point spot...).
  52068. */
  52069. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52070. /**
  52071. * Intensity of the direct lights e.g. the four lights available in your scene.
  52072. * This impacts both the direct diffuse and specular highlights.
  52073. */
  52074. directIntensity: number;
  52075. /**
  52076. * Intensity of the emissive part of the material.
  52077. * This helps controlling the emissive effect without modifying the emissive color.
  52078. */
  52079. emissiveIntensity: number;
  52080. /**
  52081. * Intensity of the environment e.g. how much the environment will light the object
  52082. * either through harmonics for rough material or through the refelction for shiny ones.
  52083. */
  52084. environmentIntensity: number;
  52085. /**
  52086. * This is a special control allowing the reduction of the specular highlights coming from the
  52087. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52088. */
  52089. specularIntensity: number;
  52090. /**
  52091. * Debug Control allowing disabling the bump map on this material.
  52092. */
  52093. disableBumpMap: boolean;
  52094. /**
  52095. * AKA Diffuse Texture in standard nomenclature.
  52096. */
  52097. albedoTexture: BaseTexture;
  52098. /**
  52099. * AKA Occlusion Texture in other nomenclature.
  52100. */
  52101. ambientTexture: BaseTexture;
  52102. /**
  52103. * AKA Occlusion Texture Intensity in other nomenclature.
  52104. */
  52105. ambientTextureStrength: number;
  52106. /**
  52107. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52108. * 1 means it completely occludes it
  52109. * 0 mean it has no impact
  52110. */
  52111. ambientTextureImpactOnAnalyticalLights: number;
  52112. /**
  52113. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52114. */
  52115. opacityTexture: BaseTexture;
  52116. /**
  52117. * Stores the reflection values in a texture.
  52118. */
  52119. reflectionTexture: Nullable<BaseTexture>;
  52120. /**
  52121. * Stores the emissive values in a texture.
  52122. */
  52123. emissiveTexture: BaseTexture;
  52124. /**
  52125. * AKA Specular texture in other nomenclature.
  52126. */
  52127. reflectivityTexture: BaseTexture;
  52128. /**
  52129. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52130. */
  52131. metallicTexture: BaseTexture;
  52132. /**
  52133. * Specifies the metallic scalar of the metallic/roughness workflow.
  52134. * Can also be used to scale the metalness values of the metallic texture.
  52135. */
  52136. metallic: Nullable<number>;
  52137. /**
  52138. * Specifies the roughness scalar of the metallic/roughness workflow.
  52139. * Can also be used to scale the roughness values of the metallic texture.
  52140. */
  52141. roughness: Nullable<number>;
  52142. /**
  52143. * Specifies the an F0 factor to help configuring the material F0.
  52144. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52145. * to 0.5 the previously hard coded value stays the same.
  52146. * Can also be used to scale the F0 values of the metallic texture.
  52147. */
  52148. metallicF0Factor: number;
  52149. /**
  52150. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52151. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52152. * your expectation as it multiplies with the texture data.
  52153. */
  52154. useMetallicF0FactorFromMetallicTexture: boolean;
  52155. /**
  52156. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52157. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52158. */
  52159. microSurfaceTexture: BaseTexture;
  52160. /**
  52161. * Stores surface normal data used to displace a mesh in a texture.
  52162. */
  52163. bumpTexture: BaseTexture;
  52164. /**
  52165. * Stores the pre-calculated light information of a mesh in a texture.
  52166. */
  52167. lightmapTexture: BaseTexture;
  52168. /**
  52169. * Stores the refracted light information in a texture.
  52170. */
  52171. get refractionTexture(): Nullable<BaseTexture>;
  52172. set refractionTexture(value: Nullable<BaseTexture>);
  52173. /**
  52174. * The color of a material in ambient lighting.
  52175. */
  52176. ambientColor: Color3;
  52177. /**
  52178. * AKA Diffuse Color in other nomenclature.
  52179. */
  52180. albedoColor: Color3;
  52181. /**
  52182. * AKA Specular Color in other nomenclature.
  52183. */
  52184. reflectivityColor: Color3;
  52185. /**
  52186. * The color reflected from the material.
  52187. */
  52188. reflectionColor: Color3;
  52189. /**
  52190. * The color emitted from the material.
  52191. */
  52192. emissiveColor: Color3;
  52193. /**
  52194. * AKA Glossiness in other nomenclature.
  52195. */
  52196. microSurface: number;
  52197. /**
  52198. * source material index of refraction (IOR)' / 'destination material IOR.
  52199. */
  52200. get indexOfRefraction(): number;
  52201. set indexOfRefraction(value: number);
  52202. /**
  52203. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52204. */
  52205. get invertRefractionY(): boolean;
  52206. set invertRefractionY(value: boolean);
  52207. /**
  52208. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52209. * Materials half opaque for instance using refraction could benefit from this control.
  52210. */
  52211. get linkRefractionWithTransparency(): boolean;
  52212. set linkRefractionWithTransparency(value: boolean);
  52213. /**
  52214. * If true, the light map contains occlusion information instead of lighting info.
  52215. */
  52216. useLightmapAsShadowmap: boolean;
  52217. /**
  52218. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52219. */
  52220. useAlphaFromAlbedoTexture: boolean;
  52221. /**
  52222. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52223. */
  52224. forceAlphaTest: boolean;
  52225. /**
  52226. * Defines the alpha limits in alpha test mode.
  52227. */
  52228. alphaCutOff: number;
  52229. /**
  52230. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52231. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52232. */
  52233. useSpecularOverAlpha: boolean;
  52234. /**
  52235. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52236. */
  52237. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52238. /**
  52239. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52240. */
  52241. useRoughnessFromMetallicTextureAlpha: boolean;
  52242. /**
  52243. * Specifies if the metallic texture contains the roughness information in its green channel.
  52244. */
  52245. useRoughnessFromMetallicTextureGreen: boolean;
  52246. /**
  52247. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52248. */
  52249. useMetallnessFromMetallicTextureBlue: boolean;
  52250. /**
  52251. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52252. */
  52253. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52254. /**
  52255. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52256. */
  52257. useAmbientInGrayScale: boolean;
  52258. /**
  52259. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52260. * The material will try to infer what glossiness each pixel should be.
  52261. */
  52262. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52263. /**
  52264. * BJS is using an harcoded light falloff based on a manually sets up range.
  52265. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52266. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52267. */
  52268. get usePhysicalLightFalloff(): boolean;
  52269. /**
  52270. * BJS is using an harcoded light falloff based on a manually sets up range.
  52271. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52272. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52273. */
  52274. set usePhysicalLightFalloff(value: boolean);
  52275. /**
  52276. * In order to support the falloff compatibility with gltf, a special mode has been added
  52277. * to reproduce the gltf light falloff.
  52278. */
  52279. get useGLTFLightFalloff(): boolean;
  52280. /**
  52281. * In order to support the falloff compatibility with gltf, a special mode has been added
  52282. * to reproduce the gltf light falloff.
  52283. */
  52284. set useGLTFLightFalloff(value: boolean);
  52285. /**
  52286. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52287. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52288. */
  52289. useRadianceOverAlpha: boolean;
  52290. /**
  52291. * Allows using an object space normal map (instead of tangent space).
  52292. */
  52293. useObjectSpaceNormalMap: boolean;
  52294. /**
  52295. * Allows using the bump map in parallax mode.
  52296. */
  52297. useParallax: boolean;
  52298. /**
  52299. * Allows using the bump map in parallax occlusion mode.
  52300. */
  52301. useParallaxOcclusion: boolean;
  52302. /**
  52303. * Controls the scale bias of the parallax mode.
  52304. */
  52305. parallaxScaleBias: number;
  52306. /**
  52307. * If sets to true, disables all the lights affecting the material.
  52308. */
  52309. disableLighting: boolean;
  52310. /**
  52311. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52312. */
  52313. forceIrradianceInFragment: boolean;
  52314. /**
  52315. * Number of Simultaneous lights allowed on the material.
  52316. */
  52317. maxSimultaneousLights: number;
  52318. /**
  52319. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52320. */
  52321. invertNormalMapX: boolean;
  52322. /**
  52323. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52324. */
  52325. invertNormalMapY: boolean;
  52326. /**
  52327. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52328. */
  52329. twoSidedLighting: boolean;
  52330. /**
  52331. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52332. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52333. */
  52334. useAlphaFresnel: boolean;
  52335. /**
  52336. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52337. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52338. */
  52339. useLinearAlphaFresnel: boolean;
  52340. /**
  52341. * Let user defines the brdf lookup texture used for IBL.
  52342. * A default 8bit version is embedded but you could point at :
  52343. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52344. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52345. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52346. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52347. */
  52348. environmentBRDFTexture: Nullable<BaseTexture>;
  52349. /**
  52350. * Force normal to face away from face.
  52351. */
  52352. forceNormalForward: boolean;
  52353. /**
  52354. * Enables specular anti aliasing in the PBR shader.
  52355. * It will both interacts on the Geometry for analytical and IBL lighting.
  52356. * It also prefilter the roughness map based on the bump values.
  52357. */
  52358. enableSpecularAntiAliasing: boolean;
  52359. /**
  52360. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52361. * makes the reflect vector face the model (under horizon).
  52362. */
  52363. useHorizonOcclusion: boolean;
  52364. /**
  52365. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52366. * too much the area relying on ambient texture to define their ambient occlusion.
  52367. */
  52368. useRadianceOcclusion: boolean;
  52369. /**
  52370. * If set to true, no lighting calculations will be applied.
  52371. */
  52372. unlit: boolean;
  52373. /**
  52374. * Gets the image processing configuration used either in this material.
  52375. */
  52376. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52377. /**
  52378. * Sets the Default image processing configuration used either in the this material.
  52379. *
  52380. * If sets to null, the scene one is in use.
  52381. */
  52382. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52383. /**
  52384. * Gets wether the color curves effect is enabled.
  52385. */
  52386. get cameraColorCurvesEnabled(): boolean;
  52387. /**
  52388. * Sets wether the color curves effect is enabled.
  52389. */
  52390. set cameraColorCurvesEnabled(value: boolean);
  52391. /**
  52392. * Gets wether the color grading effect is enabled.
  52393. */
  52394. get cameraColorGradingEnabled(): boolean;
  52395. /**
  52396. * Gets wether the color grading effect is enabled.
  52397. */
  52398. set cameraColorGradingEnabled(value: boolean);
  52399. /**
  52400. * Gets wether tonemapping is enabled or not.
  52401. */
  52402. get cameraToneMappingEnabled(): boolean;
  52403. /**
  52404. * Sets wether tonemapping is enabled or not
  52405. */
  52406. set cameraToneMappingEnabled(value: boolean);
  52407. /**
  52408. * The camera exposure used on this material.
  52409. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52410. * This corresponds to a photographic exposure.
  52411. */
  52412. get cameraExposure(): number;
  52413. /**
  52414. * The camera exposure used on this material.
  52415. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52416. * This corresponds to a photographic exposure.
  52417. */
  52418. set cameraExposure(value: number);
  52419. /**
  52420. * Gets The camera contrast used on this material.
  52421. */
  52422. get cameraContrast(): number;
  52423. /**
  52424. * Sets The camera contrast used on this material.
  52425. */
  52426. set cameraContrast(value: number);
  52427. /**
  52428. * Gets the Color Grading 2D Lookup Texture.
  52429. */
  52430. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52431. /**
  52432. * Sets the Color Grading 2D Lookup Texture.
  52433. */
  52434. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52435. /**
  52436. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52437. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52438. * 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;
  52439. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52440. */
  52441. get cameraColorCurves(): Nullable<ColorCurves>;
  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. set cameraColorCurves(value: Nullable<ColorCurves>);
  52449. /**
  52450. * Instantiates a new PBRMaterial instance.
  52451. *
  52452. * @param name The material name
  52453. * @param scene The scene the material will be use in.
  52454. */
  52455. constructor(name: string, scene: Scene);
  52456. /**
  52457. * Returns the name of this material class.
  52458. */
  52459. getClassName(): string;
  52460. /**
  52461. * Makes a duplicate of the current material.
  52462. * @param name - name to use for the new material.
  52463. */
  52464. clone(name: string): PBRMaterial;
  52465. /**
  52466. * Serializes this PBR Material.
  52467. * @returns - An object with the serialized material.
  52468. */
  52469. serialize(): any;
  52470. /**
  52471. * Parses a PBR Material from a serialized object.
  52472. * @param source - Serialized object.
  52473. * @param scene - BJS scene instance.
  52474. * @param rootUrl - url for the scene object
  52475. * @returns - PBRMaterial
  52476. */
  52477. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52478. }
  52479. }
  52480. declare module BABYLON {
  52481. /**
  52482. * Direct draw surface info
  52483. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52484. */
  52485. export interface DDSInfo {
  52486. /**
  52487. * Width of the texture
  52488. */
  52489. width: number;
  52490. /**
  52491. * Width of the texture
  52492. */
  52493. height: number;
  52494. /**
  52495. * Number of Mipmaps for the texture
  52496. * @see https://en.wikipedia.org/wiki/Mipmap
  52497. */
  52498. mipmapCount: number;
  52499. /**
  52500. * If the textures format is a known fourCC format
  52501. * @see https://www.fourcc.org/
  52502. */
  52503. isFourCC: boolean;
  52504. /**
  52505. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52506. */
  52507. isRGB: boolean;
  52508. /**
  52509. * If the texture is a lumincance format
  52510. */
  52511. isLuminance: boolean;
  52512. /**
  52513. * If this is a cube texture
  52514. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52515. */
  52516. isCube: boolean;
  52517. /**
  52518. * If the texture is a compressed format eg. FOURCC_DXT1
  52519. */
  52520. isCompressed: boolean;
  52521. /**
  52522. * The dxgiFormat of the texture
  52523. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52524. */
  52525. dxgiFormat: number;
  52526. /**
  52527. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52528. */
  52529. textureType: number;
  52530. /**
  52531. * Sphericle polynomial created for the dds texture
  52532. */
  52533. sphericalPolynomial?: SphericalPolynomial;
  52534. }
  52535. /**
  52536. * Class used to provide DDS decompression tools
  52537. */
  52538. export class DDSTools {
  52539. /**
  52540. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52541. */
  52542. static StoreLODInAlphaChannel: boolean;
  52543. /**
  52544. * Gets DDS information from an array buffer
  52545. * @param data defines the array buffer view to read data from
  52546. * @returns the DDS information
  52547. */
  52548. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52549. private static _FloatView;
  52550. private static _Int32View;
  52551. private static _ToHalfFloat;
  52552. private static _FromHalfFloat;
  52553. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52554. private static _GetHalfFloatRGBAArrayBuffer;
  52555. private static _GetFloatRGBAArrayBuffer;
  52556. private static _GetFloatAsUIntRGBAArrayBuffer;
  52557. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52558. private static _GetRGBAArrayBuffer;
  52559. private static _ExtractLongWordOrder;
  52560. private static _GetRGBArrayBuffer;
  52561. private static _GetLuminanceArrayBuffer;
  52562. /**
  52563. * Uploads DDS Levels to a Babylon Texture
  52564. * @hidden
  52565. */
  52566. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52567. }
  52568. interface ThinEngine {
  52569. /**
  52570. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52571. * @param rootUrl defines the url where the file to load is located
  52572. * @param scene defines the current scene
  52573. * @param lodScale defines scale to apply to the mip map selection
  52574. * @param lodOffset defines offset to apply to the mip map selection
  52575. * @param onLoad defines an optional callback raised when the texture is loaded
  52576. * @param onError defines an optional callback raised if there is an issue to load the texture
  52577. * @param format defines the format of the data
  52578. * @param forcedExtension defines the extension to use to pick the right loader
  52579. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52580. * @returns the cube texture as an InternalTexture
  52581. */
  52582. 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;
  52583. }
  52584. }
  52585. declare module BABYLON {
  52586. /**
  52587. * Implementation of the DDS Texture Loader.
  52588. * @hidden
  52589. */
  52590. export class _DDSTextureLoader implements IInternalTextureLoader {
  52591. /**
  52592. * Defines wether the loader supports cascade loading the different faces.
  52593. */
  52594. readonly supportCascades: boolean;
  52595. /**
  52596. * This returns if the loader support the current file information.
  52597. * @param extension defines the file extension of the file being loaded
  52598. * @returns true if the loader can load the specified file
  52599. */
  52600. canLoad(extension: string): boolean;
  52601. /**
  52602. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52603. * @param data contains the texture data
  52604. * @param texture defines the BabylonJS internal texture
  52605. * @param createPolynomials will be true if polynomials have been requested
  52606. * @param onLoad defines the callback to trigger once the texture is ready
  52607. * @param onError defines the callback to trigger in case of error
  52608. */
  52609. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52610. /**
  52611. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52612. * @param data contains the texture data
  52613. * @param texture defines the BabylonJS internal texture
  52614. * @param callback defines the method to call once ready to upload
  52615. */
  52616. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52617. }
  52618. }
  52619. declare module BABYLON {
  52620. /**
  52621. * Implementation of the ENV Texture Loader.
  52622. * @hidden
  52623. */
  52624. export class _ENVTextureLoader implements IInternalTextureLoader {
  52625. /**
  52626. * Defines wether the loader supports cascade loading the different faces.
  52627. */
  52628. readonly supportCascades: boolean;
  52629. /**
  52630. * This returns if the loader support the current file information.
  52631. * @param extension defines the file extension of the file being loaded
  52632. * @returns true if the loader can load the specified file
  52633. */
  52634. canLoad(extension: string): boolean;
  52635. /**
  52636. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52637. * @param data contains the texture data
  52638. * @param texture defines the BabylonJS internal texture
  52639. * @param createPolynomials will be true if polynomials have been requested
  52640. * @param onLoad defines the callback to trigger once the texture is ready
  52641. * @param onError defines the callback to trigger in case of error
  52642. */
  52643. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52644. /**
  52645. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52646. * @param data contains the texture data
  52647. * @param texture defines the BabylonJS internal texture
  52648. * @param callback defines the method to call once ready to upload
  52649. */
  52650. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52651. }
  52652. }
  52653. declare module BABYLON {
  52654. /**
  52655. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52656. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52657. */
  52658. export class KhronosTextureContainer {
  52659. /** contents of the KTX container file */
  52660. data: ArrayBufferView;
  52661. private static HEADER_LEN;
  52662. private static COMPRESSED_2D;
  52663. private static COMPRESSED_3D;
  52664. private static TEX_2D;
  52665. private static TEX_3D;
  52666. /**
  52667. * Gets the openGL type
  52668. */
  52669. glType: number;
  52670. /**
  52671. * Gets the openGL type size
  52672. */
  52673. glTypeSize: number;
  52674. /**
  52675. * Gets the openGL format
  52676. */
  52677. glFormat: number;
  52678. /**
  52679. * Gets the openGL internal format
  52680. */
  52681. glInternalFormat: number;
  52682. /**
  52683. * Gets the base internal format
  52684. */
  52685. glBaseInternalFormat: number;
  52686. /**
  52687. * Gets image width in pixel
  52688. */
  52689. pixelWidth: number;
  52690. /**
  52691. * Gets image height in pixel
  52692. */
  52693. pixelHeight: number;
  52694. /**
  52695. * Gets image depth in pixels
  52696. */
  52697. pixelDepth: number;
  52698. /**
  52699. * Gets the number of array elements
  52700. */
  52701. numberOfArrayElements: number;
  52702. /**
  52703. * Gets the number of faces
  52704. */
  52705. numberOfFaces: number;
  52706. /**
  52707. * Gets the number of mipmap levels
  52708. */
  52709. numberOfMipmapLevels: number;
  52710. /**
  52711. * Gets the bytes of key value data
  52712. */
  52713. bytesOfKeyValueData: number;
  52714. /**
  52715. * Gets the load type
  52716. */
  52717. loadType: number;
  52718. /**
  52719. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52720. */
  52721. isInvalid: boolean;
  52722. /**
  52723. * Creates a new KhronosTextureContainer
  52724. * @param data contents of the KTX container file
  52725. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52726. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52727. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52728. */
  52729. constructor(
  52730. /** contents of the KTX container file */
  52731. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52732. /**
  52733. * Uploads KTX content to a Babylon Texture.
  52734. * It is assumed that the texture has already been created & is currently bound
  52735. * @hidden
  52736. */
  52737. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52738. private _upload2DCompressedLevels;
  52739. /**
  52740. * Checks if the given data starts with a KTX file identifier.
  52741. * @param data the data to check
  52742. * @returns true if the data is a KTX file or false otherwise
  52743. */
  52744. static IsValid(data: ArrayBufferView): boolean;
  52745. }
  52746. }
  52747. declare module BABYLON {
  52748. /**
  52749. * Class for loading KTX2 files
  52750. * !!! Experimental Extension Subject to Changes !!!
  52751. * @hidden
  52752. */
  52753. export class KhronosTextureContainer2 {
  52754. private static _ModulePromise;
  52755. private static _TranscodeFormat;
  52756. constructor(engine: ThinEngine);
  52757. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52758. private _determineTranscodeFormat;
  52759. /**
  52760. * Checks if the given data starts with a KTX2 file identifier.
  52761. * @param data the data to check
  52762. * @returns true if the data is a KTX2 file or false otherwise
  52763. */
  52764. static IsValid(data: ArrayBufferView): boolean;
  52765. }
  52766. }
  52767. declare module BABYLON {
  52768. /**
  52769. * Implementation of the KTX Texture Loader.
  52770. * @hidden
  52771. */
  52772. export class _KTXTextureLoader implements IInternalTextureLoader {
  52773. /**
  52774. * Defines wether the loader supports cascade loading the different faces.
  52775. */
  52776. readonly supportCascades: boolean;
  52777. /**
  52778. * This returns if the loader support the current file information.
  52779. * @param extension defines the file extension of the file being loaded
  52780. * @returns true if the loader can load the specified file
  52781. */
  52782. canLoad(extension: string): boolean;
  52783. /**
  52784. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52785. * @param data contains the texture data
  52786. * @param texture defines the BabylonJS internal texture
  52787. * @param createPolynomials will be true if polynomials have been requested
  52788. * @param onLoad defines the callback to trigger once the texture is ready
  52789. * @param onError defines the callback to trigger in case of error
  52790. */
  52791. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52792. /**
  52793. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52794. * @param data contains the texture data
  52795. * @param texture defines the BabylonJS internal texture
  52796. * @param callback defines the method to call once ready to upload
  52797. */
  52798. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52799. }
  52800. }
  52801. declare module BABYLON {
  52802. /** @hidden */
  52803. export var _forceSceneHelpersToBundle: boolean;
  52804. interface Scene {
  52805. /**
  52806. * Creates a default light for the scene.
  52807. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52808. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52809. */
  52810. createDefaultLight(replace?: boolean): void;
  52811. /**
  52812. * Creates a default camera for the scene.
  52813. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52814. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52815. * @param replace has default false, when true replaces the active camera in the scene
  52816. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52817. */
  52818. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52819. /**
  52820. * Creates a default camera and a default light.
  52821. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52822. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52823. * @param replace has the default false, when true replaces the active camera/light in the scene
  52824. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52825. */
  52826. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52827. /**
  52828. * Creates a new sky box
  52829. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52830. * @param environmentTexture defines the texture to use as environment texture
  52831. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52832. * @param scale defines the overall scale of the skybox
  52833. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52834. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52835. * @returns a new mesh holding the sky box
  52836. */
  52837. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52838. /**
  52839. * Creates a new environment
  52840. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52841. * @param options defines the options you can use to configure the environment
  52842. * @returns the new EnvironmentHelper
  52843. */
  52844. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52845. /**
  52846. * Creates a new VREXperienceHelper
  52847. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52848. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52849. * @returns a new VREXperienceHelper
  52850. */
  52851. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52852. /**
  52853. * Creates a new WebXRDefaultExperience
  52854. * @see http://doc.babylonjs.com/how_to/webxr
  52855. * @param options experience options
  52856. * @returns a promise for a new WebXRDefaultExperience
  52857. */
  52858. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52859. }
  52860. }
  52861. declare module BABYLON {
  52862. /**
  52863. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52864. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52865. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52866. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52867. */
  52868. export class VideoDome extends TransformNode {
  52869. /**
  52870. * Define the video source as a Monoscopic panoramic 360 video.
  52871. */
  52872. static readonly MODE_MONOSCOPIC: number;
  52873. /**
  52874. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52875. */
  52876. static readonly MODE_TOPBOTTOM: number;
  52877. /**
  52878. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52879. */
  52880. static readonly MODE_SIDEBYSIDE: number;
  52881. private _halfDome;
  52882. private _useDirectMapping;
  52883. /**
  52884. * The video texture being displayed on the sphere
  52885. */
  52886. protected _videoTexture: VideoTexture;
  52887. /**
  52888. * Gets the video texture being displayed on the sphere
  52889. */
  52890. get videoTexture(): VideoTexture;
  52891. /**
  52892. * The skybox material
  52893. */
  52894. protected _material: BackgroundMaterial;
  52895. /**
  52896. * The surface used for the skybox
  52897. */
  52898. protected _mesh: Mesh;
  52899. /**
  52900. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52901. */
  52902. private _halfDomeMask;
  52903. /**
  52904. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52905. * Also see the options.resolution property.
  52906. */
  52907. get fovMultiplier(): number;
  52908. set fovMultiplier(value: number);
  52909. private _videoMode;
  52910. /**
  52911. * Gets or set the current video mode for the video. It can be:
  52912. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52913. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52914. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52915. */
  52916. get videoMode(): number;
  52917. set videoMode(value: number);
  52918. /**
  52919. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52920. *
  52921. */
  52922. get halfDome(): boolean;
  52923. /**
  52924. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52925. */
  52926. set halfDome(enabled: boolean);
  52927. /**
  52928. * Oberserver used in Stereoscopic VR Mode.
  52929. */
  52930. private _onBeforeCameraRenderObserver;
  52931. /**
  52932. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52933. * @param name Element's name, child elements will append suffixes for their own names.
  52934. * @param urlsOrVideo defines the url(s) or the video element to use
  52935. * @param options An object containing optional or exposed sub element properties
  52936. */
  52937. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52938. resolution?: number;
  52939. clickToPlay?: boolean;
  52940. autoPlay?: boolean;
  52941. loop?: boolean;
  52942. size?: number;
  52943. poster?: string;
  52944. faceForward?: boolean;
  52945. useDirectMapping?: boolean;
  52946. halfDomeMode?: boolean;
  52947. }, scene: Scene);
  52948. private _changeVideoMode;
  52949. /**
  52950. * Releases resources associated with this node.
  52951. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52952. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52953. */
  52954. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52955. }
  52956. }
  52957. declare module BABYLON {
  52958. /**
  52959. * This class can be used to get instrumentation data from a Babylon engine
  52960. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52961. */
  52962. export class EngineInstrumentation implements IDisposable {
  52963. /**
  52964. * Define the instrumented engine.
  52965. */
  52966. engine: Engine;
  52967. private _captureGPUFrameTime;
  52968. private _gpuFrameTimeToken;
  52969. private _gpuFrameTime;
  52970. private _captureShaderCompilationTime;
  52971. private _shaderCompilationTime;
  52972. private _onBeginFrameObserver;
  52973. private _onEndFrameObserver;
  52974. private _onBeforeShaderCompilationObserver;
  52975. private _onAfterShaderCompilationObserver;
  52976. /**
  52977. * Gets the perf counter used for GPU frame time
  52978. */
  52979. get gpuFrameTimeCounter(): PerfCounter;
  52980. /**
  52981. * Gets the GPU frame time capture status
  52982. */
  52983. get captureGPUFrameTime(): boolean;
  52984. /**
  52985. * Enable or disable the GPU frame time capture
  52986. */
  52987. set captureGPUFrameTime(value: boolean);
  52988. /**
  52989. * Gets the perf counter used for shader compilation time
  52990. */
  52991. get shaderCompilationTimeCounter(): PerfCounter;
  52992. /**
  52993. * Gets the shader compilation time capture status
  52994. */
  52995. get captureShaderCompilationTime(): boolean;
  52996. /**
  52997. * Enable or disable the shader compilation time capture
  52998. */
  52999. set captureShaderCompilationTime(value: boolean);
  53000. /**
  53001. * Instantiates a new engine instrumentation.
  53002. * This class can be used to get instrumentation data from a Babylon engine
  53003. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53004. * @param engine Defines the engine to instrument
  53005. */
  53006. constructor(
  53007. /**
  53008. * Define the instrumented engine.
  53009. */
  53010. engine: Engine);
  53011. /**
  53012. * Dispose and release associated resources.
  53013. */
  53014. dispose(): void;
  53015. }
  53016. }
  53017. declare module BABYLON {
  53018. /**
  53019. * This class can be used to get instrumentation data from a Babylon engine
  53020. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53021. */
  53022. export class SceneInstrumentation implements IDisposable {
  53023. /**
  53024. * Defines the scene to instrument
  53025. */
  53026. scene: Scene;
  53027. private _captureActiveMeshesEvaluationTime;
  53028. private _activeMeshesEvaluationTime;
  53029. private _captureRenderTargetsRenderTime;
  53030. private _renderTargetsRenderTime;
  53031. private _captureFrameTime;
  53032. private _frameTime;
  53033. private _captureRenderTime;
  53034. private _renderTime;
  53035. private _captureInterFrameTime;
  53036. private _interFrameTime;
  53037. private _captureParticlesRenderTime;
  53038. private _particlesRenderTime;
  53039. private _captureSpritesRenderTime;
  53040. private _spritesRenderTime;
  53041. private _capturePhysicsTime;
  53042. private _physicsTime;
  53043. private _captureAnimationsTime;
  53044. private _animationsTime;
  53045. private _captureCameraRenderTime;
  53046. private _cameraRenderTime;
  53047. private _onBeforeActiveMeshesEvaluationObserver;
  53048. private _onAfterActiveMeshesEvaluationObserver;
  53049. private _onBeforeRenderTargetsRenderObserver;
  53050. private _onAfterRenderTargetsRenderObserver;
  53051. private _onAfterRenderObserver;
  53052. private _onBeforeDrawPhaseObserver;
  53053. private _onAfterDrawPhaseObserver;
  53054. private _onBeforeAnimationsObserver;
  53055. private _onBeforeParticlesRenderingObserver;
  53056. private _onAfterParticlesRenderingObserver;
  53057. private _onBeforeSpritesRenderingObserver;
  53058. private _onAfterSpritesRenderingObserver;
  53059. private _onBeforePhysicsObserver;
  53060. private _onAfterPhysicsObserver;
  53061. private _onAfterAnimationsObserver;
  53062. private _onBeforeCameraRenderObserver;
  53063. private _onAfterCameraRenderObserver;
  53064. /**
  53065. * Gets the perf counter used for active meshes evaluation time
  53066. */
  53067. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53068. /**
  53069. * Gets the active meshes evaluation time capture status
  53070. */
  53071. get captureActiveMeshesEvaluationTime(): boolean;
  53072. /**
  53073. * Enable or disable the active meshes evaluation time capture
  53074. */
  53075. set captureActiveMeshesEvaluationTime(value: boolean);
  53076. /**
  53077. * Gets the perf counter used for render targets render time
  53078. */
  53079. get renderTargetsRenderTimeCounter(): PerfCounter;
  53080. /**
  53081. * Gets the render targets render time capture status
  53082. */
  53083. get captureRenderTargetsRenderTime(): boolean;
  53084. /**
  53085. * Enable or disable the render targets render time capture
  53086. */
  53087. set captureRenderTargetsRenderTime(value: boolean);
  53088. /**
  53089. * Gets the perf counter used for particles render time
  53090. */
  53091. get particlesRenderTimeCounter(): PerfCounter;
  53092. /**
  53093. * Gets the particles render time capture status
  53094. */
  53095. get captureParticlesRenderTime(): boolean;
  53096. /**
  53097. * Enable or disable the particles render time capture
  53098. */
  53099. set captureParticlesRenderTime(value: boolean);
  53100. /**
  53101. * Gets the perf counter used for sprites render time
  53102. */
  53103. get spritesRenderTimeCounter(): PerfCounter;
  53104. /**
  53105. * Gets the sprites render time capture status
  53106. */
  53107. get captureSpritesRenderTime(): boolean;
  53108. /**
  53109. * Enable or disable the sprites render time capture
  53110. */
  53111. set captureSpritesRenderTime(value: boolean);
  53112. /**
  53113. * Gets the perf counter used for physics time
  53114. */
  53115. get physicsTimeCounter(): PerfCounter;
  53116. /**
  53117. * Gets the physics time capture status
  53118. */
  53119. get capturePhysicsTime(): boolean;
  53120. /**
  53121. * Enable or disable the physics time capture
  53122. */
  53123. set capturePhysicsTime(value: boolean);
  53124. /**
  53125. * Gets the perf counter used for animations time
  53126. */
  53127. get animationsTimeCounter(): PerfCounter;
  53128. /**
  53129. * Gets the animations time capture status
  53130. */
  53131. get captureAnimationsTime(): boolean;
  53132. /**
  53133. * Enable or disable the animations time capture
  53134. */
  53135. set captureAnimationsTime(value: boolean);
  53136. /**
  53137. * Gets the perf counter used for frame time capture
  53138. */
  53139. get frameTimeCounter(): PerfCounter;
  53140. /**
  53141. * Gets the frame time capture status
  53142. */
  53143. get captureFrameTime(): boolean;
  53144. /**
  53145. * Enable or disable the frame time capture
  53146. */
  53147. set captureFrameTime(value: boolean);
  53148. /**
  53149. * Gets the perf counter used for inter-frames time capture
  53150. */
  53151. get interFrameTimeCounter(): PerfCounter;
  53152. /**
  53153. * Gets the inter-frames time capture status
  53154. */
  53155. get captureInterFrameTime(): boolean;
  53156. /**
  53157. * Enable or disable the inter-frames time capture
  53158. */
  53159. set captureInterFrameTime(value: boolean);
  53160. /**
  53161. * Gets the perf counter used for render time capture
  53162. */
  53163. get renderTimeCounter(): PerfCounter;
  53164. /**
  53165. * Gets the render time capture status
  53166. */
  53167. get captureRenderTime(): boolean;
  53168. /**
  53169. * Enable or disable the render time capture
  53170. */
  53171. set captureRenderTime(value: boolean);
  53172. /**
  53173. * Gets the perf counter used for camera render time capture
  53174. */
  53175. get cameraRenderTimeCounter(): PerfCounter;
  53176. /**
  53177. * Gets the camera render time capture status
  53178. */
  53179. get captureCameraRenderTime(): boolean;
  53180. /**
  53181. * Enable or disable the camera render time capture
  53182. */
  53183. set captureCameraRenderTime(value: boolean);
  53184. /**
  53185. * Gets the perf counter used for draw calls
  53186. */
  53187. get drawCallsCounter(): PerfCounter;
  53188. /**
  53189. * Instantiates a new scene instrumentation.
  53190. * This class can be used to get instrumentation data from a Babylon engine
  53191. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53192. * @param scene Defines the scene to instrument
  53193. */
  53194. constructor(
  53195. /**
  53196. * Defines the scene to instrument
  53197. */
  53198. scene: Scene);
  53199. /**
  53200. * Dispose and release associated resources.
  53201. */
  53202. dispose(): void;
  53203. }
  53204. }
  53205. declare module BABYLON {
  53206. /** @hidden */
  53207. export var glowMapGenerationPixelShader: {
  53208. name: string;
  53209. shader: string;
  53210. };
  53211. }
  53212. declare module BABYLON {
  53213. /** @hidden */
  53214. export var glowMapGenerationVertexShader: {
  53215. name: string;
  53216. shader: string;
  53217. };
  53218. }
  53219. declare module BABYLON {
  53220. /**
  53221. * Effect layer options. This helps customizing the behaviour
  53222. * of the effect layer.
  53223. */
  53224. export interface IEffectLayerOptions {
  53225. /**
  53226. * Multiplication factor apply to the canvas size to compute the render target size
  53227. * used to generated the objects (the smaller the faster).
  53228. */
  53229. mainTextureRatio: number;
  53230. /**
  53231. * Enforces a fixed size texture to ensure effect stability across devices.
  53232. */
  53233. mainTextureFixedSize?: number;
  53234. /**
  53235. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53236. */
  53237. alphaBlendingMode: number;
  53238. /**
  53239. * The camera attached to the layer.
  53240. */
  53241. camera: Nullable<Camera>;
  53242. /**
  53243. * The rendering group to draw the layer in.
  53244. */
  53245. renderingGroupId: number;
  53246. }
  53247. /**
  53248. * The effect layer Helps adding post process effect blended with the main pass.
  53249. *
  53250. * This can be for instance use to generate glow or higlight effects on the scene.
  53251. *
  53252. * The effect layer class can not be used directly and is intented to inherited from to be
  53253. * customized per effects.
  53254. */
  53255. export abstract class EffectLayer {
  53256. private _vertexBuffers;
  53257. private _indexBuffer;
  53258. private _cachedDefines;
  53259. private _effectLayerMapGenerationEffect;
  53260. private _effectLayerOptions;
  53261. private _mergeEffect;
  53262. protected _scene: Scene;
  53263. protected _engine: Engine;
  53264. protected _maxSize: number;
  53265. protected _mainTextureDesiredSize: ISize;
  53266. protected _mainTexture: RenderTargetTexture;
  53267. protected _shouldRender: boolean;
  53268. protected _postProcesses: PostProcess[];
  53269. protected _textures: BaseTexture[];
  53270. protected _emissiveTextureAndColor: {
  53271. texture: Nullable<BaseTexture>;
  53272. color: Color4;
  53273. };
  53274. /**
  53275. * The name of the layer
  53276. */
  53277. name: string;
  53278. /**
  53279. * The clear color of the texture used to generate the glow map.
  53280. */
  53281. neutralColor: Color4;
  53282. /**
  53283. * Specifies whether the highlight layer is enabled or not.
  53284. */
  53285. isEnabled: boolean;
  53286. /**
  53287. * Gets the camera attached to the layer.
  53288. */
  53289. get camera(): Nullable<Camera>;
  53290. /**
  53291. * Gets the rendering group id the layer should render in.
  53292. */
  53293. get renderingGroupId(): number;
  53294. set renderingGroupId(renderingGroupId: number);
  53295. /**
  53296. * An event triggered when the effect layer has been disposed.
  53297. */
  53298. onDisposeObservable: Observable<EffectLayer>;
  53299. /**
  53300. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53301. */
  53302. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53303. /**
  53304. * An event triggered when the generated texture is being merged in the scene.
  53305. */
  53306. onBeforeComposeObservable: Observable<EffectLayer>;
  53307. /**
  53308. * An event triggered when the mesh is rendered into the effect render target.
  53309. */
  53310. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53311. /**
  53312. * An event triggered after the mesh has been rendered into the effect render target.
  53313. */
  53314. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53315. /**
  53316. * An event triggered when the generated texture has been merged in the scene.
  53317. */
  53318. onAfterComposeObservable: Observable<EffectLayer>;
  53319. /**
  53320. * An event triggered when the efffect layer changes its size.
  53321. */
  53322. onSizeChangedObservable: Observable<EffectLayer>;
  53323. /** @hidden */
  53324. static _SceneComponentInitialization: (scene: Scene) => void;
  53325. /**
  53326. * Instantiates a new effect Layer and references it in the scene.
  53327. * @param name The name of the layer
  53328. * @param scene The scene to use the layer in
  53329. */
  53330. constructor(
  53331. /** The Friendly of the effect in the scene */
  53332. name: string, scene: Scene);
  53333. /**
  53334. * Get the effect name of the layer.
  53335. * @return The effect name
  53336. */
  53337. abstract getEffectName(): string;
  53338. /**
  53339. * Checks for the readiness of the element composing the layer.
  53340. * @param subMesh the mesh to check for
  53341. * @param useInstances specify whether or not to use instances to render the mesh
  53342. * @return true if ready otherwise, false
  53343. */
  53344. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53345. /**
  53346. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53347. * @returns true if the effect requires stencil during the main canvas render pass.
  53348. */
  53349. abstract needStencil(): boolean;
  53350. /**
  53351. * Create the merge effect. This is the shader use to blit the information back
  53352. * to the main canvas at the end of the scene rendering.
  53353. * @returns The effect containing the shader used to merge the effect on the main canvas
  53354. */
  53355. protected abstract _createMergeEffect(): Effect;
  53356. /**
  53357. * Creates the render target textures and post processes used in the effect layer.
  53358. */
  53359. protected abstract _createTextureAndPostProcesses(): void;
  53360. /**
  53361. * Implementation specific of rendering the generating effect on the main canvas.
  53362. * @param effect The effect used to render through
  53363. */
  53364. protected abstract _internalRender(effect: Effect): void;
  53365. /**
  53366. * Sets the required values for both the emissive texture and and the main color.
  53367. */
  53368. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53369. /**
  53370. * Free any resources and references associated to a mesh.
  53371. * Internal use
  53372. * @param mesh The mesh to free.
  53373. */
  53374. abstract _disposeMesh(mesh: Mesh): void;
  53375. /**
  53376. * Serializes this layer (Glow or Highlight for example)
  53377. * @returns a serialized layer object
  53378. */
  53379. abstract serialize?(): any;
  53380. /**
  53381. * Initializes the effect layer with the required options.
  53382. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53383. */
  53384. protected _init(options: Partial<IEffectLayerOptions>): void;
  53385. /**
  53386. * Generates the index buffer of the full screen quad blending to the main canvas.
  53387. */
  53388. private _generateIndexBuffer;
  53389. /**
  53390. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53391. */
  53392. private _generateVertexBuffer;
  53393. /**
  53394. * Sets the main texture desired size which is the closest power of two
  53395. * of the engine canvas size.
  53396. */
  53397. private _setMainTextureSize;
  53398. /**
  53399. * Creates the main texture for the effect layer.
  53400. */
  53401. protected _createMainTexture(): void;
  53402. /**
  53403. * Adds specific effects defines.
  53404. * @param defines The defines to add specifics to.
  53405. */
  53406. protected _addCustomEffectDefines(defines: string[]): void;
  53407. /**
  53408. * Checks for the readiness of the element composing the layer.
  53409. * @param subMesh the mesh to check for
  53410. * @param useInstances specify whether or not to use instances to render the mesh
  53411. * @param emissiveTexture the associated emissive texture used to generate the glow
  53412. * @return true if ready otherwise, false
  53413. */
  53414. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53415. /**
  53416. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53417. */
  53418. render(): void;
  53419. /**
  53420. * Determine if a given mesh will be used in the current effect.
  53421. * @param mesh mesh to test
  53422. * @returns true if the mesh will be used
  53423. */
  53424. hasMesh(mesh: AbstractMesh): boolean;
  53425. /**
  53426. * Returns true if the layer contains information to display, otherwise false.
  53427. * @returns true if the glow layer should be rendered
  53428. */
  53429. shouldRender(): boolean;
  53430. /**
  53431. * Returns true if the mesh should render, otherwise false.
  53432. * @param mesh The mesh to render
  53433. * @returns true if it should render otherwise false
  53434. */
  53435. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53436. /**
  53437. * Returns true if the mesh can be rendered, otherwise false.
  53438. * @param mesh The mesh to render
  53439. * @param material The material used on the mesh
  53440. * @returns true if it can be rendered otherwise false
  53441. */
  53442. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53443. /**
  53444. * Returns true if the mesh should render, otherwise false.
  53445. * @param mesh The mesh to render
  53446. * @returns true if it should render otherwise false
  53447. */
  53448. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53449. /**
  53450. * Renders the submesh passed in parameter to the generation map.
  53451. */
  53452. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53453. /**
  53454. * Defines whether the current material of the mesh should be use to render the effect.
  53455. * @param mesh defines the current mesh to render
  53456. */
  53457. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53458. /**
  53459. * Rebuild the required buffers.
  53460. * @hidden Internal use only.
  53461. */
  53462. _rebuild(): void;
  53463. /**
  53464. * Dispose only the render target textures and post process.
  53465. */
  53466. private _disposeTextureAndPostProcesses;
  53467. /**
  53468. * Dispose the highlight layer and free resources.
  53469. */
  53470. dispose(): void;
  53471. /**
  53472. * Gets the class name of the effect layer
  53473. * @returns the string with the class name of the effect layer
  53474. */
  53475. getClassName(): string;
  53476. /**
  53477. * Creates an effect layer from parsed effect layer data
  53478. * @param parsedEffectLayer defines effect layer data
  53479. * @param scene defines the current scene
  53480. * @param rootUrl defines the root URL containing the effect layer information
  53481. * @returns a parsed effect Layer
  53482. */
  53483. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53484. }
  53485. }
  53486. declare module BABYLON {
  53487. interface AbstractScene {
  53488. /**
  53489. * The list of effect layers (highlights/glow) added to the scene
  53490. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53491. * @see http://doc.babylonjs.com/how_to/glow_layer
  53492. */
  53493. effectLayers: Array<EffectLayer>;
  53494. /**
  53495. * Removes the given effect layer from this scene.
  53496. * @param toRemove defines the effect layer to remove
  53497. * @returns the index of the removed effect layer
  53498. */
  53499. removeEffectLayer(toRemove: EffectLayer): number;
  53500. /**
  53501. * Adds the given effect layer to this scene
  53502. * @param newEffectLayer defines the effect layer to add
  53503. */
  53504. addEffectLayer(newEffectLayer: EffectLayer): void;
  53505. }
  53506. /**
  53507. * Defines the layer scene component responsible to manage any effect layers
  53508. * in a given scene.
  53509. */
  53510. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53511. /**
  53512. * The component name helpfull to identify the component in the list of scene components.
  53513. */
  53514. readonly name: string;
  53515. /**
  53516. * The scene the component belongs to.
  53517. */
  53518. scene: Scene;
  53519. private _engine;
  53520. private _renderEffects;
  53521. private _needStencil;
  53522. private _previousStencilState;
  53523. /**
  53524. * Creates a new instance of the component for the given scene
  53525. * @param scene Defines the scene to register the component in
  53526. */
  53527. constructor(scene: Scene);
  53528. /**
  53529. * Registers the component in a given scene
  53530. */
  53531. register(): void;
  53532. /**
  53533. * Rebuilds the elements related to this component in case of
  53534. * context lost for instance.
  53535. */
  53536. rebuild(): void;
  53537. /**
  53538. * Serializes the component data to the specified json object
  53539. * @param serializationObject The object to serialize to
  53540. */
  53541. serialize(serializationObject: any): void;
  53542. /**
  53543. * Adds all the elements from the container to the scene
  53544. * @param container the container holding the elements
  53545. */
  53546. addFromContainer(container: AbstractScene): void;
  53547. /**
  53548. * Removes all the elements in the container from the scene
  53549. * @param container contains the elements to remove
  53550. * @param dispose if the removed element should be disposed (default: false)
  53551. */
  53552. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53553. /**
  53554. * Disposes the component and the associated ressources.
  53555. */
  53556. dispose(): void;
  53557. private _isReadyForMesh;
  53558. private _renderMainTexture;
  53559. private _setStencil;
  53560. private _setStencilBack;
  53561. private _draw;
  53562. private _drawCamera;
  53563. private _drawRenderingGroup;
  53564. }
  53565. }
  53566. declare module BABYLON {
  53567. /** @hidden */
  53568. export var glowMapMergePixelShader: {
  53569. name: string;
  53570. shader: string;
  53571. };
  53572. }
  53573. declare module BABYLON {
  53574. /** @hidden */
  53575. export var glowMapMergeVertexShader: {
  53576. name: string;
  53577. shader: string;
  53578. };
  53579. }
  53580. declare module BABYLON {
  53581. interface AbstractScene {
  53582. /**
  53583. * Return a the first highlight layer of the scene with a given name.
  53584. * @param name The name of the highlight layer to look for.
  53585. * @return The highlight layer if found otherwise null.
  53586. */
  53587. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53588. }
  53589. /**
  53590. * Glow layer options. This helps customizing the behaviour
  53591. * of the glow layer.
  53592. */
  53593. export interface IGlowLayerOptions {
  53594. /**
  53595. * Multiplication factor apply to the canvas size to compute the render target size
  53596. * used to generated the glowing objects (the smaller the faster).
  53597. */
  53598. mainTextureRatio: number;
  53599. /**
  53600. * Enforces a fixed size texture to ensure resize independant blur.
  53601. */
  53602. mainTextureFixedSize?: number;
  53603. /**
  53604. * How big is the kernel of the blur texture.
  53605. */
  53606. blurKernelSize: number;
  53607. /**
  53608. * The camera attached to the layer.
  53609. */
  53610. camera: Nullable<Camera>;
  53611. /**
  53612. * Enable MSAA by chosing the number of samples.
  53613. */
  53614. mainTextureSamples?: number;
  53615. /**
  53616. * The rendering group to draw the layer in.
  53617. */
  53618. renderingGroupId: number;
  53619. }
  53620. /**
  53621. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53622. *
  53623. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53624. *
  53625. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53626. */
  53627. export class GlowLayer extends EffectLayer {
  53628. /**
  53629. * Effect Name of the layer.
  53630. */
  53631. static readonly EffectName: string;
  53632. /**
  53633. * The default blur kernel size used for the glow.
  53634. */
  53635. static DefaultBlurKernelSize: number;
  53636. /**
  53637. * The default texture size ratio used for the glow.
  53638. */
  53639. static DefaultTextureRatio: number;
  53640. /**
  53641. * Sets the kernel size of the blur.
  53642. */
  53643. set blurKernelSize(value: number);
  53644. /**
  53645. * Gets the kernel size of the blur.
  53646. */
  53647. get blurKernelSize(): number;
  53648. /**
  53649. * Sets the glow intensity.
  53650. */
  53651. set intensity(value: number);
  53652. /**
  53653. * Gets the glow intensity.
  53654. */
  53655. get intensity(): number;
  53656. private _options;
  53657. private _intensity;
  53658. private _horizontalBlurPostprocess1;
  53659. private _verticalBlurPostprocess1;
  53660. private _horizontalBlurPostprocess2;
  53661. private _verticalBlurPostprocess2;
  53662. private _blurTexture1;
  53663. private _blurTexture2;
  53664. private _postProcesses1;
  53665. private _postProcesses2;
  53666. private _includedOnlyMeshes;
  53667. private _excludedMeshes;
  53668. private _meshesUsingTheirOwnMaterials;
  53669. /**
  53670. * Callback used to let the user override the color selection on a per mesh basis
  53671. */
  53672. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53673. /**
  53674. * Callback used to let the user override the texture selection on a per mesh basis
  53675. */
  53676. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53677. /**
  53678. * Instantiates a new glow Layer and references it to the scene.
  53679. * @param name The name of the layer
  53680. * @param scene The scene to use the layer in
  53681. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53682. */
  53683. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53684. /**
  53685. * Get the effect name of the layer.
  53686. * @return The effect name
  53687. */
  53688. getEffectName(): string;
  53689. /**
  53690. * Create the merge effect. This is the shader use to blit the information back
  53691. * to the main canvas at the end of the scene rendering.
  53692. */
  53693. protected _createMergeEffect(): Effect;
  53694. /**
  53695. * Creates the render target textures and post processes used in the glow layer.
  53696. */
  53697. protected _createTextureAndPostProcesses(): void;
  53698. /**
  53699. * Checks for the readiness of the element composing the layer.
  53700. * @param subMesh the mesh to check for
  53701. * @param useInstances specify wether or not to use instances to render the mesh
  53702. * @param emissiveTexture the associated emissive texture used to generate the glow
  53703. * @return true if ready otherwise, false
  53704. */
  53705. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53706. /**
  53707. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53708. */
  53709. needStencil(): boolean;
  53710. /**
  53711. * Returns true if the mesh can be rendered, otherwise false.
  53712. * @param mesh The mesh to render
  53713. * @param material The material used on the mesh
  53714. * @returns true if it can be rendered otherwise false
  53715. */
  53716. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53717. /**
  53718. * Implementation specific of rendering the generating effect on the main canvas.
  53719. * @param effect The effect used to render through
  53720. */
  53721. protected _internalRender(effect: Effect): void;
  53722. /**
  53723. * Sets the required values for both the emissive texture and and the main color.
  53724. */
  53725. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53726. /**
  53727. * Returns true if the mesh should render, otherwise false.
  53728. * @param mesh The mesh to render
  53729. * @returns true if it should render otherwise false
  53730. */
  53731. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53732. /**
  53733. * Adds specific effects defines.
  53734. * @param defines The defines to add specifics to.
  53735. */
  53736. protected _addCustomEffectDefines(defines: string[]): void;
  53737. /**
  53738. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53739. * @param mesh The mesh to exclude from the glow layer
  53740. */
  53741. addExcludedMesh(mesh: Mesh): void;
  53742. /**
  53743. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53744. * @param mesh The mesh to remove
  53745. */
  53746. removeExcludedMesh(mesh: Mesh): void;
  53747. /**
  53748. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53749. * @param mesh The mesh to include in the glow layer
  53750. */
  53751. addIncludedOnlyMesh(mesh: Mesh): void;
  53752. /**
  53753. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53754. * @param mesh The mesh to remove
  53755. */
  53756. removeIncludedOnlyMesh(mesh: Mesh): void;
  53757. /**
  53758. * Determine if a given mesh will be used in the glow layer
  53759. * @param mesh The mesh to test
  53760. * @returns true if the mesh will be highlighted by the current glow layer
  53761. */
  53762. hasMesh(mesh: AbstractMesh): boolean;
  53763. /**
  53764. * Defines whether the current material of the mesh should be use to render the effect.
  53765. * @param mesh defines the current mesh to render
  53766. */
  53767. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53768. /**
  53769. * Add a mesh to be rendered through its own material and not with emissive only.
  53770. * @param mesh The mesh for which we need to use its material
  53771. */
  53772. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53773. /**
  53774. * Remove a mesh from being rendered through its own material and not with emissive only.
  53775. * @param mesh The mesh for which we need to not use its material
  53776. */
  53777. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53778. /**
  53779. * Free any resources and references associated to a mesh.
  53780. * Internal use
  53781. * @param mesh The mesh to free.
  53782. * @hidden
  53783. */
  53784. _disposeMesh(mesh: Mesh): void;
  53785. /**
  53786. * Gets the class name of the effect layer
  53787. * @returns the string with the class name of the effect layer
  53788. */
  53789. getClassName(): string;
  53790. /**
  53791. * Serializes this glow layer
  53792. * @returns a serialized glow layer object
  53793. */
  53794. serialize(): any;
  53795. /**
  53796. * Creates a Glow Layer from parsed glow layer data
  53797. * @param parsedGlowLayer defines glow layer data
  53798. * @param scene defines the current scene
  53799. * @param rootUrl defines the root URL containing the glow layer information
  53800. * @returns a parsed Glow Layer
  53801. */
  53802. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53803. }
  53804. }
  53805. declare module BABYLON {
  53806. /** @hidden */
  53807. export var glowBlurPostProcessPixelShader: {
  53808. name: string;
  53809. shader: string;
  53810. };
  53811. }
  53812. declare module BABYLON {
  53813. interface AbstractScene {
  53814. /**
  53815. * Return a the first highlight layer of the scene with a given name.
  53816. * @param name The name of the highlight layer to look for.
  53817. * @return The highlight layer if found otherwise null.
  53818. */
  53819. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53820. }
  53821. /**
  53822. * Highlight layer options. This helps customizing the behaviour
  53823. * of the highlight layer.
  53824. */
  53825. export interface IHighlightLayerOptions {
  53826. /**
  53827. * Multiplication factor apply to the canvas size to compute the render target size
  53828. * used to generated the glowing objects (the smaller the faster).
  53829. */
  53830. mainTextureRatio: number;
  53831. /**
  53832. * Enforces a fixed size texture to ensure resize independant blur.
  53833. */
  53834. mainTextureFixedSize?: number;
  53835. /**
  53836. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53837. * of the picture to blur (the smaller the faster).
  53838. */
  53839. blurTextureSizeRatio: number;
  53840. /**
  53841. * How big in texel of the blur texture is the vertical blur.
  53842. */
  53843. blurVerticalSize: number;
  53844. /**
  53845. * How big in texel of the blur texture is the horizontal blur.
  53846. */
  53847. blurHorizontalSize: number;
  53848. /**
  53849. * Alpha blending mode used to apply the blur. Default is combine.
  53850. */
  53851. alphaBlendingMode: number;
  53852. /**
  53853. * The camera attached to the layer.
  53854. */
  53855. camera: Nullable<Camera>;
  53856. /**
  53857. * Should we display highlight as a solid stroke?
  53858. */
  53859. isStroke?: boolean;
  53860. /**
  53861. * The rendering group to draw the layer in.
  53862. */
  53863. renderingGroupId: number;
  53864. }
  53865. /**
  53866. * The highlight layer Helps adding a glow effect around a mesh.
  53867. *
  53868. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53869. * glowy meshes to your scene.
  53870. *
  53871. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53872. */
  53873. export class HighlightLayer extends EffectLayer {
  53874. name: string;
  53875. /**
  53876. * Effect Name of the highlight layer.
  53877. */
  53878. static readonly EffectName: string;
  53879. /**
  53880. * The neutral color used during the preparation of the glow effect.
  53881. * This is black by default as the blend operation is a blend operation.
  53882. */
  53883. static NeutralColor: Color4;
  53884. /**
  53885. * Stencil value used for glowing meshes.
  53886. */
  53887. static GlowingMeshStencilReference: number;
  53888. /**
  53889. * Stencil value used for the other meshes in the scene.
  53890. */
  53891. static NormalMeshStencilReference: number;
  53892. /**
  53893. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53894. */
  53895. innerGlow: boolean;
  53896. /**
  53897. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53898. */
  53899. outerGlow: boolean;
  53900. /**
  53901. * Specifies the horizontal size of the blur.
  53902. */
  53903. set blurHorizontalSize(value: number);
  53904. /**
  53905. * Specifies the vertical size of the blur.
  53906. */
  53907. set blurVerticalSize(value: number);
  53908. /**
  53909. * Gets the horizontal size of the blur.
  53910. */
  53911. get blurHorizontalSize(): number;
  53912. /**
  53913. * Gets the vertical size of the blur.
  53914. */
  53915. get blurVerticalSize(): number;
  53916. /**
  53917. * An event triggered when the highlight layer is being blurred.
  53918. */
  53919. onBeforeBlurObservable: Observable<HighlightLayer>;
  53920. /**
  53921. * An event triggered when the highlight layer has been blurred.
  53922. */
  53923. onAfterBlurObservable: Observable<HighlightLayer>;
  53924. private _instanceGlowingMeshStencilReference;
  53925. private _options;
  53926. private _downSamplePostprocess;
  53927. private _horizontalBlurPostprocess;
  53928. private _verticalBlurPostprocess;
  53929. private _blurTexture;
  53930. private _meshes;
  53931. private _excludedMeshes;
  53932. /**
  53933. * Instantiates a new highlight Layer and references it to the scene..
  53934. * @param name The name of the layer
  53935. * @param scene The scene to use the layer in
  53936. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53937. */
  53938. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53939. /**
  53940. * Get the effect name of the layer.
  53941. * @return The effect name
  53942. */
  53943. getEffectName(): string;
  53944. /**
  53945. * Create the merge effect. This is the shader use to blit the information back
  53946. * to the main canvas at the end of the scene rendering.
  53947. */
  53948. protected _createMergeEffect(): Effect;
  53949. /**
  53950. * Creates the render target textures and post processes used in the highlight layer.
  53951. */
  53952. protected _createTextureAndPostProcesses(): void;
  53953. /**
  53954. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53955. */
  53956. needStencil(): boolean;
  53957. /**
  53958. * Checks for the readiness of the element composing the layer.
  53959. * @param subMesh the mesh to check for
  53960. * @param useInstances specify wether or not to use instances to render the mesh
  53961. * @param emissiveTexture the associated emissive texture used to generate the glow
  53962. * @return true if ready otherwise, false
  53963. */
  53964. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53965. /**
  53966. * Implementation specific of rendering the generating effect on the main canvas.
  53967. * @param effect The effect used to render through
  53968. */
  53969. protected _internalRender(effect: Effect): void;
  53970. /**
  53971. * Returns true if the layer contains information to display, otherwise false.
  53972. */
  53973. shouldRender(): boolean;
  53974. /**
  53975. * Returns true if the mesh should render, otherwise false.
  53976. * @param mesh The mesh to render
  53977. * @returns true if it should render otherwise false
  53978. */
  53979. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53980. /**
  53981. * Sets the required values for both the emissive texture and and the main color.
  53982. */
  53983. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53984. /**
  53985. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53986. * @param mesh The mesh to exclude from the highlight layer
  53987. */
  53988. addExcludedMesh(mesh: Mesh): void;
  53989. /**
  53990. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53991. * @param mesh The mesh to highlight
  53992. */
  53993. removeExcludedMesh(mesh: Mesh): void;
  53994. /**
  53995. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53996. * @param mesh mesh to test
  53997. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53998. */
  53999. hasMesh(mesh: AbstractMesh): boolean;
  54000. /**
  54001. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54002. * @param mesh The mesh to highlight
  54003. * @param color The color of the highlight
  54004. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54005. */
  54006. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54007. /**
  54008. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54009. * @param mesh The mesh to highlight
  54010. */
  54011. removeMesh(mesh: Mesh): void;
  54012. /**
  54013. * Remove all the meshes currently referenced in the highlight layer
  54014. */
  54015. removeAllMeshes(): void;
  54016. /**
  54017. * Force the stencil to the normal expected value for none glowing parts
  54018. */
  54019. private _defaultStencilReference;
  54020. /**
  54021. * Free any resources and references associated to a mesh.
  54022. * Internal use
  54023. * @param mesh The mesh to free.
  54024. * @hidden
  54025. */
  54026. _disposeMesh(mesh: Mesh): void;
  54027. /**
  54028. * Dispose the highlight layer and free resources.
  54029. */
  54030. dispose(): void;
  54031. /**
  54032. * Gets the class name of the effect layer
  54033. * @returns the string with the class name of the effect layer
  54034. */
  54035. getClassName(): string;
  54036. /**
  54037. * Serializes this Highlight layer
  54038. * @returns a serialized Highlight layer object
  54039. */
  54040. serialize(): any;
  54041. /**
  54042. * Creates a Highlight layer from parsed Highlight layer data
  54043. * @param parsedHightlightLayer defines the Highlight layer data
  54044. * @param scene defines the current scene
  54045. * @param rootUrl defines the root URL containing the Highlight layer information
  54046. * @returns a parsed Highlight layer
  54047. */
  54048. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54049. }
  54050. }
  54051. declare module BABYLON {
  54052. interface AbstractScene {
  54053. /**
  54054. * The list of layers (background and foreground) of the scene
  54055. */
  54056. layers: Array<Layer>;
  54057. }
  54058. /**
  54059. * Defines the layer scene component responsible to manage any layers
  54060. * in a given scene.
  54061. */
  54062. export class LayerSceneComponent implements ISceneComponent {
  54063. /**
  54064. * The component name helpfull to identify the component in the list of scene components.
  54065. */
  54066. readonly name: string;
  54067. /**
  54068. * The scene the component belongs to.
  54069. */
  54070. scene: Scene;
  54071. private _engine;
  54072. /**
  54073. * Creates a new instance of the component for the given scene
  54074. * @param scene Defines the scene to register the component in
  54075. */
  54076. constructor(scene: Scene);
  54077. /**
  54078. * Registers the component in a given scene
  54079. */
  54080. register(): void;
  54081. /**
  54082. * Rebuilds the elements related to this component in case of
  54083. * context lost for instance.
  54084. */
  54085. rebuild(): void;
  54086. /**
  54087. * Disposes the component and the associated ressources.
  54088. */
  54089. dispose(): void;
  54090. private _draw;
  54091. private _drawCameraPredicate;
  54092. private _drawCameraBackground;
  54093. private _drawCameraForeground;
  54094. private _drawRenderTargetPredicate;
  54095. private _drawRenderTargetBackground;
  54096. private _drawRenderTargetForeground;
  54097. /**
  54098. * Adds all the elements from the container to the scene
  54099. * @param container the container holding the elements
  54100. */
  54101. addFromContainer(container: AbstractScene): void;
  54102. /**
  54103. * Removes all the elements in the container from the scene
  54104. * @param container contains the elements to remove
  54105. * @param dispose if the removed element should be disposed (default: false)
  54106. */
  54107. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54108. }
  54109. }
  54110. declare module BABYLON {
  54111. /** @hidden */
  54112. export var layerPixelShader: {
  54113. name: string;
  54114. shader: string;
  54115. };
  54116. }
  54117. declare module BABYLON {
  54118. /** @hidden */
  54119. export var layerVertexShader: {
  54120. name: string;
  54121. shader: string;
  54122. };
  54123. }
  54124. declare module BABYLON {
  54125. /**
  54126. * This represents a full screen 2d layer.
  54127. * This can be useful to display a picture in the background of your scene for instance.
  54128. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54129. */
  54130. export class Layer {
  54131. /**
  54132. * Define the name of the layer.
  54133. */
  54134. name: string;
  54135. /**
  54136. * Define the texture the layer should display.
  54137. */
  54138. texture: Nullable<Texture>;
  54139. /**
  54140. * Is the layer in background or foreground.
  54141. */
  54142. isBackground: boolean;
  54143. /**
  54144. * Define the color of the layer (instead of texture).
  54145. */
  54146. color: Color4;
  54147. /**
  54148. * Define the scale of the layer in order to zoom in out of the texture.
  54149. */
  54150. scale: Vector2;
  54151. /**
  54152. * Define an offset for the layer in order to shift the texture.
  54153. */
  54154. offset: Vector2;
  54155. /**
  54156. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54157. */
  54158. alphaBlendingMode: number;
  54159. /**
  54160. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54161. * Alpha test will not mix with the background color in case of transparency.
  54162. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54163. */
  54164. alphaTest: boolean;
  54165. /**
  54166. * Define a mask to restrict the layer to only some of the scene cameras.
  54167. */
  54168. layerMask: number;
  54169. /**
  54170. * Define the list of render target the layer is visible into.
  54171. */
  54172. renderTargetTextures: RenderTargetTexture[];
  54173. /**
  54174. * Define if the layer is only used in renderTarget or if it also
  54175. * renders in the main frame buffer of the canvas.
  54176. */
  54177. renderOnlyInRenderTargetTextures: boolean;
  54178. private _scene;
  54179. private _vertexBuffers;
  54180. private _indexBuffer;
  54181. private _effect;
  54182. private _previousDefines;
  54183. /**
  54184. * An event triggered when the layer is disposed.
  54185. */
  54186. onDisposeObservable: Observable<Layer>;
  54187. private _onDisposeObserver;
  54188. /**
  54189. * Back compatibility with callback before the onDisposeObservable existed.
  54190. * The set callback will be triggered when the layer has been disposed.
  54191. */
  54192. set onDispose(callback: () => void);
  54193. /**
  54194. * An event triggered before rendering the scene
  54195. */
  54196. onBeforeRenderObservable: Observable<Layer>;
  54197. private _onBeforeRenderObserver;
  54198. /**
  54199. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54200. * The set callback will be triggered just before rendering the layer.
  54201. */
  54202. set onBeforeRender(callback: () => void);
  54203. /**
  54204. * An event triggered after rendering the scene
  54205. */
  54206. onAfterRenderObservable: Observable<Layer>;
  54207. private _onAfterRenderObserver;
  54208. /**
  54209. * Back compatibility with callback before the onAfterRenderObservable existed.
  54210. * The set callback will be triggered just after rendering the layer.
  54211. */
  54212. set onAfterRender(callback: () => void);
  54213. /**
  54214. * Instantiates a new layer.
  54215. * This represents a full screen 2d layer.
  54216. * This can be useful to display a picture in the background of your scene for instance.
  54217. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54218. * @param name Define the name of the layer in the scene
  54219. * @param imgUrl Define the url of the texture to display in the layer
  54220. * @param scene Define the scene the layer belongs to
  54221. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54222. * @param color Defines a color for the layer
  54223. */
  54224. constructor(
  54225. /**
  54226. * Define the name of the layer.
  54227. */
  54228. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54229. private _createIndexBuffer;
  54230. /** @hidden */
  54231. _rebuild(): void;
  54232. /**
  54233. * Renders the layer in the scene.
  54234. */
  54235. render(): void;
  54236. /**
  54237. * Disposes and releases the associated ressources.
  54238. */
  54239. dispose(): void;
  54240. }
  54241. }
  54242. declare module BABYLON {
  54243. /** @hidden */
  54244. export var lensFlarePixelShader: {
  54245. name: string;
  54246. shader: string;
  54247. };
  54248. }
  54249. declare module BABYLON {
  54250. /** @hidden */
  54251. export var lensFlareVertexShader: {
  54252. name: string;
  54253. shader: string;
  54254. };
  54255. }
  54256. declare module BABYLON {
  54257. /**
  54258. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54259. * It is usually composed of several `lensFlare`.
  54260. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54261. */
  54262. export class LensFlareSystem {
  54263. /**
  54264. * Define the name of the lens flare system
  54265. */
  54266. name: string;
  54267. /**
  54268. * List of lens flares used in this system.
  54269. */
  54270. lensFlares: LensFlare[];
  54271. /**
  54272. * Define a limit from the border the lens flare can be visible.
  54273. */
  54274. borderLimit: number;
  54275. /**
  54276. * Define a viewport border we do not want to see the lens flare in.
  54277. */
  54278. viewportBorder: number;
  54279. /**
  54280. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54281. */
  54282. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54283. /**
  54284. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54285. */
  54286. layerMask: number;
  54287. /**
  54288. * Define the id of the lens flare system in the scene.
  54289. * (equal to name by default)
  54290. */
  54291. id: string;
  54292. private _scene;
  54293. private _emitter;
  54294. private _vertexBuffers;
  54295. private _indexBuffer;
  54296. private _effect;
  54297. private _positionX;
  54298. private _positionY;
  54299. private _isEnabled;
  54300. /** @hidden */
  54301. static _SceneComponentInitialization: (scene: Scene) => void;
  54302. /**
  54303. * Instantiates a lens flare system.
  54304. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54305. * It is usually composed of several `lensFlare`.
  54306. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54307. * @param name Define the name of the lens flare system in the scene
  54308. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54309. * @param scene Define the scene the lens flare system belongs to
  54310. */
  54311. constructor(
  54312. /**
  54313. * Define the name of the lens flare system
  54314. */
  54315. name: string, emitter: any, scene: Scene);
  54316. /**
  54317. * Define if the lens flare system is enabled.
  54318. */
  54319. get isEnabled(): boolean;
  54320. set isEnabled(value: boolean);
  54321. /**
  54322. * Get the scene the effects belongs to.
  54323. * @returns the scene holding the lens flare system
  54324. */
  54325. getScene(): Scene;
  54326. /**
  54327. * Get the emitter of the lens flare system.
  54328. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54329. * @returns the emitter of the lens flare system
  54330. */
  54331. getEmitter(): any;
  54332. /**
  54333. * Set the emitter of the lens flare system.
  54334. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54335. * @param newEmitter Define the new emitter of the system
  54336. */
  54337. setEmitter(newEmitter: any): void;
  54338. /**
  54339. * Get the lens flare system emitter position.
  54340. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54341. * @returns the position
  54342. */
  54343. getEmitterPosition(): Vector3;
  54344. /**
  54345. * @hidden
  54346. */
  54347. computeEffectivePosition(globalViewport: Viewport): boolean;
  54348. /** @hidden */
  54349. _isVisible(): boolean;
  54350. /**
  54351. * @hidden
  54352. */
  54353. render(): boolean;
  54354. /**
  54355. * Dispose and release the lens flare with its associated resources.
  54356. */
  54357. dispose(): void;
  54358. /**
  54359. * Parse a lens flare system from a JSON repressentation
  54360. * @param parsedLensFlareSystem Define the JSON to parse
  54361. * @param scene Define the scene the parsed system should be instantiated in
  54362. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54363. * @returns the parsed system
  54364. */
  54365. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54366. /**
  54367. * Serialize the current Lens Flare System into a JSON representation.
  54368. * @returns the serialized JSON
  54369. */
  54370. serialize(): any;
  54371. }
  54372. }
  54373. declare module BABYLON {
  54374. /**
  54375. * This represents one of the lens effect in a `lensFlareSystem`.
  54376. * It controls one of the indiviual texture used in the effect.
  54377. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54378. */
  54379. export class LensFlare {
  54380. /**
  54381. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54382. */
  54383. size: number;
  54384. /**
  54385. * 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.
  54386. */
  54387. position: number;
  54388. /**
  54389. * Define the lens color.
  54390. */
  54391. color: Color3;
  54392. /**
  54393. * Define the lens texture.
  54394. */
  54395. texture: Nullable<Texture>;
  54396. /**
  54397. * Define the alpha mode to render this particular lens.
  54398. */
  54399. alphaMode: number;
  54400. private _system;
  54401. /**
  54402. * Creates a new Lens Flare.
  54403. * This represents one of the lens effect in a `lensFlareSystem`.
  54404. * It controls one of the indiviual texture used in the effect.
  54405. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54406. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54407. * @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.
  54408. * @param color Define the lens color
  54409. * @param imgUrl Define the lens texture url
  54410. * @param system Define the `lensFlareSystem` this flare is part of
  54411. * @returns The newly created Lens Flare
  54412. */
  54413. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54414. /**
  54415. * Instantiates a new Lens Flare.
  54416. * This represents one of the lens effect in a `lensFlareSystem`.
  54417. * It controls one of the indiviual texture used in the effect.
  54418. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54419. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54420. * @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.
  54421. * @param color Define the lens color
  54422. * @param imgUrl Define the lens texture url
  54423. * @param system Define the `lensFlareSystem` this flare is part of
  54424. */
  54425. constructor(
  54426. /**
  54427. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54428. */
  54429. size: number,
  54430. /**
  54431. * 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.
  54432. */
  54433. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54434. /**
  54435. * Dispose and release the lens flare with its associated resources.
  54436. */
  54437. dispose(): void;
  54438. }
  54439. }
  54440. declare module BABYLON {
  54441. interface AbstractScene {
  54442. /**
  54443. * The list of lens flare system added to the scene
  54444. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54445. */
  54446. lensFlareSystems: Array<LensFlareSystem>;
  54447. /**
  54448. * Removes the given lens flare system from this scene.
  54449. * @param toRemove The lens flare system to remove
  54450. * @returns The index of the removed lens flare system
  54451. */
  54452. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54453. /**
  54454. * Adds the given lens flare system to this scene
  54455. * @param newLensFlareSystem The lens flare system to add
  54456. */
  54457. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54458. /**
  54459. * Gets a lens flare system using its name
  54460. * @param name defines the name to look for
  54461. * @returns the lens flare system or null if not found
  54462. */
  54463. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54464. /**
  54465. * Gets a lens flare system using its id
  54466. * @param id defines the id to look for
  54467. * @returns the lens flare system or null if not found
  54468. */
  54469. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54470. }
  54471. /**
  54472. * Defines the lens flare scene component responsible to manage any lens flares
  54473. * in a given scene.
  54474. */
  54475. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54476. /**
  54477. * The component name helpfull to identify the component in the list of scene components.
  54478. */
  54479. readonly name: string;
  54480. /**
  54481. * The scene the component belongs to.
  54482. */
  54483. scene: Scene;
  54484. /**
  54485. * Creates a new instance of the component for the given scene
  54486. * @param scene Defines the scene to register the component in
  54487. */
  54488. constructor(scene: Scene);
  54489. /**
  54490. * Registers the component in a given scene
  54491. */
  54492. register(): void;
  54493. /**
  54494. * Rebuilds the elements related to this component in case of
  54495. * context lost for instance.
  54496. */
  54497. rebuild(): void;
  54498. /**
  54499. * Adds all the elements from the container to the scene
  54500. * @param container the container holding the elements
  54501. */
  54502. addFromContainer(container: AbstractScene): void;
  54503. /**
  54504. * Removes all the elements in the container from the scene
  54505. * @param container contains the elements to remove
  54506. * @param dispose if the removed element should be disposed (default: false)
  54507. */
  54508. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54509. /**
  54510. * Serializes the component data to the specified json object
  54511. * @param serializationObject The object to serialize to
  54512. */
  54513. serialize(serializationObject: any): void;
  54514. /**
  54515. * Disposes the component and the associated ressources.
  54516. */
  54517. dispose(): void;
  54518. private _draw;
  54519. }
  54520. }
  54521. declare module BABYLON {
  54522. /** @hidden */
  54523. export var depthPixelShader: {
  54524. name: string;
  54525. shader: string;
  54526. };
  54527. }
  54528. declare module BABYLON {
  54529. /** @hidden */
  54530. export var depthVertexShader: {
  54531. name: string;
  54532. shader: string;
  54533. };
  54534. }
  54535. declare module BABYLON {
  54536. /**
  54537. * This represents a depth renderer in Babylon.
  54538. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54539. */
  54540. export class DepthRenderer {
  54541. private _scene;
  54542. private _depthMap;
  54543. private _effect;
  54544. private readonly _storeNonLinearDepth;
  54545. private readonly _clearColor;
  54546. /** Get if the depth renderer is using packed depth or not */
  54547. readonly isPacked: boolean;
  54548. private _cachedDefines;
  54549. private _camera;
  54550. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54551. enabled: boolean;
  54552. /**
  54553. * Specifiess that the depth renderer will only be used within
  54554. * the camera it is created for.
  54555. * This can help forcing its rendering during the camera processing.
  54556. */
  54557. useOnlyInActiveCamera: boolean;
  54558. /** @hidden */
  54559. static _SceneComponentInitialization: (scene: Scene) => void;
  54560. /**
  54561. * Instantiates a depth renderer
  54562. * @param scene The scene the renderer belongs to
  54563. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54564. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54565. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54566. */
  54567. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54568. /**
  54569. * Creates the depth rendering effect and checks if the effect is ready.
  54570. * @param subMesh The submesh to be used to render the depth map of
  54571. * @param useInstances If multiple world instances should be used
  54572. * @returns if the depth renderer is ready to render the depth map
  54573. */
  54574. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54575. /**
  54576. * Gets the texture which the depth map will be written to.
  54577. * @returns The depth map texture
  54578. */
  54579. getDepthMap(): RenderTargetTexture;
  54580. /**
  54581. * Disposes of the depth renderer.
  54582. */
  54583. dispose(): void;
  54584. }
  54585. }
  54586. declare module BABYLON {
  54587. /** @hidden */
  54588. export var minmaxReduxPixelShader: {
  54589. name: string;
  54590. shader: string;
  54591. };
  54592. }
  54593. declare module BABYLON {
  54594. /**
  54595. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54596. * and maximum values from all values of the texture.
  54597. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54598. * The source values are read from the red channel of the texture.
  54599. */
  54600. export class MinMaxReducer {
  54601. /**
  54602. * Observable triggered when the computation has been performed
  54603. */
  54604. onAfterReductionPerformed: Observable<{
  54605. min: number;
  54606. max: number;
  54607. }>;
  54608. protected _camera: Camera;
  54609. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54610. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54611. protected _postProcessManager: PostProcessManager;
  54612. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54613. protected _forceFullscreenViewport: boolean;
  54614. /**
  54615. * Creates a min/max reducer
  54616. * @param camera The camera to use for the post processes
  54617. */
  54618. constructor(camera: Camera);
  54619. /**
  54620. * Gets the texture used to read the values from.
  54621. */
  54622. get sourceTexture(): Nullable<RenderTargetTexture>;
  54623. /**
  54624. * Sets the source texture to read the values from.
  54625. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54626. * because in such textures '1' value must not be taken into account to compute the maximum
  54627. * as this value is used to clear the texture.
  54628. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54629. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54630. * @param depthRedux Indicates if the texture is a depth texture or not
  54631. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54632. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54633. */
  54634. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54635. /**
  54636. * Defines the refresh rate of the computation.
  54637. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54638. */
  54639. get refreshRate(): number;
  54640. set refreshRate(value: number);
  54641. protected _activated: boolean;
  54642. /**
  54643. * Gets the activation status of the reducer
  54644. */
  54645. get activated(): boolean;
  54646. /**
  54647. * Activates the reduction computation.
  54648. * When activated, the observers registered in onAfterReductionPerformed are
  54649. * called after the compuation is performed
  54650. */
  54651. activate(): void;
  54652. /**
  54653. * Deactivates the reduction computation.
  54654. */
  54655. deactivate(): void;
  54656. /**
  54657. * Disposes the min/max reducer
  54658. * @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.
  54659. */
  54660. dispose(disposeAll?: boolean): void;
  54661. }
  54662. }
  54663. declare module BABYLON {
  54664. /**
  54665. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54666. */
  54667. export class DepthReducer extends MinMaxReducer {
  54668. private _depthRenderer;
  54669. private _depthRendererId;
  54670. /**
  54671. * Gets the depth renderer used for the computation.
  54672. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54673. */
  54674. get depthRenderer(): Nullable<DepthRenderer>;
  54675. /**
  54676. * Creates a depth reducer
  54677. * @param camera The camera used to render the depth texture
  54678. */
  54679. constructor(camera: Camera);
  54680. /**
  54681. * Sets the depth renderer to use to generate the depth map
  54682. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54683. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54684. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54685. */
  54686. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54687. /** @hidden */
  54688. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54689. /**
  54690. * Activates the reduction computation.
  54691. * When activated, the observers registered in onAfterReductionPerformed are
  54692. * called after the compuation is performed
  54693. */
  54694. activate(): void;
  54695. /**
  54696. * Deactivates the reduction computation.
  54697. */
  54698. deactivate(): void;
  54699. /**
  54700. * Disposes the depth reducer
  54701. * @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.
  54702. */
  54703. dispose(disposeAll?: boolean): void;
  54704. }
  54705. }
  54706. declare module BABYLON {
  54707. /**
  54708. * A CSM implementation allowing casting shadows on large scenes.
  54709. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54710. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54711. */
  54712. export class CascadedShadowGenerator extends ShadowGenerator {
  54713. private static readonly frustumCornersNDCSpace;
  54714. /**
  54715. * Name of the CSM class
  54716. */
  54717. static CLASSNAME: string;
  54718. /**
  54719. * Defines the default number of cascades used by the CSM.
  54720. */
  54721. static readonly DEFAULT_CASCADES_COUNT: number;
  54722. /**
  54723. * Defines the minimum number of cascades used by the CSM.
  54724. */
  54725. static readonly MIN_CASCADES_COUNT: number;
  54726. /**
  54727. * Defines the maximum number of cascades used by the CSM.
  54728. */
  54729. static readonly MAX_CASCADES_COUNT: number;
  54730. protected _validateFilter(filter: number): number;
  54731. /**
  54732. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54733. */
  54734. penumbraDarkness: number;
  54735. private _numCascades;
  54736. /**
  54737. * Gets or set the number of cascades used by the CSM.
  54738. */
  54739. get numCascades(): number;
  54740. set numCascades(value: number);
  54741. /**
  54742. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54743. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54744. */
  54745. stabilizeCascades: boolean;
  54746. private _freezeShadowCastersBoundingInfo;
  54747. private _freezeShadowCastersBoundingInfoObservable;
  54748. /**
  54749. * Enables or disables the shadow casters bounding info computation.
  54750. * If your shadow casters don't move, you can disable this feature.
  54751. * If it is enabled, the bounding box computation is done every frame.
  54752. */
  54753. get freezeShadowCastersBoundingInfo(): boolean;
  54754. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54755. private _scbiMin;
  54756. private _scbiMax;
  54757. protected _computeShadowCastersBoundingInfo(): void;
  54758. protected _shadowCastersBoundingInfo: BoundingInfo;
  54759. /**
  54760. * Gets or sets the shadow casters bounding info.
  54761. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54762. * so that the system won't overwrite the bounds you provide
  54763. */
  54764. get shadowCastersBoundingInfo(): BoundingInfo;
  54765. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54766. protected _breaksAreDirty: boolean;
  54767. protected _minDistance: number;
  54768. protected _maxDistance: number;
  54769. /**
  54770. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54771. *
  54772. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54773. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54774. * @param min minimal distance for the breaks (default to 0.)
  54775. * @param max maximal distance for the breaks (default to 1.)
  54776. */
  54777. setMinMaxDistance(min: number, max: number): void;
  54778. /** Gets the minimal distance used in the cascade break computation */
  54779. get minDistance(): number;
  54780. /** Gets the maximal distance used in the cascade break computation */
  54781. get maxDistance(): number;
  54782. /**
  54783. * Gets the class name of that object
  54784. * @returns "CascadedShadowGenerator"
  54785. */
  54786. getClassName(): string;
  54787. private _cascadeMinExtents;
  54788. private _cascadeMaxExtents;
  54789. /**
  54790. * Gets a cascade minimum extents
  54791. * @param cascadeIndex index of the cascade
  54792. * @returns the minimum cascade extents
  54793. */
  54794. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54795. /**
  54796. * Gets a cascade maximum extents
  54797. * @param cascadeIndex index of the cascade
  54798. * @returns the maximum cascade extents
  54799. */
  54800. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54801. private _cascades;
  54802. private _currentLayer;
  54803. private _viewSpaceFrustumsZ;
  54804. private _viewMatrices;
  54805. private _projectionMatrices;
  54806. private _transformMatrices;
  54807. private _transformMatricesAsArray;
  54808. private _frustumLengths;
  54809. private _lightSizeUVCorrection;
  54810. private _depthCorrection;
  54811. private _frustumCornersWorldSpace;
  54812. private _frustumCenter;
  54813. private _shadowCameraPos;
  54814. private _shadowMaxZ;
  54815. /**
  54816. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54817. * It defaults to camera.maxZ
  54818. */
  54819. get shadowMaxZ(): number;
  54820. /**
  54821. * Sets the shadow max z distance.
  54822. */
  54823. set shadowMaxZ(value: number);
  54824. protected _debug: boolean;
  54825. /**
  54826. * Gets or sets the debug flag.
  54827. * When enabled, the cascades are materialized by different colors on the screen.
  54828. */
  54829. get debug(): boolean;
  54830. set debug(dbg: boolean);
  54831. private _depthClamp;
  54832. /**
  54833. * Gets or sets the depth clamping value.
  54834. *
  54835. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54836. * to account for the shadow casters far away.
  54837. *
  54838. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54839. */
  54840. get depthClamp(): boolean;
  54841. set depthClamp(value: boolean);
  54842. private _cascadeBlendPercentage;
  54843. /**
  54844. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54845. * It defaults to 0.1 (10% blending).
  54846. */
  54847. get cascadeBlendPercentage(): number;
  54848. set cascadeBlendPercentage(value: number);
  54849. private _lambda;
  54850. /**
  54851. * Gets or set the lambda parameter.
  54852. * This parameter is used to split the camera frustum and create the cascades.
  54853. * 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.
  54854. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54855. */
  54856. get lambda(): number;
  54857. set lambda(value: number);
  54858. /**
  54859. * Gets the view matrix corresponding to a given cascade
  54860. * @param cascadeNum cascade to retrieve the view matrix from
  54861. * @returns the cascade view matrix
  54862. */
  54863. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54864. /**
  54865. * Gets the projection matrix corresponding to a given cascade
  54866. * @param cascadeNum cascade to retrieve the projection matrix from
  54867. * @returns the cascade projection matrix
  54868. */
  54869. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54870. /**
  54871. * Gets the transformation matrix corresponding to a given cascade
  54872. * @param cascadeNum cascade to retrieve the transformation matrix from
  54873. * @returns the cascade transformation matrix
  54874. */
  54875. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54876. private _depthRenderer;
  54877. /**
  54878. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54879. *
  54880. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54881. *
  54882. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54883. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54884. * @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
  54885. */
  54886. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54887. private _depthReducer;
  54888. private _autoCalcDepthBounds;
  54889. /**
  54890. * Gets or sets the autoCalcDepthBounds property.
  54891. *
  54892. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54893. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54894. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54895. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54896. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54897. */
  54898. get autoCalcDepthBounds(): boolean;
  54899. set autoCalcDepthBounds(value: boolean);
  54900. /**
  54901. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54902. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54903. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54904. * for setting the refresh rate on the renderer yourself!
  54905. */
  54906. get autoCalcDepthBoundsRefreshRate(): number;
  54907. set autoCalcDepthBoundsRefreshRate(value: number);
  54908. /**
  54909. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54910. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54911. * you change the camera near/far planes!
  54912. */
  54913. splitFrustum(): void;
  54914. private _splitFrustum;
  54915. private _computeMatrices;
  54916. private _computeFrustumInWorldSpace;
  54917. private _computeCascadeFrustum;
  54918. /**
  54919. * Support test.
  54920. */
  54921. static get IsSupported(): boolean;
  54922. /** @hidden */
  54923. static _SceneComponentInitialization: (scene: Scene) => void;
  54924. /**
  54925. * Creates a Cascaded Shadow Generator object.
  54926. * A ShadowGenerator is the required tool to use the shadows.
  54927. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54928. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54929. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54930. * @param light The directional light object generating the shadows.
  54931. * @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.
  54932. */
  54933. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54934. protected _initializeGenerator(): void;
  54935. protected _createTargetRenderTexture(): void;
  54936. protected _initializeShadowMap(): void;
  54937. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54938. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54939. /**
  54940. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54941. * @param defines Defines of the material we want to update
  54942. * @param lightIndex Index of the light in the enabled light list of the material
  54943. */
  54944. prepareDefines(defines: any, lightIndex: number): void;
  54945. /**
  54946. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54947. * defined in the generator but impacting the effect).
  54948. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54949. * @param effect The effect we are binfing the information for
  54950. */
  54951. bindShadowLight(lightIndex: string, effect: Effect): void;
  54952. /**
  54953. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54954. * (eq to view projection * shadow projection matrices)
  54955. * @returns The transform matrix used to create the shadow map
  54956. */
  54957. getTransformMatrix(): Matrix;
  54958. /**
  54959. * Disposes the ShadowGenerator.
  54960. * Returns nothing.
  54961. */
  54962. dispose(): void;
  54963. /**
  54964. * Serializes the shadow generator setup to a json object.
  54965. * @returns The serialized JSON object
  54966. */
  54967. serialize(): any;
  54968. /**
  54969. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54970. * @param parsedShadowGenerator The JSON object to parse
  54971. * @param scene The scene to create the shadow map for
  54972. * @returns The parsed shadow generator
  54973. */
  54974. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54975. }
  54976. }
  54977. declare module BABYLON {
  54978. /**
  54979. * Defines the shadow generator component responsible to manage any shadow generators
  54980. * in a given scene.
  54981. */
  54982. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54983. /**
  54984. * The component name helpfull to identify the component in the list of scene components.
  54985. */
  54986. readonly name: string;
  54987. /**
  54988. * The scene the component belongs to.
  54989. */
  54990. scene: Scene;
  54991. /**
  54992. * Creates a new instance of the component for the given scene
  54993. * @param scene Defines the scene to register the component in
  54994. */
  54995. constructor(scene: Scene);
  54996. /**
  54997. * Registers the component in a given scene
  54998. */
  54999. register(): void;
  55000. /**
  55001. * Rebuilds the elements related to this component in case of
  55002. * context lost for instance.
  55003. */
  55004. rebuild(): void;
  55005. /**
  55006. * Serializes the component data to the specified json object
  55007. * @param serializationObject The object to serialize to
  55008. */
  55009. serialize(serializationObject: any): void;
  55010. /**
  55011. * Adds all the elements from the container to the scene
  55012. * @param container the container holding the elements
  55013. */
  55014. addFromContainer(container: AbstractScene): void;
  55015. /**
  55016. * Removes all the elements in the container from the scene
  55017. * @param container contains the elements to remove
  55018. * @param dispose if the removed element should be disposed (default: false)
  55019. */
  55020. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55021. /**
  55022. * Rebuilds the elements related to this component in case of
  55023. * context lost for instance.
  55024. */
  55025. dispose(): void;
  55026. private _gatherRenderTargets;
  55027. }
  55028. }
  55029. declare module BABYLON {
  55030. /**
  55031. * A point light is a light defined by an unique point in world space.
  55032. * The light is emitted in every direction from this point.
  55033. * A good example of a point light is a standard light bulb.
  55034. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55035. */
  55036. export class PointLight extends ShadowLight {
  55037. private _shadowAngle;
  55038. /**
  55039. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55040. * This specifies what angle the shadow will use to be created.
  55041. *
  55042. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55043. */
  55044. get shadowAngle(): number;
  55045. /**
  55046. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55047. * This specifies what angle the shadow will use to be created.
  55048. *
  55049. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55050. */
  55051. set shadowAngle(value: number);
  55052. /**
  55053. * Gets the direction if it has been set.
  55054. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55055. */
  55056. get direction(): Vector3;
  55057. /**
  55058. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55059. */
  55060. set direction(value: Vector3);
  55061. /**
  55062. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55063. * A PointLight emits the light in every direction.
  55064. * It can cast shadows.
  55065. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55066. * ```javascript
  55067. * var pointLight = new PointLight("pl", camera.position, scene);
  55068. * ```
  55069. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55070. * @param name The light friendly name
  55071. * @param position The position of the point light in the scene
  55072. * @param scene The scene the lights belongs to
  55073. */
  55074. constructor(name: string, position: Vector3, scene: Scene);
  55075. /**
  55076. * Returns the string "PointLight"
  55077. * @returns the class name
  55078. */
  55079. getClassName(): string;
  55080. /**
  55081. * Returns the integer 0.
  55082. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55083. */
  55084. getTypeID(): number;
  55085. /**
  55086. * Specifies wether or not the shadowmap should be a cube texture.
  55087. * @returns true if the shadowmap needs to be a cube texture.
  55088. */
  55089. needCube(): boolean;
  55090. /**
  55091. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55092. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55093. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55094. */
  55095. getShadowDirection(faceIndex?: number): Vector3;
  55096. /**
  55097. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55098. * - fov = PI / 2
  55099. * - aspect ratio : 1.0
  55100. * - z-near and far equal to the active camera minZ and maxZ.
  55101. * Returns the PointLight.
  55102. */
  55103. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55104. protected _buildUniformLayout(): void;
  55105. /**
  55106. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55107. * @param effect The effect to update
  55108. * @param lightIndex The index of the light in the effect to update
  55109. * @returns The point light
  55110. */
  55111. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55112. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55113. /**
  55114. * Prepares the list of defines specific to the light type.
  55115. * @param defines the list of defines
  55116. * @param lightIndex defines the index of the light for the effect
  55117. */
  55118. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55119. }
  55120. }
  55121. declare module BABYLON {
  55122. /**
  55123. * Header information of HDR texture files.
  55124. */
  55125. export interface HDRInfo {
  55126. /**
  55127. * The height of the texture in pixels.
  55128. */
  55129. height: number;
  55130. /**
  55131. * The width of the texture in pixels.
  55132. */
  55133. width: number;
  55134. /**
  55135. * The index of the beginning of the data in the binary file.
  55136. */
  55137. dataPosition: number;
  55138. }
  55139. /**
  55140. * This groups tools to convert HDR texture to native colors array.
  55141. */
  55142. export class HDRTools {
  55143. private static Ldexp;
  55144. private static Rgbe2float;
  55145. private static readStringLine;
  55146. /**
  55147. * Reads header information from an RGBE texture stored in a native array.
  55148. * More information on this format are available here:
  55149. * https://en.wikipedia.org/wiki/RGBE_image_format
  55150. *
  55151. * @param uint8array The binary file stored in native array.
  55152. * @return The header information.
  55153. */
  55154. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55155. /**
  55156. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55157. * This RGBE texture needs to store the information as a panorama.
  55158. *
  55159. * More information on this format are available here:
  55160. * https://en.wikipedia.org/wiki/RGBE_image_format
  55161. *
  55162. * @param buffer The binary file stored in an array buffer.
  55163. * @param size The expected size of the extracted cubemap.
  55164. * @return The Cube Map information.
  55165. */
  55166. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55167. /**
  55168. * Returns the pixels data extracted from an RGBE texture.
  55169. * This pixels will be stored left to right up to down in the R G B order in one array.
  55170. *
  55171. * More information on this format are available here:
  55172. * https://en.wikipedia.org/wiki/RGBE_image_format
  55173. *
  55174. * @param uint8array The binary file stored in an array buffer.
  55175. * @param hdrInfo The header information of the file.
  55176. * @return The pixels data in RGB right to left up to down order.
  55177. */
  55178. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55179. private static RGBE_ReadPixels_RLE;
  55180. }
  55181. }
  55182. declare module BABYLON {
  55183. /**
  55184. * This represents a texture coming from an HDR input.
  55185. *
  55186. * The only supported format is currently panorama picture stored in RGBE format.
  55187. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55188. */
  55189. export class HDRCubeTexture extends BaseTexture {
  55190. private static _facesMapping;
  55191. private _generateHarmonics;
  55192. private _noMipmap;
  55193. private _textureMatrix;
  55194. private _size;
  55195. private _onLoad;
  55196. private _onError;
  55197. /**
  55198. * The texture URL.
  55199. */
  55200. url: string;
  55201. /**
  55202. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55203. */
  55204. coordinatesMode: number;
  55205. protected _isBlocking: boolean;
  55206. /**
  55207. * Sets wether or not the texture is blocking during loading.
  55208. */
  55209. set isBlocking(value: boolean);
  55210. /**
  55211. * Gets wether or not the texture is blocking during loading.
  55212. */
  55213. get isBlocking(): boolean;
  55214. protected _rotationY: number;
  55215. /**
  55216. * Sets texture matrix rotation angle around Y axis in radians.
  55217. */
  55218. set rotationY(value: number);
  55219. /**
  55220. * Gets texture matrix rotation angle around Y axis radians.
  55221. */
  55222. get rotationY(): number;
  55223. /**
  55224. * Gets or sets the center of the bounding box associated with the cube texture
  55225. * It must define where the camera used to render the texture was set
  55226. */
  55227. boundingBoxPosition: Vector3;
  55228. private _boundingBoxSize;
  55229. /**
  55230. * Gets or sets the size of the bounding box associated with the cube texture
  55231. * When defined, the cubemap will switch to local mode
  55232. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55233. * @example https://www.babylonjs-playground.com/#RNASML
  55234. */
  55235. set boundingBoxSize(value: Vector3);
  55236. get boundingBoxSize(): Vector3;
  55237. /**
  55238. * Instantiates an HDRTexture from the following parameters.
  55239. *
  55240. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55241. * @param scene The scene the texture will be used in
  55242. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55243. * @param noMipmap Forces to not generate the mipmap if true
  55244. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55245. * @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)
  55246. * @param reserved Reserved flag for internal use.
  55247. */
  55248. 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>);
  55249. /**
  55250. * Get the current class name of the texture useful for serialization or dynamic coding.
  55251. * @returns "HDRCubeTexture"
  55252. */
  55253. getClassName(): string;
  55254. /**
  55255. * Occurs when the file is raw .hdr file.
  55256. */
  55257. private loadTexture;
  55258. clone(): HDRCubeTexture;
  55259. delayLoad(): void;
  55260. /**
  55261. * Get the texture reflection matrix used to rotate/transform the reflection.
  55262. * @returns the reflection matrix
  55263. */
  55264. getReflectionTextureMatrix(): Matrix;
  55265. /**
  55266. * Set the texture reflection matrix used to rotate/transform the reflection.
  55267. * @param value Define the reflection matrix to set
  55268. */
  55269. setReflectionTextureMatrix(value: Matrix): void;
  55270. /**
  55271. * Parses a JSON representation of an HDR Texture in order to create the texture
  55272. * @param parsedTexture Define the JSON representation
  55273. * @param scene Define the scene the texture should be created in
  55274. * @param rootUrl Define the root url in case we need to load relative dependencies
  55275. * @returns the newly created texture after parsing
  55276. */
  55277. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55278. serialize(): any;
  55279. }
  55280. }
  55281. declare module BABYLON {
  55282. /**
  55283. * Class used to control physics engine
  55284. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55285. */
  55286. export class PhysicsEngine implements IPhysicsEngine {
  55287. private _physicsPlugin;
  55288. /**
  55289. * Global value used to control the smallest number supported by the simulation
  55290. */
  55291. static Epsilon: number;
  55292. private _impostors;
  55293. private _joints;
  55294. private _subTimeStep;
  55295. /**
  55296. * Gets the gravity vector used by the simulation
  55297. */
  55298. gravity: Vector3;
  55299. /**
  55300. * Factory used to create the default physics plugin.
  55301. * @returns The default physics plugin
  55302. */
  55303. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55304. /**
  55305. * Creates a new Physics Engine
  55306. * @param gravity defines the gravity vector used by the simulation
  55307. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55308. */
  55309. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55310. /**
  55311. * Sets the gravity vector used by the simulation
  55312. * @param gravity defines the gravity vector to use
  55313. */
  55314. setGravity(gravity: Vector3): void;
  55315. /**
  55316. * Set the time step of the physics engine.
  55317. * Default is 1/60.
  55318. * To slow it down, enter 1/600 for example.
  55319. * To speed it up, 1/30
  55320. * @param newTimeStep defines the new timestep to apply to this world.
  55321. */
  55322. setTimeStep(newTimeStep?: number): void;
  55323. /**
  55324. * Get the time step of the physics engine.
  55325. * @returns the current time step
  55326. */
  55327. getTimeStep(): number;
  55328. /**
  55329. * Set the sub time step of the physics engine.
  55330. * Default is 0 meaning there is no sub steps
  55331. * To increase physics resolution precision, set a small value (like 1 ms)
  55332. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55333. */
  55334. setSubTimeStep(subTimeStep?: number): void;
  55335. /**
  55336. * Get the sub time step of the physics engine.
  55337. * @returns the current sub time step
  55338. */
  55339. getSubTimeStep(): number;
  55340. /**
  55341. * Release all resources
  55342. */
  55343. dispose(): void;
  55344. /**
  55345. * Gets the name of the current physics plugin
  55346. * @returns the name of the plugin
  55347. */
  55348. getPhysicsPluginName(): string;
  55349. /**
  55350. * Adding a new impostor for the impostor tracking.
  55351. * This will be done by the impostor itself.
  55352. * @param impostor the impostor to add
  55353. */
  55354. addImpostor(impostor: PhysicsImpostor): void;
  55355. /**
  55356. * Remove an impostor from the engine.
  55357. * This impostor and its mesh will not longer be updated by the physics engine.
  55358. * @param impostor the impostor to remove
  55359. */
  55360. removeImpostor(impostor: PhysicsImpostor): void;
  55361. /**
  55362. * Add a joint to the physics engine
  55363. * @param mainImpostor defines the main impostor to which the joint is added.
  55364. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55365. * @param joint defines the joint that will connect both impostors.
  55366. */
  55367. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55368. /**
  55369. * Removes a joint from the simulation
  55370. * @param mainImpostor defines the impostor used with the joint
  55371. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55372. * @param joint defines the joint to remove
  55373. */
  55374. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55375. /**
  55376. * Called by the scene. No need to call it.
  55377. * @param delta defines the timespam between frames
  55378. */
  55379. _step(delta: number): void;
  55380. /**
  55381. * Gets the current plugin used to run the simulation
  55382. * @returns current plugin
  55383. */
  55384. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55385. /**
  55386. * Gets the list of physic impostors
  55387. * @returns an array of PhysicsImpostor
  55388. */
  55389. getImpostors(): Array<PhysicsImpostor>;
  55390. /**
  55391. * Gets the impostor for a physics enabled object
  55392. * @param object defines the object impersonated by the impostor
  55393. * @returns the PhysicsImpostor or null if not found
  55394. */
  55395. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55396. /**
  55397. * Gets the impostor for a physics body object
  55398. * @param body defines physics body used by the impostor
  55399. * @returns the PhysicsImpostor or null if not found
  55400. */
  55401. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55402. /**
  55403. * Does a raycast in the physics world
  55404. * @param from when should the ray start?
  55405. * @param to when should the ray end?
  55406. * @returns PhysicsRaycastResult
  55407. */
  55408. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55409. }
  55410. }
  55411. declare module BABYLON {
  55412. /** @hidden */
  55413. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55414. private _useDeltaForWorldStep;
  55415. world: any;
  55416. name: string;
  55417. private _physicsMaterials;
  55418. private _fixedTimeStep;
  55419. private _cannonRaycastResult;
  55420. private _raycastResult;
  55421. private _physicsBodysToRemoveAfterStep;
  55422. BJSCANNON: any;
  55423. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55424. setGravity(gravity: Vector3): void;
  55425. setTimeStep(timeStep: number): void;
  55426. getTimeStep(): number;
  55427. executeStep(delta: number): void;
  55428. private _removeMarkedPhysicsBodiesFromWorld;
  55429. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55430. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55431. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55432. private _processChildMeshes;
  55433. removePhysicsBody(impostor: PhysicsImpostor): void;
  55434. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55435. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55436. private _addMaterial;
  55437. private _checkWithEpsilon;
  55438. private _createShape;
  55439. private _createHeightmap;
  55440. private _minus90X;
  55441. private _plus90X;
  55442. private _tmpPosition;
  55443. private _tmpDeltaPosition;
  55444. private _tmpUnityRotation;
  55445. private _updatePhysicsBodyTransformation;
  55446. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55447. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55448. isSupported(): boolean;
  55449. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55450. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55451. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55452. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55453. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55454. getBodyMass(impostor: PhysicsImpostor): number;
  55455. getBodyFriction(impostor: PhysicsImpostor): number;
  55456. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55457. getBodyRestitution(impostor: PhysicsImpostor): number;
  55458. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55459. sleepBody(impostor: PhysicsImpostor): void;
  55460. wakeUpBody(impostor: PhysicsImpostor): void;
  55461. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55462. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55463. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55464. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55465. getRadius(impostor: PhysicsImpostor): number;
  55466. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55467. dispose(): void;
  55468. private _extendNamespace;
  55469. /**
  55470. * Does a raycast in the physics world
  55471. * @param from when should the ray start?
  55472. * @param to when should the ray end?
  55473. * @returns PhysicsRaycastResult
  55474. */
  55475. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55476. }
  55477. }
  55478. declare module BABYLON {
  55479. /** @hidden */
  55480. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55481. world: any;
  55482. name: string;
  55483. BJSOIMO: any;
  55484. private _raycastResult;
  55485. constructor(iterations?: number, oimoInjection?: any);
  55486. setGravity(gravity: Vector3): void;
  55487. setTimeStep(timeStep: number): void;
  55488. getTimeStep(): number;
  55489. private _tmpImpostorsArray;
  55490. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55491. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55492. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55493. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55494. private _tmpPositionVector;
  55495. removePhysicsBody(impostor: PhysicsImpostor): void;
  55496. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55497. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55498. isSupported(): boolean;
  55499. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55500. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55501. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55502. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55503. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55504. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55505. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55506. getBodyMass(impostor: PhysicsImpostor): number;
  55507. getBodyFriction(impostor: PhysicsImpostor): number;
  55508. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55509. getBodyRestitution(impostor: PhysicsImpostor): number;
  55510. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55511. sleepBody(impostor: PhysicsImpostor): void;
  55512. wakeUpBody(impostor: PhysicsImpostor): void;
  55513. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55514. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55515. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55516. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55517. getRadius(impostor: PhysicsImpostor): number;
  55518. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55519. dispose(): void;
  55520. /**
  55521. * Does a raycast in the physics world
  55522. * @param from when should the ray start?
  55523. * @param to when should the ray end?
  55524. * @returns PhysicsRaycastResult
  55525. */
  55526. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55527. }
  55528. }
  55529. declare module BABYLON {
  55530. /**
  55531. * Class containing static functions to help procedurally build meshes
  55532. */
  55533. export class RibbonBuilder {
  55534. /**
  55535. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55536. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55537. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55538. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55539. * * 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
  55540. * * 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
  55541. * * 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
  55542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55543. * * 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
  55544. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55545. * * 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
  55546. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55547. * * 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
  55548. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55550. * @param name defines the name of the mesh
  55551. * @param options defines the options used to create the mesh
  55552. * @param scene defines the hosting scene
  55553. * @returns the ribbon mesh
  55554. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55555. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55556. */
  55557. static CreateRibbon(name: string, options: {
  55558. pathArray: Vector3[][];
  55559. closeArray?: boolean;
  55560. closePath?: boolean;
  55561. offset?: number;
  55562. updatable?: boolean;
  55563. sideOrientation?: number;
  55564. frontUVs?: Vector4;
  55565. backUVs?: Vector4;
  55566. instance?: Mesh;
  55567. invertUV?: boolean;
  55568. uvs?: Vector2[];
  55569. colors?: Color4[];
  55570. }, scene?: Nullable<Scene>): Mesh;
  55571. }
  55572. }
  55573. declare module BABYLON {
  55574. /**
  55575. * Class containing static functions to help procedurally build meshes
  55576. */
  55577. export class ShapeBuilder {
  55578. /**
  55579. * 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.
  55580. * * 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.
  55581. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55582. * * 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.
  55583. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55584. * * 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
  55585. * * 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
  55586. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55588. * * 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
  55589. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55591. * @param name defines the name of the mesh
  55592. * @param options defines the options used to create the mesh
  55593. * @param scene defines the hosting scene
  55594. * @returns the extruded shape mesh
  55595. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55597. */
  55598. static ExtrudeShape(name: string, options: {
  55599. shape: Vector3[];
  55600. path: Vector3[];
  55601. scale?: number;
  55602. rotation?: number;
  55603. cap?: number;
  55604. updatable?: boolean;
  55605. sideOrientation?: number;
  55606. frontUVs?: Vector4;
  55607. backUVs?: Vector4;
  55608. instance?: Mesh;
  55609. invertUV?: boolean;
  55610. }, scene?: Nullable<Scene>): Mesh;
  55611. /**
  55612. * Creates an custom extruded shape mesh.
  55613. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55614. * * 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.
  55615. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55616. * * 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
  55617. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55618. * * 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
  55619. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55620. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55621. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55622. * * 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
  55623. * * 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
  55624. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55626. * * 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
  55627. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55629. * @param name defines the name of the mesh
  55630. * @param options defines the options used to create the mesh
  55631. * @param scene defines the hosting scene
  55632. * @returns the custom extruded shape mesh
  55633. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55634. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55636. */
  55637. static ExtrudeShapeCustom(name: string, options: {
  55638. shape: Vector3[];
  55639. path: Vector3[];
  55640. scaleFunction?: any;
  55641. rotationFunction?: any;
  55642. ribbonCloseArray?: boolean;
  55643. ribbonClosePath?: boolean;
  55644. cap?: number;
  55645. updatable?: boolean;
  55646. sideOrientation?: number;
  55647. frontUVs?: Vector4;
  55648. backUVs?: Vector4;
  55649. instance?: Mesh;
  55650. invertUV?: boolean;
  55651. }, scene?: Nullable<Scene>): Mesh;
  55652. private static _ExtrudeShapeGeneric;
  55653. }
  55654. }
  55655. declare module BABYLON {
  55656. /**
  55657. * AmmoJS Physics plugin
  55658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55659. * @see https://github.com/kripken/ammo.js/
  55660. */
  55661. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55662. private _useDeltaForWorldStep;
  55663. /**
  55664. * Reference to the Ammo library
  55665. */
  55666. bjsAMMO: any;
  55667. /**
  55668. * Created ammoJS world which physics bodies are added to
  55669. */
  55670. world: any;
  55671. /**
  55672. * Name of the plugin
  55673. */
  55674. name: string;
  55675. private _timeStep;
  55676. private _fixedTimeStep;
  55677. private _maxSteps;
  55678. private _tmpQuaternion;
  55679. private _tmpAmmoTransform;
  55680. private _tmpAmmoQuaternion;
  55681. private _tmpAmmoConcreteContactResultCallback;
  55682. private _collisionConfiguration;
  55683. private _dispatcher;
  55684. private _overlappingPairCache;
  55685. private _solver;
  55686. private _softBodySolver;
  55687. private _tmpAmmoVectorA;
  55688. private _tmpAmmoVectorB;
  55689. private _tmpAmmoVectorC;
  55690. private _tmpAmmoVectorD;
  55691. private _tmpContactCallbackResult;
  55692. private _tmpAmmoVectorRCA;
  55693. private _tmpAmmoVectorRCB;
  55694. private _raycastResult;
  55695. private static readonly DISABLE_COLLISION_FLAG;
  55696. private static readonly KINEMATIC_FLAG;
  55697. private static readonly DISABLE_DEACTIVATION_FLAG;
  55698. /**
  55699. * Initializes the ammoJS plugin
  55700. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55701. * @param ammoInjection can be used to inject your own ammo reference
  55702. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55703. */
  55704. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55705. /**
  55706. * Sets the gravity of the physics world (m/(s^2))
  55707. * @param gravity Gravity to set
  55708. */
  55709. setGravity(gravity: Vector3): void;
  55710. /**
  55711. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55712. * @param timeStep timestep to use in seconds
  55713. */
  55714. setTimeStep(timeStep: number): void;
  55715. /**
  55716. * 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)
  55717. * @param fixedTimeStep fixedTimeStep to use in seconds
  55718. */
  55719. setFixedTimeStep(fixedTimeStep: number): void;
  55720. /**
  55721. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55722. * @param maxSteps the maximum number of steps by the physics engine per frame
  55723. */
  55724. setMaxSteps(maxSteps: number): void;
  55725. /**
  55726. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55727. * @returns the current timestep in seconds
  55728. */
  55729. getTimeStep(): number;
  55730. /**
  55731. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55732. */
  55733. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55734. private _isImpostorInContact;
  55735. private _isImpostorPairInContact;
  55736. private _stepSimulation;
  55737. /**
  55738. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55739. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55740. * After the step the babylon meshes are set to the position of the physics imposters
  55741. * @param delta amount of time to step forward
  55742. * @param impostors array of imposters to update before/after the step
  55743. */
  55744. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55745. /**
  55746. * Update babylon mesh to match physics world object
  55747. * @param impostor imposter to match
  55748. */
  55749. private _afterSoftStep;
  55750. /**
  55751. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55752. * @param impostor imposter to match
  55753. */
  55754. private _ropeStep;
  55755. /**
  55756. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55757. * @param impostor imposter to match
  55758. */
  55759. private _softbodyOrClothStep;
  55760. private _tmpMatrix;
  55761. /**
  55762. * Applies an impulse on the imposter
  55763. * @param impostor imposter to apply impulse to
  55764. * @param force amount of force to be applied to the imposter
  55765. * @param contactPoint the location to apply the impulse on the imposter
  55766. */
  55767. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55768. /**
  55769. * Applies a force on the imposter
  55770. * @param impostor imposter to apply force
  55771. * @param force amount of force to be applied to the imposter
  55772. * @param contactPoint the location to apply the force on the imposter
  55773. */
  55774. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55775. /**
  55776. * Creates a physics body using the plugin
  55777. * @param impostor the imposter to create the physics body on
  55778. */
  55779. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55780. /**
  55781. * Removes the physics body from the imposter and disposes of the body's memory
  55782. * @param impostor imposter to remove the physics body from
  55783. */
  55784. removePhysicsBody(impostor: PhysicsImpostor): void;
  55785. /**
  55786. * Generates a joint
  55787. * @param impostorJoint the imposter joint to create the joint with
  55788. */
  55789. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55790. /**
  55791. * Removes a joint
  55792. * @param impostorJoint the imposter joint to remove the joint from
  55793. */
  55794. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55795. private _addMeshVerts;
  55796. /**
  55797. * Initialise the soft body vertices to match its object's (mesh) vertices
  55798. * Softbody vertices (nodes) are in world space and to match this
  55799. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55800. * @param impostor to create the softbody for
  55801. */
  55802. private _softVertexData;
  55803. /**
  55804. * Create an impostor's soft body
  55805. * @param impostor to create the softbody for
  55806. */
  55807. private _createSoftbody;
  55808. /**
  55809. * Create cloth for an impostor
  55810. * @param impostor to create the softbody for
  55811. */
  55812. private _createCloth;
  55813. /**
  55814. * Create rope for an impostor
  55815. * @param impostor to create the softbody for
  55816. */
  55817. private _createRope;
  55818. /**
  55819. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55820. * @param impostor to create the custom physics shape for
  55821. */
  55822. private _createCustom;
  55823. private _addHullVerts;
  55824. private _createShape;
  55825. /**
  55826. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55827. * @param impostor imposter containing the physics body and babylon object
  55828. */
  55829. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55830. /**
  55831. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55832. * @param impostor imposter containing the physics body and babylon object
  55833. * @param newPosition new position
  55834. * @param newRotation new rotation
  55835. */
  55836. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55837. /**
  55838. * If this plugin is supported
  55839. * @returns true if its supported
  55840. */
  55841. isSupported(): boolean;
  55842. /**
  55843. * Sets the linear velocity of the physics body
  55844. * @param impostor imposter to set the velocity on
  55845. * @param velocity velocity to set
  55846. */
  55847. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55848. /**
  55849. * Sets the angular velocity of the physics body
  55850. * @param impostor imposter to set the velocity on
  55851. * @param velocity velocity to set
  55852. */
  55853. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55854. /**
  55855. * gets the linear velocity
  55856. * @param impostor imposter to get linear velocity from
  55857. * @returns linear velocity
  55858. */
  55859. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55860. /**
  55861. * gets the angular velocity
  55862. * @param impostor imposter to get angular velocity from
  55863. * @returns angular velocity
  55864. */
  55865. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55866. /**
  55867. * Sets the mass of physics body
  55868. * @param impostor imposter to set the mass on
  55869. * @param mass mass to set
  55870. */
  55871. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55872. /**
  55873. * Gets the mass of the physics body
  55874. * @param impostor imposter to get the mass from
  55875. * @returns mass
  55876. */
  55877. getBodyMass(impostor: PhysicsImpostor): number;
  55878. /**
  55879. * Gets friction of the impostor
  55880. * @param impostor impostor to get friction from
  55881. * @returns friction value
  55882. */
  55883. getBodyFriction(impostor: PhysicsImpostor): number;
  55884. /**
  55885. * Sets friction of the impostor
  55886. * @param impostor impostor to set friction on
  55887. * @param friction friction value
  55888. */
  55889. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55890. /**
  55891. * Gets restitution of the impostor
  55892. * @param impostor impostor to get restitution from
  55893. * @returns restitution value
  55894. */
  55895. getBodyRestitution(impostor: PhysicsImpostor): number;
  55896. /**
  55897. * Sets resitution of the impostor
  55898. * @param impostor impostor to set resitution on
  55899. * @param restitution resitution value
  55900. */
  55901. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55902. /**
  55903. * Gets pressure inside the impostor
  55904. * @param impostor impostor to get pressure from
  55905. * @returns pressure value
  55906. */
  55907. getBodyPressure(impostor: PhysicsImpostor): number;
  55908. /**
  55909. * Sets pressure inside a soft body impostor
  55910. * Cloth and rope must remain 0 pressure
  55911. * @param impostor impostor to set pressure on
  55912. * @param pressure pressure value
  55913. */
  55914. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55915. /**
  55916. * Gets stiffness of the impostor
  55917. * @param impostor impostor to get stiffness from
  55918. * @returns pressure value
  55919. */
  55920. getBodyStiffness(impostor: PhysicsImpostor): number;
  55921. /**
  55922. * Sets stiffness of the impostor
  55923. * @param impostor impostor to set stiffness on
  55924. * @param stiffness stiffness value from 0 to 1
  55925. */
  55926. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55927. /**
  55928. * Gets velocityIterations of the impostor
  55929. * @param impostor impostor to get velocity iterations from
  55930. * @returns velocityIterations value
  55931. */
  55932. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55933. /**
  55934. * Sets velocityIterations of the impostor
  55935. * @param impostor impostor to set velocity iterations on
  55936. * @param velocityIterations velocityIterations value
  55937. */
  55938. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55939. /**
  55940. * Gets positionIterations of the impostor
  55941. * @param impostor impostor to get position iterations from
  55942. * @returns positionIterations value
  55943. */
  55944. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55945. /**
  55946. * Sets positionIterations of the impostor
  55947. * @param impostor impostor to set position on
  55948. * @param positionIterations positionIterations value
  55949. */
  55950. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55951. /**
  55952. * Append an anchor to a cloth object
  55953. * @param impostor is the cloth impostor to add anchor to
  55954. * @param otherImpostor is the rigid impostor to anchor to
  55955. * @param width ratio across width from 0 to 1
  55956. * @param height ratio up height from 0 to 1
  55957. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55958. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55959. */
  55960. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55961. /**
  55962. * Append an hook to a rope object
  55963. * @param impostor is the rope impostor to add hook to
  55964. * @param otherImpostor is the rigid impostor to hook to
  55965. * @param length ratio along the rope from 0 to 1
  55966. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55967. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55968. */
  55969. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55970. /**
  55971. * Sleeps the physics body and stops it from being active
  55972. * @param impostor impostor to sleep
  55973. */
  55974. sleepBody(impostor: PhysicsImpostor): void;
  55975. /**
  55976. * Activates the physics body
  55977. * @param impostor impostor to activate
  55978. */
  55979. wakeUpBody(impostor: PhysicsImpostor): void;
  55980. /**
  55981. * Updates the distance parameters of the joint
  55982. * @param joint joint to update
  55983. * @param maxDistance maximum distance of the joint
  55984. * @param minDistance minimum distance of the joint
  55985. */
  55986. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55987. /**
  55988. * Sets a motor on the joint
  55989. * @param joint joint to set motor on
  55990. * @param speed speed of the motor
  55991. * @param maxForce maximum force of the motor
  55992. * @param motorIndex index of the motor
  55993. */
  55994. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55995. /**
  55996. * Sets the motors limit
  55997. * @param joint joint to set limit on
  55998. * @param upperLimit upper limit
  55999. * @param lowerLimit lower limit
  56000. */
  56001. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56002. /**
  56003. * Syncs the position and rotation of a mesh with the impostor
  56004. * @param mesh mesh to sync
  56005. * @param impostor impostor to update the mesh with
  56006. */
  56007. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56008. /**
  56009. * Gets the radius of the impostor
  56010. * @param impostor impostor to get radius from
  56011. * @returns the radius
  56012. */
  56013. getRadius(impostor: PhysicsImpostor): number;
  56014. /**
  56015. * Gets the box size of the impostor
  56016. * @param impostor impostor to get box size from
  56017. * @param result the resulting box size
  56018. */
  56019. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56020. /**
  56021. * Disposes of the impostor
  56022. */
  56023. dispose(): void;
  56024. /**
  56025. * Does a raycast in the physics world
  56026. * @param from when should the ray start?
  56027. * @param to when should the ray end?
  56028. * @returns PhysicsRaycastResult
  56029. */
  56030. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56031. }
  56032. }
  56033. declare module BABYLON {
  56034. interface AbstractScene {
  56035. /**
  56036. * The list of reflection probes added to the scene
  56037. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56038. */
  56039. reflectionProbes: Array<ReflectionProbe>;
  56040. /**
  56041. * Removes the given reflection probe from this scene.
  56042. * @param toRemove The reflection probe to remove
  56043. * @returns The index of the removed reflection probe
  56044. */
  56045. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56046. /**
  56047. * Adds the given reflection probe to this scene.
  56048. * @param newReflectionProbe The reflection probe to add
  56049. */
  56050. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56051. }
  56052. /**
  56053. * Class used to generate realtime reflection / refraction cube textures
  56054. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56055. */
  56056. export class ReflectionProbe {
  56057. /** defines the name of the probe */
  56058. name: string;
  56059. private _scene;
  56060. private _renderTargetTexture;
  56061. private _projectionMatrix;
  56062. private _viewMatrix;
  56063. private _target;
  56064. private _add;
  56065. private _attachedMesh;
  56066. private _invertYAxis;
  56067. /** Gets or sets probe position (center of the cube map) */
  56068. position: Vector3;
  56069. /**
  56070. * Creates a new reflection probe
  56071. * @param name defines the name of the probe
  56072. * @param size defines the texture resolution (for each face)
  56073. * @param scene defines the hosting scene
  56074. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56075. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56076. */
  56077. constructor(
  56078. /** defines the name of the probe */
  56079. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56080. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56081. get samples(): number;
  56082. set samples(value: number);
  56083. /** Gets or sets the refresh rate to use (on every frame by default) */
  56084. get refreshRate(): number;
  56085. set refreshRate(value: number);
  56086. /**
  56087. * Gets the hosting scene
  56088. * @returns a Scene
  56089. */
  56090. getScene(): Scene;
  56091. /** Gets the internal CubeTexture used to render to */
  56092. get cubeTexture(): RenderTargetTexture;
  56093. /** Gets the list of meshes to render */
  56094. get renderList(): Nullable<AbstractMesh[]>;
  56095. /**
  56096. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56097. * @param mesh defines the mesh to attach to
  56098. */
  56099. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56100. /**
  56101. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56102. * @param renderingGroupId The rendering group id corresponding to its index
  56103. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56104. */
  56105. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56106. /**
  56107. * Clean all associated resources
  56108. */
  56109. dispose(): void;
  56110. /**
  56111. * Converts the reflection probe information to a readable string for debug purpose.
  56112. * @param fullDetails Supports for multiple levels of logging within scene loading
  56113. * @returns the human readable reflection probe info
  56114. */
  56115. toString(fullDetails?: boolean): string;
  56116. /**
  56117. * Get the class name of the relfection probe.
  56118. * @returns "ReflectionProbe"
  56119. */
  56120. getClassName(): string;
  56121. /**
  56122. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56123. * @returns The JSON representation of the texture
  56124. */
  56125. serialize(): any;
  56126. /**
  56127. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56128. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56129. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56130. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56131. * @returns The parsed reflection probe if successful
  56132. */
  56133. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56134. }
  56135. }
  56136. declare module BABYLON {
  56137. /** @hidden */
  56138. export var _BabylonLoaderRegistered: boolean;
  56139. /**
  56140. * Helps setting up some configuration for the babylon file loader.
  56141. */
  56142. export class BabylonFileLoaderConfiguration {
  56143. /**
  56144. * The loader does not allow injecting custom physix engine into the plugins.
  56145. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56146. * So you could set this variable to your engine import to make it work.
  56147. */
  56148. static LoaderInjectedPhysicsEngine: any;
  56149. }
  56150. }
  56151. declare module BABYLON {
  56152. /**
  56153. * The Physically based simple base material of BJS.
  56154. *
  56155. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56156. * It is used as the base class for both the specGloss and metalRough conventions.
  56157. */
  56158. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56159. /**
  56160. * Number of Simultaneous lights allowed on the material.
  56161. */
  56162. maxSimultaneousLights: number;
  56163. /**
  56164. * If sets to true, disables all the lights affecting the material.
  56165. */
  56166. disableLighting: boolean;
  56167. /**
  56168. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56169. */
  56170. environmentTexture: BaseTexture;
  56171. /**
  56172. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56173. */
  56174. invertNormalMapX: boolean;
  56175. /**
  56176. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56177. */
  56178. invertNormalMapY: boolean;
  56179. /**
  56180. * Normal map used in the model.
  56181. */
  56182. normalTexture: BaseTexture;
  56183. /**
  56184. * Emissivie color used to self-illuminate the model.
  56185. */
  56186. emissiveColor: Color3;
  56187. /**
  56188. * Emissivie texture used to self-illuminate the model.
  56189. */
  56190. emissiveTexture: BaseTexture;
  56191. /**
  56192. * Occlusion Channel Strenght.
  56193. */
  56194. occlusionStrength: number;
  56195. /**
  56196. * Occlusion Texture of the material (adding extra occlusion effects).
  56197. */
  56198. occlusionTexture: BaseTexture;
  56199. /**
  56200. * Defines the alpha limits in alpha test mode.
  56201. */
  56202. alphaCutOff: number;
  56203. /**
  56204. * Gets the current double sided mode.
  56205. */
  56206. get doubleSided(): boolean;
  56207. /**
  56208. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56209. */
  56210. set doubleSided(value: boolean);
  56211. /**
  56212. * Stores the pre-calculated light information of a mesh in a texture.
  56213. */
  56214. lightmapTexture: BaseTexture;
  56215. /**
  56216. * If true, the light map contains occlusion information instead of lighting info.
  56217. */
  56218. useLightmapAsShadowmap: boolean;
  56219. /**
  56220. * Instantiates a new PBRMaterial instance.
  56221. *
  56222. * @param name The material name
  56223. * @param scene The scene the material will be use in.
  56224. */
  56225. constructor(name: string, scene: Scene);
  56226. getClassName(): string;
  56227. }
  56228. }
  56229. declare module BABYLON {
  56230. /**
  56231. * The PBR material of BJS following the metal roughness convention.
  56232. *
  56233. * This fits to the PBR convention in the GLTF definition:
  56234. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56235. */
  56236. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56237. /**
  56238. * The base color has two different interpretations depending on the value of metalness.
  56239. * When the material is a metal, the base color is the specific measured reflectance value
  56240. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56241. * of the material.
  56242. */
  56243. baseColor: Color3;
  56244. /**
  56245. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56246. * well as opacity information in the alpha channel.
  56247. */
  56248. baseTexture: BaseTexture;
  56249. /**
  56250. * Specifies the metallic scalar value of the material.
  56251. * Can also be used to scale the metalness values of the metallic texture.
  56252. */
  56253. metallic: number;
  56254. /**
  56255. * Specifies the roughness scalar value of the material.
  56256. * Can also be used to scale the roughness values of the metallic texture.
  56257. */
  56258. roughness: number;
  56259. /**
  56260. * Texture containing both the metallic value in the B channel and the
  56261. * roughness value in the G channel to keep better precision.
  56262. */
  56263. metallicRoughnessTexture: BaseTexture;
  56264. /**
  56265. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56266. *
  56267. * @param name The material name
  56268. * @param scene The scene the material will be use in.
  56269. */
  56270. constructor(name: string, scene: Scene);
  56271. /**
  56272. * Return the currrent class name of the material.
  56273. */
  56274. getClassName(): string;
  56275. /**
  56276. * Makes a duplicate of the current material.
  56277. * @param name - name to use for the new material.
  56278. */
  56279. clone(name: string): PBRMetallicRoughnessMaterial;
  56280. /**
  56281. * Serialize the material to a parsable JSON object.
  56282. */
  56283. serialize(): any;
  56284. /**
  56285. * Parses a JSON object correponding to the serialize function.
  56286. */
  56287. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56288. }
  56289. }
  56290. declare module BABYLON {
  56291. /**
  56292. * The PBR material of BJS following the specular glossiness convention.
  56293. *
  56294. * This fits to the PBR convention in the GLTF definition:
  56295. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56296. */
  56297. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56298. /**
  56299. * Specifies the diffuse color of the material.
  56300. */
  56301. diffuseColor: Color3;
  56302. /**
  56303. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56304. * channel.
  56305. */
  56306. diffuseTexture: BaseTexture;
  56307. /**
  56308. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56309. */
  56310. specularColor: Color3;
  56311. /**
  56312. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56313. */
  56314. glossiness: number;
  56315. /**
  56316. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56317. */
  56318. specularGlossinessTexture: BaseTexture;
  56319. /**
  56320. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56321. *
  56322. * @param name The material name
  56323. * @param scene The scene the material will be use in.
  56324. */
  56325. constructor(name: string, scene: Scene);
  56326. /**
  56327. * Return the currrent class name of the material.
  56328. */
  56329. getClassName(): string;
  56330. /**
  56331. * Makes a duplicate of the current material.
  56332. * @param name - name to use for the new material.
  56333. */
  56334. clone(name: string): PBRSpecularGlossinessMaterial;
  56335. /**
  56336. * Serialize the material to a parsable JSON object.
  56337. */
  56338. serialize(): any;
  56339. /**
  56340. * Parses a JSON object correponding to the serialize function.
  56341. */
  56342. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56343. }
  56344. }
  56345. declare module BABYLON {
  56346. /**
  56347. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56348. * It can help converting any input color in a desired output one. This can then be used to create effects
  56349. * from sepia, black and white to sixties or futuristic rendering...
  56350. *
  56351. * The only supported format is currently 3dl.
  56352. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56353. */
  56354. export class ColorGradingTexture extends BaseTexture {
  56355. /**
  56356. * The current texture matrix. (will always be identity in color grading texture)
  56357. */
  56358. private _textureMatrix;
  56359. /**
  56360. * The texture URL.
  56361. */
  56362. url: string;
  56363. /**
  56364. * Empty line regex stored for GC.
  56365. */
  56366. private static _noneEmptyLineRegex;
  56367. private _engine;
  56368. /**
  56369. * Instantiates a ColorGradingTexture from the following parameters.
  56370. *
  56371. * @param url The location of the color gradind data (currently only supporting 3dl)
  56372. * @param scene The scene the texture will be used in
  56373. */
  56374. constructor(url: string, scene: Scene);
  56375. /**
  56376. * Returns the texture matrix used in most of the material.
  56377. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56378. */
  56379. getTextureMatrix(): Matrix;
  56380. /**
  56381. * Occurs when the file being loaded is a .3dl LUT file.
  56382. */
  56383. private load3dlTexture;
  56384. /**
  56385. * Starts the loading process of the texture.
  56386. */
  56387. private loadTexture;
  56388. /**
  56389. * Clones the color gradind texture.
  56390. */
  56391. clone(): ColorGradingTexture;
  56392. /**
  56393. * Called during delayed load for textures.
  56394. */
  56395. delayLoad(): void;
  56396. /**
  56397. * Parses a color grading texture serialized by Babylon.
  56398. * @param parsedTexture The texture information being parsedTexture
  56399. * @param scene The scene to load the texture in
  56400. * @param rootUrl The root url of the data assets to load
  56401. * @return A color gradind texture
  56402. */
  56403. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56404. /**
  56405. * Serializes the LUT texture to json format.
  56406. */
  56407. serialize(): any;
  56408. }
  56409. }
  56410. declare module BABYLON {
  56411. /**
  56412. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56413. */
  56414. export class EquiRectangularCubeTexture extends BaseTexture {
  56415. /** The six faces of the cube. */
  56416. private static _FacesMapping;
  56417. private _noMipmap;
  56418. private _onLoad;
  56419. private _onError;
  56420. /** The size of the cubemap. */
  56421. private _size;
  56422. /** The buffer of the image. */
  56423. private _buffer;
  56424. /** The width of the input image. */
  56425. private _width;
  56426. /** The height of the input image. */
  56427. private _height;
  56428. /** The URL to the image. */
  56429. url: string;
  56430. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56431. coordinatesMode: number;
  56432. /**
  56433. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56434. * @param url The location of the image
  56435. * @param scene The scene the texture will be used in
  56436. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56437. * @param noMipmap Forces to not generate the mipmap if true
  56438. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56439. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56440. * @param onLoad — defines a callback called when texture is loaded
  56441. * @param onError — defines a callback called if there is an error
  56442. */
  56443. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56444. /**
  56445. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56446. */
  56447. private loadImage;
  56448. /**
  56449. * Convert the image buffer into a cubemap and create a CubeTexture.
  56450. */
  56451. private loadTexture;
  56452. /**
  56453. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56454. * @param buffer The ArrayBuffer that should be converted.
  56455. * @returns The buffer as Float32Array.
  56456. */
  56457. private getFloat32ArrayFromArrayBuffer;
  56458. /**
  56459. * Get the current class name of the texture useful for serialization or dynamic coding.
  56460. * @returns "EquiRectangularCubeTexture"
  56461. */
  56462. getClassName(): string;
  56463. /**
  56464. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56465. * @returns A clone of the current EquiRectangularCubeTexture.
  56466. */
  56467. clone(): EquiRectangularCubeTexture;
  56468. }
  56469. }
  56470. declare module BABYLON {
  56471. /**
  56472. * Based on jsTGALoader - Javascript loader for TGA file
  56473. * By Vincent Thibault
  56474. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56475. */
  56476. export class TGATools {
  56477. private static _TYPE_INDEXED;
  56478. private static _TYPE_RGB;
  56479. private static _TYPE_GREY;
  56480. private static _TYPE_RLE_INDEXED;
  56481. private static _TYPE_RLE_RGB;
  56482. private static _TYPE_RLE_GREY;
  56483. private static _ORIGIN_MASK;
  56484. private static _ORIGIN_SHIFT;
  56485. private static _ORIGIN_BL;
  56486. private static _ORIGIN_BR;
  56487. private static _ORIGIN_UL;
  56488. private static _ORIGIN_UR;
  56489. /**
  56490. * Gets the header of a TGA file
  56491. * @param data defines the TGA data
  56492. * @returns the header
  56493. */
  56494. static GetTGAHeader(data: Uint8Array): any;
  56495. /**
  56496. * Uploads TGA content to a Babylon Texture
  56497. * @hidden
  56498. */
  56499. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56500. /** @hidden */
  56501. 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;
  56502. /** @hidden */
  56503. 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;
  56504. /** @hidden */
  56505. 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;
  56506. /** @hidden */
  56507. 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;
  56508. /** @hidden */
  56509. 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;
  56510. /** @hidden */
  56511. 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;
  56512. }
  56513. }
  56514. declare module BABYLON {
  56515. /**
  56516. * Implementation of the TGA Texture Loader.
  56517. * @hidden
  56518. */
  56519. export class _TGATextureLoader implements IInternalTextureLoader {
  56520. /**
  56521. * Defines wether the loader supports cascade loading the different faces.
  56522. */
  56523. readonly supportCascades: boolean;
  56524. /**
  56525. * This returns if the loader support the current file information.
  56526. * @param extension defines the file extension of the file being loaded
  56527. * @returns true if the loader can load the specified file
  56528. */
  56529. canLoad(extension: string): boolean;
  56530. /**
  56531. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56532. * @param data contains the texture data
  56533. * @param texture defines the BabylonJS internal texture
  56534. * @param createPolynomials will be true if polynomials have been requested
  56535. * @param onLoad defines the callback to trigger once the texture is ready
  56536. * @param onError defines the callback to trigger in case of error
  56537. */
  56538. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56539. /**
  56540. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56541. * @param data contains the texture data
  56542. * @param texture defines the BabylonJS internal texture
  56543. * @param callback defines the method to call once ready to upload
  56544. */
  56545. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56546. }
  56547. }
  56548. declare module BABYLON {
  56549. /**
  56550. * Info about the .basis files
  56551. */
  56552. class BasisFileInfo {
  56553. /**
  56554. * If the file has alpha
  56555. */
  56556. hasAlpha: boolean;
  56557. /**
  56558. * Info about each image of the basis file
  56559. */
  56560. images: Array<{
  56561. levels: Array<{
  56562. width: number;
  56563. height: number;
  56564. transcodedPixels: ArrayBufferView;
  56565. }>;
  56566. }>;
  56567. }
  56568. /**
  56569. * Result of transcoding a basis file
  56570. */
  56571. class TranscodeResult {
  56572. /**
  56573. * Info about the .basis file
  56574. */
  56575. fileInfo: BasisFileInfo;
  56576. /**
  56577. * Format to use when loading the file
  56578. */
  56579. format: number;
  56580. }
  56581. /**
  56582. * Configuration options for the Basis transcoder
  56583. */
  56584. export class BasisTranscodeConfiguration {
  56585. /**
  56586. * Supported compression formats used to determine the supported output format of the transcoder
  56587. */
  56588. supportedCompressionFormats?: {
  56589. /**
  56590. * etc1 compression format
  56591. */
  56592. etc1?: boolean;
  56593. /**
  56594. * s3tc compression format
  56595. */
  56596. s3tc?: boolean;
  56597. /**
  56598. * pvrtc compression format
  56599. */
  56600. pvrtc?: boolean;
  56601. /**
  56602. * etc2 compression format
  56603. */
  56604. etc2?: boolean;
  56605. };
  56606. /**
  56607. * If mipmap levels should be loaded for transcoded images (Default: true)
  56608. */
  56609. loadMipmapLevels?: boolean;
  56610. /**
  56611. * Index of a single image to load (Default: all images)
  56612. */
  56613. loadSingleImage?: number;
  56614. }
  56615. /**
  56616. * Used to load .Basis files
  56617. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56618. */
  56619. export class BasisTools {
  56620. private static _IgnoreSupportedFormats;
  56621. /**
  56622. * URL to use when loading the basis transcoder
  56623. */
  56624. static JSModuleURL: string;
  56625. /**
  56626. * URL to use when loading the wasm module for the transcoder
  56627. */
  56628. static WasmModuleURL: string;
  56629. /**
  56630. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56631. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56632. * @returns internal format corresponding to the Basis format
  56633. */
  56634. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56635. private static _WorkerPromise;
  56636. private static _Worker;
  56637. private static _actionId;
  56638. private static _CreateWorkerAsync;
  56639. /**
  56640. * Transcodes a loaded image file to compressed pixel data
  56641. * @param data image data to transcode
  56642. * @param config configuration options for the transcoding
  56643. * @returns a promise resulting in the transcoded image
  56644. */
  56645. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56646. /**
  56647. * Loads a texture from the transcode result
  56648. * @param texture texture load to
  56649. * @param transcodeResult the result of transcoding the basis file to load from
  56650. */
  56651. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56652. }
  56653. }
  56654. declare module BABYLON {
  56655. /**
  56656. * Loader for .basis file format
  56657. */
  56658. export class _BasisTextureLoader implements IInternalTextureLoader {
  56659. /**
  56660. * Defines whether the loader supports cascade loading the different faces.
  56661. */
  56662. readonly supportCascades: boolean;
  56663. /**
  56664. * This returns if the loader support the current file information.
  56665. * @param extension defines the file extension of the file being loaded
  56666. * @returns true if the loader can load the specified file
  56667. */
  56668. canLoad(extension: string): boolean;
  56669. /**
  56670. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56671. * @param data contains the texture data
  56672. * @param texture defines the BabylonJS internal texture
  56673. * @param createPolynomials will be true if polynomials have been requested
  56674. * @param onLoad defines the callback to trigger once the texture is ready
  56675. * @param onError defines the callback to trigger in case of error
  56676. */
  56677. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56678. /**
  56679. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56680. * @param data contains the texture data
  56681. * @param texture defines the BabylonJS internal texture
  56682. * @param callback defines the method to call once ready to upload
  56683. */
  56684. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56685. }
  56686. }
  56687. declare module BABYLON {
  56688. /**
  56689. * 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.
  56690. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56691. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56692. */
  56693. export class CustomProceduralTexture extends ProceduralTexture {
  56694. private _animate;
  56695. private _time;
  56696. private _config;
  56697. private _texturePath;
  56698. /**
  56699. * Instantiates a new Custom Procedural Texture.
  56700. * 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.
  56701. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56702. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56703. * @param name Define the name of the texture
  56704. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56705. * @param size Define the size of the texture to create
  56706. * @param scene Define the scene the texture belongs to
  56707. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56708. * @param generateMipMaps Define if the texture should creates mip maps or not
  56709. */
  56710. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56711. private _loadJson;
  56712. /**
  56713. * Is the texture ready to be used ? (rendered at least once)
  56714. * @returns true if ready, otherwise, false.
  56715. */
  56716. isReady(): boolean;
  56717. /**
  56718. * Render the texture to its associated render target.
  56719. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56720. */
  56721. render(useCameraPostProcess?: boolean): void;
  56722. /**
  56723. * Update the list of dependant textures samplers in the shader.
  56724. */
  56725. updateTextures(): void;
  56726. /**
  56727. * Update the uniform values of the procedural texture in the shader.
  56728. */
  56729. updateShaderUniforms(): void;
  56730. /**
  56731. * Define if the texture animates or not.
  56732. */
  56733. get animate(): boolean;
  56734. set animate(value: boolean);
  56735. }
  56736. }
  56737. declare module BABYLON {
  56738. /** @hidden */
  56739. export var noisePixelShader: {
  56740. name: string;
  56741. shader: string;
  56742. };
  56743. }
  56744. declare module BABYLON {
  56745. /**
  56746. * Class used to generate noise procedural textures
  56747. */
  56748. export class NoiseProceduralTexture extends ProceduralTexture {
  56749. private _time;
  56750. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56751. brightness: number;
  56752. /** Defines the number of octaves to process */
  56753. octaves: number;
  56754. /** Defines the level of persistence (0.8 by default) */
  56755. persistence: number;
  56756. /** Gets or sets animation speed factor (default is 1) */
  56757. animationSpeedFactor: number;
  56758. /**
  56759. * Creates a new NoiseProceduralTexture
  56760. * @param name defines the name fo the texture
  56761. * @param size defines the size of the texture (default is 256)
  56762. * @param scene defines the hosting scene
  56763. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56764. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56765. */
  56766. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56767. private _updateShaderUniforms;
  56768. protected _getDefines(): string;
  56769. /** Generate the current state of the procedural texture */
  56770. render(useCameraPostProcess?: boolean): void;
  56771. /**
  56772. * Serializes this noise procedural texture
  56773. * @returns a serialized noise procedural texture object
  56774. */
  56775. serialize(): any;
  56776. /**
  56777. * Clone the texture.
  56778. * @returns the cloned texture
  56779. */
  56780. clone(): NoiseProceduralTexture;
  56781. /**
  56782. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56783. * @param parsedTexture defines parsed texture data
  56784. * @param scene defines the current scene
  56785. * @param rootUrl defines the root URL containing noise procedural texture information
  56786. * @returns a parsed NoiseProceduralTexture
  56787. */
  56788. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56789. }
  56790. }
  56791. declare module BABYLON {
  56792. /**
  56793. * Raw cube texture where the raw buffers are passed in
  56794. */
  56795. export class RawCubeTexture extends CubeTexture {
  56796. /**
  56797. * Creates a cube texture where the raw buffers are passed in.
  56798. * @param scene defines the scene the texture is attached to
  56799. * @param data defines the array of data to use to create each face
  56800. * @param size defines the size of the textures
  56801. * @param format defines the format of the data
  56802. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56803. * @param generateMipMaps defines if the engine should generate the mip levels
  56804. * @param invertY defines if data must be stored with Y axis inverted
  56805. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56806. * @param compression defines the compression used (null by default)
  56807. */
  56808. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56809. /**
  56810. * Updates the raw cube texture.
  56811. * @param data defines the data to store
  56812. * @param format defines the data format
  56813. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56814. * @param invertY defines if data must be stored with Y axis inverted
  56815. * @param compression defines the compression used (null by default)
  56816. * @param level defines which level of the texture to update
  56817. */
  56818. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56819. /**
  56820. * Updates a raw cube texture with RGBD encoded data.
  56821. * @param data defines the array of data [mipmap][face] to use to create each face
  56822. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56823. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56824. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56825. * @returns a promsie that resolves when the operation is complete
  56826. */
  56827. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56828. /**
  56829. * Clones the raw cube texture.
  56830. * @return a new cube texture
  56831. */
  56832. clone(): CubeTexture;
  56833. /** @hidden */
  56834. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56835. }
  56836. }
  56837. declare module BABYLON {
  56838. /**
  56839. * Class used to store 3D textures containing user data
  56840. */
  56841. export class RawTexture3D extends Texture {
  56842. /** Gets or sets the texture format to use */
  56843. format: number;
  56844. private _engine;
  56845. /**
  56846. * Create a new RawTexture3D
  56847. * @param data defines the data of the texture
  56848. * @param width defines the width of the texture
  56849. * @param height defines the height of the texture
  56850. * @param depth defines the depth of the texture
  56851. * @param format defines the texture format to use
  56852. * @param scene defines the hosting scene
  56853. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56854. * @param invertY defines if texture must be stored with Y axis inverted
  56855. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56856. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56857. */
  56858. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56859. /** Gets or sets the texture format to use */
  56860. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56861. /**
  56862. * Update the texture with new data
  56863. * @param data defines the data to store in the texture
  56864. */
  56865. update(data: ArrayBufferView): void;
  56866. }
  56867. }
  56868. declare module BABYLON {
  56869. /**
  56870. * Class used to store 2D array textures containing user data
  56871. */
  56872. export class RawTexture2DArray extends Texture {
  56873. /** Gets or sets the texture format to use */
  56874. format: number;
  56875. private _engine;
  56876. /**
  56877. * Create a new RawTexture2DArray
  56878. * @param data defines the data of the texture
  56879. * @param width defines the width of the texture
  56880. * @param height defines the height of the texture
  56881. * @param depth defines the number of layers of the texture
  56882. * @param format defines the texture format to use
  56883. * @param scene defines the hosting scene
  56884. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56885. * @param invertY defines if texture must be stored with Y axis inverted
  56886. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56887. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56888. */
  56889. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56890. /** Gets or sets the texture format to use */
  56891. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56892. /**
  56893. * Update the texture with new data
  56894. * @param data defines the data to store in the texture
  56895. */
  56896. update(data: ArrayBufferView): void;
  56897. }
  56898. }
  56899. declare module BABYLON {
  56900. /**
  56901. * Creates a refraction texture used by refraction channel of the standard material.
  56902. * It is like a mirror but to see through a material.
  56903. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56904. */
  56905. export class RefractionTexture extends RenderTargetTexture {
  56906. /**
  56907. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56908. * 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.
  56909. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56910. */
  56911. refractionPlane: Plane;
  56912. /**
  56913. * Define how deep under the surface we should see.
  56914. */
  56915. depth: number;
  56916. /**
  56917. * Creates a refraction texture used by refraction channel of the standard material.
  56918. * It is like a mirror but to see through a material.
  56919. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56920. * @param name Define the texture name
  56921. * @param size Define the size of the underlying texture
  56922. * @param scene Define the scene the refraction belongs to
  56923. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56924. */
  56925. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56926. /**
  56927. * Clone the refraction texture.
  56928. * @returns the cloned texture
  56929. */
  56930. clone(): RefractionTexture;
  56931. /**
  56932. * Serialize the texture to a JSON representation you could use in Parse later on
  56933. * @returns the serialized JSON representation
  56934. */
  56935. serialize(): any;
  56936. }
  56937. }
  56938. declare module BABYLON {
  56939. /**
  56940. * Defines the options related to the creation of an HtmlElementTexture
  56941. */
  56942. export interface IHtmlElementTextureOptions {
  56943. /**
  56944. * Defines wether mip maps should be created or not.
  56945. */
  56946. generateMipMaps?: boolean;
  56947. /**
  56948. * Defines the sampling mode of the texture.
  56949. */
  56950. samplingMode?: number;
  56951. /**
  56952. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56953. */
  56954. engine: Nullable<ThinEngine>;
  56955. /**
  56956. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56957. */
  56958. scene: Nullable<Scene>;
  56959. }
  56960. /**
  56961. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56962. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56963. * is automatically managed.
  56964. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56965. * in your application.
  56966. *
  56967. * As the update is not automatic, you need to call them manually.
  56968. */
  56969. export class HtmlElementTexture extends BaseTexture {
  56970. /**
  56971. * The texture URL.
  56972. */
  56973. element: HTMLVideoElement | HTMLCanvasElement;
  56974. private static readonly DefaultOptions;
  56975. private _textureMatrix;
  56976. private _engine;
  56977. private _isVideo;
  56978. private _generateMipMaps;
  56979. private _samplingMode;
  56980. /**
  56981. * Instantiates a HtmlElementTexture from the following parameters.
  56982. *
  56983. * @param name Defines the name of the texture
  56984. * @param element Defines the video or canvas the texture is filled with
  56985. * @param options Defines the other none mandatory texture creation options
  56986. */
  56987. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56988. private _createInternalTexture;
  56989. /**
  56990. * Returns the texture matrix used in most of the material.
  56991. */
  56992. getTextureMatrix(): Matrix;
  56993. /**
  56994. * Updates the content of the texture.
  56995. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56996. */
  56997. update(invertY?: Nullable<boolean>): void;
  56998. }
  56999. }
  57000. declare module BABYLON {
  57001. /**
  57002. * Defines the basic options interface of a TexturePacker Frame
  57003. */
  57004. export interface ITexturePackerFrame {
  57005. /**
  57006. * The frame ID
  57007. */
  57008. id: number;
  57009. /**
  57010. * The frames Scale
  57011. */
  57012. scale: Vector2;
  57013. /**
  57014. * The Frames offset
  57015. */
  57016. offset: Vector2;
  57017. }
  57018. /**
  57019. * This is a support class for frame Data on texture packer sets.
  57020. */
  57021. export class TexturePackerFrame implements ITexturePackerFrame {
  57022. /**
  57023. * The frame ID
  57024. */
  57025. id: number;
  57026. /**
  57027. * The frames Scale
  57028. */
  57029. scale: Vector2;
  57030. /**
  57031. * The Frames offset
  57032. */
  57033. offset: Vector2;
  57034. /**
  57035. * Initializes a texture package frame.
  57036. * @param id The numerical frame identifier
  57037. * @param scale Scalar Vector2 for UV frame
  57038. * @param offset Vector2 for the frame position in UV units.
  57039. * @returns TexturePackerFrame
  57040. */
  57041. constructor(id: number, scale: Vector2, offset: Vector2);
  57042. }
  57043. }
  57044. declare module BABYLON {
  57045. /**
  57046. * Defines the basic options interface of a TexturePacker
  57047. */
  57048. export interface ITexturePackerOptions {
  57049. /**
  57050. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57051. */
  57052. map?: string[];
  57053. /**
  57054. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57055. */
  57056. uvsIn?: string;
  57057. /**
  57058. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57059. */
  57060. uvsOut?: string;
  57061. /**
  57062. * number representing the layout style. Defaults to LAYOUT_STRIP
  57063. */
  57064. layout?: number;
  57065. /**
  57066. * number of columns if using custom column count layout(2). This defaults to 4.
  57067. */
  57068. colnum?: number;
  57069. /**
  57070. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57071. */
  57072. updateInputMeshes?: boolean;
  57073. /**
  57074. * boolean flag to dispose all the source textures. Defaults to true.
  57075. */
  57076. disposeSources?: boolean;
  57077. /**
  57078. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57079. */
  57080. fillBlanks?: boolean;
  57081. /**
  57082. * string value representing the context fill style color. Defaults to 'black'.
  57083. */
  57084. customFillColor?: string;
  57085. /**
  57086. * Width and Height Value of each Frame in the TexturePacker Sets
  57087. */
  57088. frameSize?: number;
  57089. /**
  57090. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57091. */
  57092. paddingRatio?: number;
  57093. /**
  57094. * Number that declares the fill method for the padding gutter.
  57095. */
  57096. paddingMode?: number;
  57097. /**
  57098. * If in SUBUV_COLOR padding mode what color to use.
  57099. */
  57100. paddingColor?: Color3 | Color4;
  57101. }
  57102. /**
  57103. * Defines the basic interface of a TexturePacker JSON File
  57104. */
  57105. export interface ITexturePackerJSON {
  57106. /**
  57107. * The frame ID
  57108. */
  57109. name: string;
  57110. /**
  57111. * The base64 channel data
  57112. */
  57113. sets: any;
  57114. /**
  57115. * The options of the Packer
  57116. */
  57117. options: ITexturePackerOptions;
  57118. /**
  57119. * The frame data of the Packer
  57120. */
  57121. frames: Array<number>;
  57122. }
  57123. /**
  57124. * This is a support class that generates a series of packed texture sets.
  57125. * @see https://doc.babylonjs.com/babylon101/materials
  57126. */
  57127. export class TexturePacker {
  57128. /** Packer Layout Constant 0 */
  57129. static readonly LAYOUT_STRIP: number;
  57130. /** Packer Layout Constant 1 */
  57131. static readonly LAYOUT_POWER2: number;
  57132. /** Packer Layout Constant 2 */
  57133. static readonly LAYOUT_COLNUM: number;
  57134. /** Packer Layout Constant 0 */
  57135. static readonly SUBUV_WRAP: number;
  57136. /** Packer Layout Constant 1 */
  57137. static readonly SUBUV_EXTEND: number;
  57138. /** Packer Layout Constant 2 */
  57139. static readonly SUBUV_COLOR: number;
  57140. /** The Name of the Texture Package */
  57141. name: string;
  57142. /** The scene scope of the TexturePacker */
  57143. scene: Scene;
  57144. /** The Meshes to target */
  57145. meshes: AbstractMesh[];
  57146. /** Arguments passed with the Constructor */
  57147. options: ITexturePackerOptions;
  57148. /** The promise that is started upon initialization */
  57149. promise: Nullable<Promise<TexturePacker | string>>;
  57150. /** The Container object for the channel sets that are generated */
  57151. sets: object;
  57152. /** The Container array for the frames that are generated */
  57153. frames: TexturePackerFrame[];
  57154. /** The expected number of textures the system is parsing. */
  57155. private _expecting;
  57156. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57157. private _paddingValue;
  57158. /**
  57159. * Initializes a texture package series from an array of meshes or a single mesh.
  57160. * @param name The name of the package
  57161. * @param meshes The target meshes to compose the package from
  57162. * @param options The arguments that texture packer should follow while building.
  57163. * @param scene The scene which the textures are scoped to.
  57164. * @returns TexturePacker
  57165. */
  57166. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57167. /**
  57168. * Starts the package process
  57169. * @param resolve The promises resolution function
  57170. * @returns TexturePacker
  57171. */
  57172. private _createFrames;
  57173. /**
  57174. * Calculates the Size of the Channel Sets
  57175. * @returns Vector2
  57176. */
  57177. private _calculateSize;
  57178. /**
  57179. * Calculates the UV data for the frames.
  57180. * @param baseSize the base frameSize
  57181. * @param padding the base frame padding
  57182. * @param dtSize size of the Dynamic Texture for that channel
  57183. * @param dtUnits is 1/dtSize
  57184. * @param update flag to update the input meshes
  57185. */
  57186. private _calculateMeshUVFrames;
  57187. /**
  57188. * Calculates the frames Offset.
  57189. * @param index of the frame
  57190. * @returns Vector2
  57191. */
  57192. private _getFrameOffset;
  57193. /**
  57194. * Updates a Mesh to the frame data
  57195. * @param mesh that is the target
  57196. * @param frameID or the frame index
  57197. */
  57198. private _updateMeshUV;
  57199. /**
  57200. * Updates a Meshes materials to use the texture packer channels
  57201. * @param m is the mesh to target
  57202. * @param force all channels on the packer to be set.
  57203. */
  57204. private _updateTextureReferences;
  57205. /**
  57206. * Public method to set a Mesh to a frame
  57207. * @param m that is the target
  57208. * @param frameID or the frame index
  57209. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57210. */
  57211. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57212. /**
  57213. * Starts the async promise to compile the texture packer.
  57214. * @returns Promise<void>
  57215. */
  57216. processAsync(): Promise<void>;
  57217. /**
  57218. * Disposes all textures associated with this packer
  57219. */
  57220. dispose(): void;
  57221. /**
  57222. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57223. * @param imageType is the image type to use.
  57224. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57225. */
  57226. download(imageType?: string, quality?: number): void;
  57227. /**
  57228. * Public method to load a texturePacker JSON file.
  57229. * @param data of the JSON file in string format.
  57230. */
  57231. updateFromJSON(data: string): void;
  57232. }
  57233. }
  57234. declare module BABYLON {
  57235. /**
  57236. * Enum used to define the target of a block
  57237. */
  57238. export enum NodeMaterialBlockTargets {
  57239. /** Vertex shader */
  57240. Vertex = 1,
  57241. /** Fragment shader */
  57242. Fragment = 2,
  57243. /** Neutral */
  57244. Neutral = 4,
  57245. /** Vertex and Fragment */
  57246. VertexAndFragment = 3
  57247. }
  57248. }
  57249. declare module BABYLON {
  57250. /**
  57251. * Defines the kind of connection point for node based material
  57252. */
  57253. export enum NodeMaterialBlockConnectionPointTypes {
  57254. /** Float */
  57255. Float = 1,
  57256. /** Int */
  57257. Int = 2,
  57258. /** Vector2 */
  57259. Vector2 = 4,
  57260. /** Vector3 */
  57261. Vector3 = 8,
  57262. /** Vector4 */
  57263. Vector4 = 16,
  57264. /** Color3 */
  57265. Color3 = 32,
  57266. /** Color4 */
  57267. Color4 = 64,
  57268. /** Matrix */
  57269. Matrix = 128,
  57270. /** Detect type based on connection */
  57271. AutoDetect = 1024,
  57272. /** Output type that will be defined by input type */
  57273. BasedOnInput = 2048
  57274. }
  57275. }
  57276. declare module BABYLON {
  57277. /**
  57278. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57279. */
  57280. export enum NodeMaterialBlockConnectionPointMode {
  57281. /** Value is an uniform */
  57282. Uniform = 0,
  57283. /** Value is a mesh attribute */
  57284. Attribute = 1,
  57285. /** Value is a varying between vertex and fragment shaders */
  57286. Varying = 2,
  57287. /** Mode is undefined */
  57288. Undefined = 3
  57289. }
  57290. }
  57291. declare module BABYLON {
  57292. /**
  57293. * Enum used to define system values e.g. values automatically provided by the system
  57294. */
  57295. export enum NodeMaterialSystemValues {
  57296. /** World */
  57297. World = 1,
  57298. /** View */
  57299. View = 2,
  57300. /** Projection */
  57301. Projection = 3,
  57302. /** ViewProjection */
  57303. ViewProjection = 4,
  57304. /** WorldView */
  57305. WorldView = 5,
  57306. /** WorldViewProjection */
  57307. WorldViewProjection = 6,
  57308. /** CameraPosition */
  57309. CameraPosition = 7,
  57310. /** Fog Color */
  57311. FogColor = 8,
  57312. /** Delta time */
  57313. DeltaTime = 9
  57314. }
  57315. }
  57316. declare module BABYLON {
  57317. /**
  57318. * Root class for all node material optimizers
  57319. */
  57320. export class NodeMaterialOptimizer {
  57321. /**
  57322. * Function used to optimize a NodeMaterial graph
  57323. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57324. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57325. */
  57326. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57327. }
  57328. }
  57329. declare module BABYLON {
  57330. /**
  57331. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57332. */
  57333. export class TransformBlock extends NodeMaterialBlock {
  57334. /**
  57335. * Defines the value to use to complement W value to transform it to a Vector4
  57336. */
  57337. complementW: number;
  57338. /**
  57339. * Defines the value to use to complement z value to transform it to a Vector4
  57340. */
  57341. complementZ: number;
  57342. /**
  57343. * Creates a new TransformBlock
  57344. * @param name defines the block name
  57345. */
  57346. constructor(name: string);
  57347. /**
  57348. * Gets the current class name
  57349. * @returns the class name
  57350. */
  57351. getClassName(): string;
  57352. /**
  57353. * Gets the vector input
  57354. */
  57355. get vector(): NodeMaterialConnectionPoint;
  57356. /**
  57357. * Gets the output component
  57358. */
  57359. get output(): NodeMaterialConnectionPoint;
  57360. /**
  57361. * Gets the xyz output component
  57362. */
  57363. get xyz(): NodeMaterialConnectionPoint;
  57364. /**
  57365. * Gets the matrix transform input
  57366. */
  57367. get transform(): NodeMaterialConnectionPoint;
  57368. protected _buildBlock(state: NodeMaterialBuildState): this;
  57369. serialize(): any;
  57370. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57371. protected _dumpPropertiesCode(): string;
  57372. }
  57373. }
  57374. declare module BABYLON {
  57375. /**
  57376. * Block used to output the vertex position
  57377. */
  57378. export class VertexOutputBlock extends NodeMaterialBlock {
  57379. /**
  57380. * Creates a new VertexOutputBlock
  57381. * @param name defines the block name
  57382. */
  57383. constructor(name: string);
  57384. /**
  57385. * Gets the current class name
  57386. * @returns the class name
  57387. */
  57388. getClassName(): string;
  57389. /**
  57390. * Gets the vector input component
  57391. */
  57392. get vector(): NodeMaterialConnectionPoint;
  57393. protected _buildBlock(state: NodeMaterialBuildState): this;
  57394. }
  57395. }
  57396. declare module BABYLON {
  57397. /**
  57398. * Block used to output the final color
  57399. */
  57400. export class FragmentOutputBlock extends NodeMaterialBlock {
  57401. /**
  57402. * Create a new FragmentOutputBlock
  57403. * @param name defines the block name
  57404. */
  57405. constructor(name: string);
  57406. /**
  57407. * Gets the current class name
  57408. * @returns the class name
  57409. */
  57410. getClassName(): string;
  57411. /**
  57412. * Gets the rgba input component
  57413. */
  57414. get rgba(): NodeMaterialConnectionPoint;
  57415. /**
  57416. * Gets the rgb input component
  57417. */
  57418. get rgb(): NodeMaterialConnectionPoint;
  57419. /**
  57420. * Gets the a input component
  57421. */
  57422. get a(): NodeMaterialConnectionPoint;
  57423. protected _buildBlock(state: NodeMaterialBuildState): this;
  57424. }
  57425. }
  57426. declare module BABYLON {
  57427. /**
  57428. * Block used to read a reflection texture from a sampler
  57429. */
  57430. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57431. private _define3DName;
  57432. private _defineCubicName;
  57433. private _defineExplicitName;
  57434. private _defineProjectionName;
  57435. private _defineLocalCubicName;
  57436. private _defineSphericalName;
  57437. private _definePlanarName;
  57438. private _defineEquirectangularName;
  57439. private _defineMirroredEquirectangularFixedName;
  57440. private _defineEquirectangularFixedName;
  57441. private _defineSkyboxName;
  57442. private _cubeSamplerName;
  57443. private _2DSamplerName;
  57444. private _positionUVWName;
  57445. private _directionWName;
  57446. private _reflectionCoordsName;
  57447. private _reflection2DCoordsName;
  57448. private _reflectionColorName;
  57449. private _reflectionMatrixName;
  57450. /**
  57451. * Gets or sets the texture associated with the node
  57452. */
  57453. texture: Nullable<BaseTexture>;
  57454. /**
  57455. * Create a new TextureBlock
  57456. * @param name defines the block name
  57457. */
  57458. constructor(name: string);
  57459. /**
  57460. * Gets the current class name
  57461. * @returns the class name
  57462. */
  57463. getClassName(): string;
  57464. /**
  57465. * Gets the world position input component
  57466. */
  57467. get position(): NodeMaterialConnectionPoint;
  57468. /**
  57469. * Gets the world position input component
  57470. */
  57471. get worldPosition(): NodeMaterialConnectionPoint;
  57472. /**
  57473. * Gets the world normal input component
  57474. */
  57475. get worldNormal(): NodeMaterialConnectionPoint;
  57476. /**
  57477. * Gets the world input component
  57478. */
  57479. get world(): NodeMaterialConnectionPoint;
  57480. /**
  57481. * Gets the camera (or eye) position component
  57482. */
  57483. get cameraPosition(): NodeMaterialConnectionPoint;
  57484. /**
  57485. * Gets the view input component
  57486. */
  57487. get view(): NodeMaterialConnectionPoint;
  57488. /**
  57489. * Gets the rgb output component
  57490. */
  57491. get rgb(): NodeMaterialConnectionPoint;
  57492. /**
  57493. * Gets the r output component
  57494. */
  57495. get r(): NodeMaterialConnectionPoint;
  57496. /**
  57497. * Gets the g output component
  57498. */
  57499. get g(): NodeMaterialConnectionPoint;
  57500. /**
  57501. * Gets the b output component
  57502. */
  57503. get b(): NodeMaterialConnectionPoint;
  57504. autoConfigure(material: NodeMaterial): void;
  57505. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57506. isReady(): boolean;
  57507. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57508. private _injectVertexCode;
  57509. private _writeOutput;
  57510. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57511. protected _dumpPropertiesCode(): string;
  57512. serialize(): any;
  57513. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57514. }
  57515. }
  57516. declare module BABYLON {
  57517. /**
  57518. * Interface used to configure the node material editor
  57519. */
  57520. export interface INodeMaterialEditorOptions {
  57521. /** Define the URl to load node editor script */
  57522. editorURL?: string;
  57523. }
  57524. /** @hidden */
  57525. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57526. NORMAL: boolean;
  57527. TANGENT: boolean;
  57528. UV1: boolean;
  57529. /** BONES */
  57530. NUM_BONE_INFLUENCERS: number;
  57531. BonesPerMesh: number;
  57532. BONETEXTURE: boolean;
  57533. /** MORPH TARGETS */
  57534. MORPHTARGETS: boolean;
  57535. MORPHTARGETS_NORMAL: boolean;
  57536. MORPHTARGETS_TANGENT: boolean;
  57537. MORPHTARGETS_UV: boolean;
  57538. NUM_MORPH_INFLUENCERS: number;
  57539. /** IMAGE PROCESSING */
  57540. IMAGEPROCESSING: boolean;
  57541. VIGNETTE: boolean;
  57542. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57543. VIGNETTEBLENDMODEOPAQUE: boolean;
  57544. TONEMAPPING: boolean;
  57545. TONEMAPPING_ACES: boolean;
  57546. CONTRAST: boolean;
  57547. EXPOSURE: boolean;
  57548. COLORCURVES: boolean;
  57549. COLORGRADING: boolean;
  57550. COLORGRADING3D: boolean;
  57551. SAMPLER3DGREENDEPTH: boolean;
  57552. SAMPLER3DBGRMAP: boolean;
  57553. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57554. /** MISC. */
  57555. BUMPDIRECTUV: number;
  57556. constructor();
  57557. setValue(name: string, value: boolean): void;
  57558. }
  57559. /**
  57560. * Class used to configure NodeMaterial
  57561. */
  57562. export interface INodeMaterialOptions {
  57563. /**
  57564. * Defines if blocks should emit comments
  57565. */
  57566. emitComments: boolean;
  57567. }
  57568. /**
  57569. * Class used to create a node based material built by assembling shader blocks
  57570. */
  57571. export class NodeMaterial extends PushMaterial {
  57572. private static _BuildIdGenerator;
  57573. private _options;
  57574. private _vertexCompilationState;
  57575. private _fragmentCompilationState;
  57576. private _sharedData;
  57577. private _buildId;
  57578. private _buildWasSuccessful;
  57579. private _cachedWorldViewMatrix;
  57580. private _cachedWorldViewProjectionMatrix;
  57581. private _optimizers;
  57582. private _animationFrame;
  57583. /** Define the Url to load node editor script */
  57584. static EditorURL: string;
  57585. /** Define the Url to load snippets */
  57586. static SnippetUrl: string;
  57587. private BJSNODEMATERIALEDITOR;
  57588. /** Get the inspector from bundle or global */
  57589. private _getGlobalNodeMaterialEditor;
  57590. /**
  57591. * Snippet ID if the material was created from the snippet server
  57592. */
  57593. snippetId: string;
  57594. /**
  57595. * Gets or sets data used by visual editor
  57596. * @see https://nme.babylonjs.com
  57597. */
  57598. editorData: any;
  57599. /**
  57600. * 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)
  57601. */
  57602. ignoreAlpha: boolean;
  57603. /**
  57604. * Defines the maximum number of lights that can be used in the material
  57605. */
  57606. maxSimultaneousLights: number;
  57607. /**
  57608. * Observable raised when the material is built
  57609. */
  57610. onBuildObservable: Observable<NodeMaterial>;
  57611. /**
  57612. * Gets or sets the root nodes of the material vertex shader
  57613. */
  57614. _vertexOutputNodes: NodeMaterialBlock[];
  57615. /**
  57616. * Gets or sets the root nodes of the material fragment (pixel) shader
  57617. */
  57618. _fragmentOutputNodes: NodeMaterialBlock[];
  57619. /** Gets or sets options to control the node material overall behavior */
  57620. get options(): INodeMaterialOptions;
  57621. set options(options: INodeMaterialOptions);
  57622. /**
  57623. * Default configuration related to image processing available in the standard Material.
  57624. */
  57625. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57626. /**
  57627. * Gets the image processing configuration used either in this material.
  57628. */
  57629. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57630. /**
  57631. * Sets the Default image processing configuration used either in the this material.
  57632. *
  57633. * If sets to null, the scene one is in use.
  57634. */
  57635. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57636. /**
  57637. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57638. */
  57639. attachedBlocks: NodeMaterialBlock[];
  57640. /**
  57641. * Create a new node based material
  57642. * @param name defines the material name
  57643. * @param scene defines the hosting scene
  57644. * @param options defines creation option
  57645. */
  57646. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57647. /**
  57648. * Gets the current class name of the material e.g. "NodeMaterial"
  57649. * @returns the class name
  57650. */
  57651. getClassName(): string;
  57652. /**
  57653. * Keep track of the image processing observer to allow dispose and replace.
  57654. */
  57655. private _imageProcessingObserver;
  57656. /**
  57657. * Attaches a new image processing configuration to the Standard Material.
  57658. * @param configuration
  57659. */
  57660. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57661. /**
  57662. * Get a block by its name
  57663. * @param name defines the name of the block to retrieve
  57664. * @returns the required block or null if not found
  57665. */
  57666. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57667. /**
  57668. * Get a block by its name
  57669. * @param predicate defines the predicate used to find the good candidate
  57670. * @returns the required block or null if not found
  57671. */
  57672. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57673. /**
  57674. * Get an input block by its name
  57675. * @param predicate defines the predicate used to find the good candidate
  57676. * @returns the required input block or null if not found
  57677. */
  57678. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57679. /**
  57680. * Gets the list of input blocks attached to this material
  57681. * @returns an array of InputBlocks
  57682. */
  57683. getInputBlocks(): InputBlock[];
  57684. /**
  57685. * Adds a new optimizer to the list of optimizers
  57686. * @param optimizer defines the optimizers to add
  57687. * @returns the current material
  57688. */
  57689. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57690. /**
  57691. * Remove an optimizer from the list of optimizers
  57692. * @param optimizer defines the optimizers to remove
  57693. * @returns the current material
  57694. */
  57695. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57696. /**
  57697. * Add a new block to the list of output nodes
  57698. * @param node defines the node to add
  57699. * @returns the current material
  57700. */
  57701. addOutputNode(node: NodeMaterialBlock): this;
  57702. /**
  57703. * Remove a block from the list of root nodes
  57704. * @param node defines the node to remove
  57705. * @returns the current material
  57706. */
  57707. removeOutputNode(node: NodeMaterialBlock): this;
  57708. private _addVertexOutputNode;
  57709. private _removeVertexOutputNode;
  57710. private _addFragmentOutputNode;
  57711. private _removeFragmentOutputNode;
  57712. /**
  57713. * Specifies if the material will require alpha blending
  57714. * @returns a boolean specifying if alpha blending is needed
  57715. */
  57716. needAlphaBlending(): boolean;
  57717. /**
  57718. * Specifies if this material should be rendered in alpha test mode
  57719. * @returns a boolean specifying if an alpha test is needed.
  57720. */
  57721. needAlphaTesting(): boolean;
  57722. private _initializeBlock;
  57723. private _resetDualBlocks;
  57724. /**
  57725. * Remove a block from the current node material
  57726. * @param block defines the block to remove
  57727. */
  57728. removeBlock(block: NodeMaterialBlock): void;
  57729. /**
  57730. * Build the material and generates the inner effect
  57731. * @param verbose defines if the build should log activity
  57732. */
  57733. build(verbose?: boolean): void;
  57734. /**
  57735. * Runs an otpimization phase to try to improve the shader code
  57736. */
  57737. optimize(): void;
  57738. private _prepareDefinesForAttributes;
  57739. /**
  57740. * Get if the submesh is ready to be used and all its information available.
  57741. * Child classes can use it to update shaders
  57742. * @param mesh defines the mesh to check
  57743. * @param subMesh defines which submesh to check
  57744. * @param useInstances specifies that instances should be used
  57745. * @returns a boolean indicating that the submesh is ready or not
  57746. */
  57747. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57748. /**
  57749. * Get a string representing the shaders built by the current node graph
  57750. */
  57751. get compiledShaders(): string;
  57752. /**
  57753. * Binds the world matrix to the material
  57754. * @param world defines the world transformation matrix
  57755. */
  57756. bindOnlyWorldMatrix(world: Matrix): void;
  57757. /**
  57758. * Binds the submesh to this material by preparing the effect and shader to draw
  57759. * @param world defines the world transformation matrix
  57760. * @param mesh defines the mesh containing the submesh
  57761. * @param subMesh defines the submesh to bind the material to
  57762. */
  57763. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57764. /**
  57765. * Gets the active textures from the material
  57766. * @returns an array of textures
  57767. */
  57768. getActiveTextures(): BaseTexture[];
  57769. /**
  57770. * Gets the list of texture blocks
  57771. * @returns an array of texture blocks
  57772. */
  57773. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57774. /**
  57775. * Specifies if the material uses a texture
  57776. * @param texture defines the texture to check against the material
  57777. * @returns a boolean specifying if the material uses the texture
  57778. */
  57779. hasTexture(texture: BaseTexture): boolean;
  57780. /**
  57781. * Disposes the material
  57782. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57783. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57784. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57785. */
  57786. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57787. /** Creates the node editor window. */
  57788. private _createNodeEditor;
  57789. /**
  57790. * Launch the node material editor
  57791. * @param config Define the configuration of the editor
  57792. * @return a promise fulfilled when the node editor is visible
  57793. */
  57794. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57795. /**
  57796. * Clear the current material
  57797. */
  57798. clear(): void;
  57799. /**
  57800. * Clear the current material and set it to a default state
  57801. */
  57802. setToDefault(): void;
  57803. /**
  57804. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57805. * @param url defines the url to load from
  57806. * @returns a promise that will fullfil when the material is fully loaded
  57807. */
  57808. loadAsync(url: string): Promise<void>;
  57809. private _gatherBlocks;
  57810. /**
  57811. * Generate a string containing the code declaration required to create an equivalent of this material
  57812. * @returns a string
  57813. */
  57814. generateCode(): string;
  57815. /**
  57816. * Serializes this material in a JSON representation
  57817. * @returns the serialized material object
  57818. */
  57819. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57820. private _restoreConnections;
  57821. /**
  57822. * Clear the current graph and load a new one from a serialization object
  57823. * @param source defines the JSON representation of the material
  57824. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57825. */
  57826. loadFromSerialization(source: any, rootUrl?: string): void;
  57827. /**
  57828. * Makes a duplicate of the current material.
  57829. * @param name - name to use for the new material.
  57830. */
  57831. clone(name: string): NodeMaterial;
  57832. /**
  57833. * Creates a node material from parsed material data
  57834. * @param source defines the JSON representation of the material
  57835. * @param scene defines the hosting scene
  57836. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57837. * @returns a new node material
  57838. */
  57839. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57840. /**
  57841. * Creates a node material from a snippet saved in a remote file
  57842. * @param name defines the name of the material to create
  57843. * @param url defines the url to load from
  57844. * @param scene defines the hosting scene
  57845. * @returns a promise that will resolve to the new node material
  57846. */
  57847. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57848. /**
  57849. * Creates a node material from a snippet saved by the node material editor
  57850. * @param snippetId defines the snippet to load
  57851. * @param scene defines the hosting scene
  57852. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57853. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  57854. * @returns a promise that will resolve to the new node material
  57855. */
  57856. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  57857. /**
  57858. * Creates a new node material set to default basic configuration
  57859. * @param name defines the name of the material
  57860. * @param scene defines the hosting scene
  57861. * @returns a new NodeMaterial
  57862. */
  57863. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57864. }
  57865. }
  57866. declare module BABYLON {
  57867. /**
  57868. * Block used to read a texture from a sampler
  57869. */
  57870. export class TextureBlock extends NodeMaterialBlock {
  57871. private _defineName;
  57872. private _linearDefineName;
  57873. private _tempTextureRead;
  57874. private _samplerName;
  57875. private _transformedUVName;
  57876. private _textureTransformName;
  57877. private _textureInfoName;
  57878. private _mainUVName;
  57879. private _mainUVDefineName;
  57880. /**
  57881. * Gets or sets the texture associated with the node
  57882. */
  57883. texture: Nullable<Texture>;
  57884. /**
  57885. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57886. */
  57887. convertToGammaSpace: boolean;
  57888. /**
  57889. * Create a new TextureBlock
  57890. * @param name defines the block name
  57891. */
  57892. constructor(name: string);
  57893. /**
  57894. * Gets the current class name
  57895. * @returns the class name
  57896. */
  57897. getClassName(): string;
  57898. /**
  57899. * Gets the uv input component
  57900. */
  57901. get uv(): NodeMaterialConnectionPoint;
  57902. /**
  57903. * Gets the rgba output component
  57904. */
  57905. get rgba(): NodeMaterialConnectionPoint;
  57906. /**
  57907. * Gets the rgb output component
  57908. */
  57909. get rgb(): NodeMaterialConnectionPoint;
  57910. /**
  57911. * Gets the r output component
  57912. */
  57913. get r(): NodeMaterialConnectionPoint;
  57914. /**
  57915. * Gets the g output component
  57916. */
  57917. get g(): NodeMaterialConnectionPoint;
  57918. /**
  57919. * Gets the b output component
  57920. */
  57921. get b(): NodeMaterialConnectionPoint;
  57922. /**
  57923. * Gets the a output component
  57924. */
  57925. get a(): NodeMaterialConnectionPoint;
  57926. get target(): NodeMaterialBlockTargets;
  57927. autoConfigure(material: NodeMaterial): void;
  57928. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57930. isReady(): boolean;
  57931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57932. private get _isMixed();
  57933. private _injectVertexCode;
  57934. private _writeTextureRead;
  57935. private _writeOutput;
  57936. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57937. protected _dumpPropertiesCode(): string;
  57938. serialize(): any;
  57939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57940. }
  57941. }
  57942. declare module BABYLON {
  57943. /**
  57944. * Class used to store shared data between 2 NodeMaterialBuildState
  57945. */
  57946. export class NodeMaterialBuildStateSharedData {
  57947. /**
  57948. * Gets the list of emitted varyings
  57949. */
  57950. temps: string[];
  57951. /**
  57952. * Gets the list of emitted varyings
  57953. */
  57954. varyings: string[];
  57955. /**
  57956. * Gets the varying declaration string
  57957. */
  57958. varyingDeclaration: string;
  57959. /**
  57960. * Input blocks
  57961. */
  57962. inputBlocks: InputBlock[];
  57963. /**
  57964. * Input blocks
  57965. */
  57966. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57967. /**
  57968. * Bindable blocks (Blocks that need to set data to the effect)
  57969. */
  57970. bindableBlocks: NodeMaterialBlock[];
  57971. /**
  57972. * List of blocks that can provide a compilation fallback
  57973. */
  57974. blocksWithFallbacks: NodeMaterialBlock[];
  57975. /**
  57976. * List of blocks that can provide a define update
  57977. */
  57978. blocksWithDefines: NodeMaterialBlock[];
  57979. /**
  57980. * List of blocks that can provide a repeatable content
  57981. */
  57982. repeatableContentBlocks: NodeMaterialBlock[];
  57983. /**
  57984. * List of blocks that can provide a dynamic list of uniforms
  57985. */
  57986. dynamicUniformBlocks: NodeMaterialBlock[];
  57987. /**
  57988. * List of blocks that can block the isReady function for the material
  57989. */
  57990. blockingBlocks: NodeMaterialBlock[];
  57991. /**
  57992. * Gets the list of animated inputs
  57993. */
  57994. animatedInputs: InputBlock[];
  57995. /**
  57996. * Build Id used to avoid multiple recompilations
  57997. */
  57998. buildId: number;
  57999. /** List of emitted variables */
  58000. variableNames: {
  58001. [key: string]: number;
  58002. };
  58003. /** List of emitted defines */
  58004. defineNames: {
  58005. [key: string]: number;
  58006. };
  58007. /** Should emit comments? */
  58008. emitComments: boolean;
  58009. /** Emit build activity */
  58010. verbose: boolean;
  58011. /** Gets or sets the hosting scene */
  58012. scene: Scene;
  58013. /**
  58014. * Gets the compilation hints emitted at compilation time
  58015. */
  58016. hints: {
  58017. needWorldViewMatrix: boolean;
  58018. needWorldViewProjectionMatrix: boolean;
  58019. needAlphaBlending: boolean;
  58020. needAlphaTesting: boolean;
  58021. };
  58022. /**
  58023. * List of compilation checks
  58024. */
  58025. checks: {
  58026. emitVertex: boolean;
  58027. emitFragment: boolean;
  58028. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58029. };
  58030. /** Creates a new shared data */
  58031. constructor();
  58032. /**
  58033. * Emits console errors and exceptions if there is a failing check
  58034. */
  58035. emitErrors(): void;
  58036. }
  58037. }
  58038. declare module BABYLON {
  58039. /**
  58040. * Class used to store node based material build state
  58041. */
  58042. export class NodeMaterialBuildState {
  58043. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58044. supportUniformBuffers: boolean;
  58045. /**
  58046. * Gets the list of emitted attributes
  58047. */
  58048. attributes: string[];
  58049. /**
  58050. * Gets the list of emitted uniforms
  58051. */
  58052. uniforms: string[];
  58053. /**
  58054. * Gets the list of emitted constants
  58055. */
  58056. constants: string[];
  58057. /**
  58058. * Gets the list of emitted samplers
  58059. */
  58060. samplers: string[];
  58061. /**
  58062. * Gets the list of emitted functions
  58063. */
  58064. functions: {
  58065. [key: string]: string;
  58066. };
  58067. /**
  58068. * Gets the list of emitted extensions
  58069. */
  58070. extensions: {
  58071. [key: string]: string;
  58072. };
  58073. /**
  58074. * Gets the target of the compilation state
  58075. */
  58076. target: NodeMaterialBlockTargets;
  58077. /**
  58078. * Gets the list of emitted counters
  58079. */
  58080. counters: {
  58081. [key: string]: number;
  58082. };
  58083. /**
  58084. * Shared data between multiple NodeMaterialBuildState instances
  58085. */
  58086. sharedData: NodeMaterialBuildStateSharedData;
  58087. /** @hidden */
  58088. _vertexState: NodeMaterialBuildState;
  58089. /** @hidden */
  58090. _attributeDeclaration: string;
  58091. /** @hidden */
  58092. _uniformDeclaration: string;
  58093. /** @hidden */
  58094. _constantDeclaration: string;
  58095. /** @hidden */
  58096. _samplerDeclaration: string;
  58097. /** @hidden */
  58098. _varyingTransfer: string;
  58099. private _repeatableContentAnchorIndex;
  58100. /** @hidden */
  58101. _builtCompilationString: string;
  58102. /**
  58103. * Gets the emitted compilation strings
  58104. */
  58105. compilationString: string;
  58106. /**
  58107. * Finalize the compilation strings
  58108. * @param state defines the current compilation state
  58109. */
  58110. finalize(state: NodeMaterialBuildState): void;
  58111. /** @hidden */
  58112. get _repeatableContentAnchor(): string;
  58113. /** @hidden */
  58114. _getFreeVariableName(prefix: string): string;
  58115. /** @hidden */
  58116. _getFreeDefineName(prefix: string): string;
  58117. /** @hidden */
  58118. _excludeVariableName(name: string): void;
  58119. /** @hidden */
  58120. _emit2DSampler(name: string): void;
  58121. /** @hidden */
  58122. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58123. /** @hidden */
  58124. _emitExtension(name: string, extension: string): void;
  58125. /** @hidden */
  58126. _emitFunction(name: string, code: string, comments: string): void;
  58127. /** @hidden */
  58128. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58129. replaceStrings?: {
  58130. search: RegExp;
  58131. replace: string;
  58132. }[];
  58133. repeatKey?: string;
  58134. }): string;
  58135. /** @hidden */
  58136. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58137. repeatKey?: string;
  58138. removeAttributes?: boolean;
  58139. removeUniforms?: boolean;
  58140. removeVaryings?: boolean;
  58141. removeIfDef?: boolean;
  58142. replaceStrings?: {
  58143. search: RegExp;
  58144. replace: string;
  58145. }[];
  58146. }, storeKey?: string): void;
  58147. /** @hidden */
  58148. _registerTempVariable(name: string): boolean;
  58149. /** @hidden */
  58150. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58151. /** @hidden */
  58152. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58153. /** @hidden */
  58154. _emitFloat(value: number): string;
  58155. }
  58156. }
  58157. declare module BABYLON {
  58158. /**
  58159. * Defines a block that can be used inside a node based material
  58160. */
  58161. export class NodeMaterialBlock {
  58162. private _buildId;
  58163. private _buildTarget;
  58164. private _target;
  58165. private _isFinalMerger;
  58166. private _isInput;
  58167. protected _isUnique: boolean;
  58168. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58169. inputsAreExclusive: boolean;
  58170. /** @hidden */
  58171. _codeVariableName: string;
  58172. /** @hidden */
  58173. _inputs: NodeMaterialConnectionPoint[];
  58174. /** @hidden */
  58175. _outputs: NodeMaterialConnectionPoint[];
  58176. /** @hidden */
  58177. _preparationId: number;
  58178. /**
  58179. * Gets or sets the name of the block
  58180. */
  58181. name: string;
  58182. /**
  58183. * Gets or sets the unique id of the node
  58184. */
  58185. uniqueId: number;
  58186. /**
  58187. * Gets or sets the comments associated with this block
  58188. */
  58189. comments: string;
  58190. /**
  58191. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58192. */
  58193. get isUnique(): boolean;
  58194. /**
  58195. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58196. */
  58197. get isFinalMerger(): boolean;
  58198. /**
  58199. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58200. */
  58201. get isInput(): boolean;
  58202. /**
  58203. * Gets or sets the build Id
  58204. */
  58205. get buildId(): number;
  58206. set buildId(value: number);
  58207. /**
  58208. * Gets or sets the target of the block
  58209. */
  58210. get target(): NodeMaterialBlockTargets;
  58211. set target(value: NodeMaterialBlockTargets);
  58212. /**
  58213. * Gets the list of input points
  58214. */
  58215. get inputs(): NodeMaterialConnectionPoint[];
  58216. /** Gets the list of output points */
  58217. get outputs(): NodeMaterialConnectionPoint[];
  58218. /**
  58219. * Find an input by its name
  58220. * @param name defines the name of the input to look for
  58221. * @returns the input or null if not found
  58222. */
  58223. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58224. /**
  58225. * Find an output by its name
  58226. * @param name defines the name of the outputto look for
  58227. * @returns the output or null if not found
  58228. */
  58229. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58230. /**
  58231. * Creates a new NodeMaterialBlock
  58232. * @param name defines the block name
  58233. * @param target defines the target of that block (Vertex by default)
  58234. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58235. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58236. */
  58237. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58238. /**
  58239. * Initialize the block and prepare the context for build
  58240. * @param state defines the state that will be used for the build
  58241. */
  58242. initialize(state: NodeMaterialBuildState): void;
  58243. /**
  58244. * Bind data to effect. Will only be called for blocks with isBindable === true
  58245. * @param effect defines the effect to bind data to
  58246. * @param nodeMaterial defines the hosting NodeMaterial
  58247. * @param mesh defines the mesh that will be rendered
  58248. */
  58249. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58250. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58251. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58252. protected _writeFloat(value: number): string;
  58253. /**
  58254. * Gets the current class name e.g. "NodeMaterialBlock"
  58255. * @returns the class name
  58256. */
  58257. getClassName(): string;
  58258. /**
  58259. * Register a new input. Must be called inside a block constructor
  58260. * @param name defines the connection point name
  58261. * @param type defines the connection point type
  58262. * @param isOptional defines a boolean indicating that this input can be omitted
  58263. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58264. * @returns the current block
  58265. */
  58266. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58267. /**
  58268. * Register a new output. Must be called inside a block constructor
  58269. * @param name defines the connection point name
  58270. * @param type defines the connection point type
  58271. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58272. * @returns the current block
  58273. */
  58274. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58275. /**
  58276. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58277. * @param forOutput defines an optional connection point to check compatibility with
  58278. * @returns the first available input or null
  58279. */
  58280. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58281. /**
  58282. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58283. * @param forBlock defines an optional block to check compatibility with
  58284. * @returns the first available input or null
  58285. */
  58286. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58287. /**
  58288. * Gets the sibling of the given output
  58289. * @param current defines the current output
  58290. * @returns the next output in the list or null
  58291. */
  58292. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58293. /**
  58294. * Connect current block with another block
  58295. * @param other defines the block to connect with
  58296. * @param options define the various options to help pick the right connections
  58297. * @returns the current block
  58298. */
  58299. connectTo(other: NodeMaterialBlock, options?: {
  58300. input?: string;
  58301. output?: string;
  58302. outputSwizzle?: string;
  58303. }): this | undefined;
  58304. protected _buildBlock(state: NodeMaterialBuildState): void;
  58305. /**
  58306. * Add uniforms, samplers and uniform buffers at compilation time
  58307. * @param state defines the state to update
  58308. * @param nodeMaterial defines the node material requesting the update
  58309. * @param defines defines the material defines to update
  58310. * @param uniformBuffers defines the list of uniform buffer names
  58311. */
  58312. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58313. /**
  58314. * Add potential fallbacks if shader compilation fails
  58315. * @param mesh defines the mesh to be rendered
  58316. * @param fallbacks defines the current prioritized list of fallbacks
  58317. */
  58318. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58319. /**
  58320. * Initialize defines for shader compilation
  58321. * @param mesh defines the mesh to be rendered
  58322. * @param nodeMaterial defines the node material requesting the update
  58323. * @param defines defines the material defines to update
  58324. * @param useInstances specifies that instances should be used
  58325. */
  58326. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58327. /**
  58328. * Update defines for shader compilation
  58329. * @param mesh defines the mesh to be rendered
  58330. * @param nodeMaterial defines the node material requesting the update
  58331. * @param defines defines the material defines to update
  58332. * @param useInstances specifies that instances should be used
  58333. */
  58334. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58335. /**
  58336. * Lets the block try to connect some inputs automatically
  58337. * @param material defines the hosting NodeMaterial
  58338. */
  58339. autoConfigure(material: NodeMaterial): void;
  58340. /**
  58341. * Function called when a block is declared as repeatable content generator
  58342. * @param vertexShaderState defines the current compilation state for the vertex shader
  58343. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58344. * @param mesh defines the mesh to be rendered
  58345. * @param defines defines the material defines to update
  58346. */
  58347. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58348. /**
  58349. * Checks if the block is ready
  58350. * @param mesh defines the mesh to be rendered
  58351. * @param nodeMaterial defines the node material requesting the update
  58352. * @param defines defines the material defines to update
  58353. * @param useInstances specifies that instances should be used
  58354. * @returns true if the block is ready
  58355. */
  58356. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58357. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58358. private _processBuild;
  58359. /**
  58360. * Compile the current node and generate the shader code
  58361. * @param state defines the current compilation state (uniforms, samplers, current string)
  58362. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58363. * @returns true if already built
  58364. */
  58365. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58366. protected _inputRename(name: string): string;
  58367. protected _outputRename(name: string): string;
  58368. protected _dumpPropertiesCode(): string;
  58369. /** @hidden */
  58370. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58371. /** @hidden */
  58372. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58373. /**
  58374. * Clone the current block to a new identical block
  58375. * @param scene defines the hosting scene
  58376. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58377. * @returns a copy of the current block
  58378. */
  58379. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58380. /**
  58381. * Serializes this block in a JSON representation
  58382. * @returns the serialized block object
  58383. */
  58384. serialize(): any;
  58385. /** @hidden */
  58386. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58387. /**
  58388. * Release resources
  58389. */
  58390. dispose(): void;
  58391. }
  58392. }
  58393. declare module BABYLON {
  58394. /**
  58395. * Enum defining the type of animations supported by InputBlock
  58396. */
  58397. export enum AnimatedInputBlockTypes {
  58398. /** No animation */
  58399. None = 0,
  58400. /** Time based animation. Will only work for floats */
  58401. Time = 1
  58402. }
  58403. }
  58404. declare module BABYLON {
  58405. /**
  58406. * Block used to expose an input value
  58407. */
  58408. export class InputBlock extends NodeMaterialBlock {
  58409. private _mode;
  58410. private _associatedVariableName;
  58411. private _storedValue;
  58412. private _valueCallback;
  58413. private _type;
  58414. private _animationType;
  58415. /** Gets or set a value used to limit the range of float values */
  58416. min: number;
  58417. /** Gets or set a value used to limit the range of float values */
  58418. max: number;
  58419. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58420. isBoolean: boolean;
  58421. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58422. matrixMode: number;
  58423. /** @hidden */
  58424. _systemValue: Nullable<NodeMaterialSystemValues>;
  58425. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58426. visibleInInspector: boolean;
  58427. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58428. isConstant: boolean;
  58429. /** Gets or sets the group to use to display this block in the Inspector */
  58430. groupInInspector: string;
  58431. /** Gets an observable raised when the value is changed */
  58432. onValueChangedObservable: Observable<InputBlock>;
  58433. /**
  58434. * Gets or sets the connection point type (default is float)
  58435. */
  58436. get type(): NodeMaterialBlockConnectionPointTypes;
  58437. /**
  58438. * Creates a new InputBlock
  58439. * @param name defines the block name
  58440. * @param target defines the target of that block (Vertex by default)
  58441. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58442. */
  58443. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58444. /**
  58445. * Gets the output component
  58446. */
  58447. get output(): NodeMaterialConnectionPoint;
  58448. /**
  58449. * Set the source of this connection point to a vertex attribute
  58450. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58451. * @returns the current connection point
  58452. */
  58453. setAsAttribute(attributeName?: string): InputBlock;
  58454. /**
  58455. * Set the source of this connection point to a system value
  58456. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58457. * @returns the current connection point
  58458. */
  58459. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58460. /**
  58461. * Gets or sets the value of that point.
  58462. * Please note that this value will be ignored if valueCallback is defined
  58463. */
  58464. get value(): any;
  58465. set value(value: any);
  58466. /**
  58467. * Gets or sets a callback used to get the value of that point.
  58468. * Please note that setting this value will force the connection point to ignore the value property
  58469. */
  58470. get valueCallback(): () => any;
  58471. set valueCallback(value: () => any);
  58472. /**
  58473. * Gets or sets the associated variable name in the shader
  58474. */
  58475. get associatedVariableName(): string;
  58476. set associatedVariableName(value: string);
  58477. /** Gets or sets the type of animation applied to the input */
  58478. get animationType(): AnimatedInputBlockTypes;
  58479. set animationType(value: AnimatedInputBlockTypes);
  58480. /**
  58481. * Gets a boolean indicating that this connection point not defined yet
  58482. */
  58483. get isUndefined(): boolean;
  58484. /**
  58485. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58486. * In this case the connection point name must be the name of the uniform to use.
  58487. * Can only be set on inputs
  58488. */
  58489. get isUniform(): boolean;
  58490. set isUniform(value: boolean);
  58491. /**
  58492. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58493. * In this case the connection point name must be the name of the attribute to use
  58494. * Can only be set on inputs
  58495. */
  58496. get isAttribute(): boolean;
  58497. set isAttribute(value: boolean);
  58498. /**
  58499. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58500. * Can only be set on exit points
  58501. */
  58502. get isVarying(): boolean;
  58503. set isVarying(value: boolean);
  58504. /**
  58505. * Gets a boolean indicating that the current connection point is a system value
  58506. */
  58507. get isSystemValue(): boolean;
  58508. /**
  58509. * Gets or sets the current well known value or null if not defined as a system value
  58510. */
  58511. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58512. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58513. /**
  58514. * Gets the current class name
  58515. * @returns the class name
  58516. */
  58517. getClassName(): string;
  58518. /**
  58519. * Animate the input if animationType !== None
  58520. * @param scene defines the rendering scene
  58521. */
  58522. animate(scene: Scene): void;
  58523. private _emitDefine;
  58524. initialize(state: NodeMaterialBuildState): void;
  58525. /**
  58526. * Set the input block to its default value (based on its type)
  58527. */
  58528. setDefaultValue(): void;
  58529. private _emitConstant;
  58530. private _emit;
  58531. /** @hidden */
  58532. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58533. /** @hidden */
  58534. _transmit(effect: Effect, scene: Scene): void;
  58535. protected _buildBlock(state: NodeMaterialBuildState): void;
  58536. protected _dumpPropertiesCode(): string;
  58537. dispose(): void;
  58538. serialize(): any;
  58539. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58540. }
  58541. }
  58542. declare module BABYLON {
  58543. /**
  58544. * Enum used to define the compatibility state between two connection points
  58545. */
  58546. export enum NodeMaterialConnectionPointCompatibilityStates {
  58547. /** Points are compatibles */
  58548. Compatible = 0,
  58549. /** Points are incompatible because of their types */
  58550. TypeIncompatible = 1,
  58551. /** Points are incompatible because of their targets (vertex vs fragment) */
  58552. TargetIncompatible = 2
  58553. }
  58554. /**
  58555. * Defines the direction of a connection point
  58556. */
  58557. export enum NodeMaterialConnectionPointDirection {
  58558. /** Input */
  58559. Input = 0,
  58560. /** Output */
  58561. Output = 1
  58562. }
  58563. /**
  58564. * Defines a connection point for a block
  58565. */
  58566. export class NodeMaterialConnectionPoint {
  58567. /** @hidden */
  58568. _ownerBlock: NodeMaterialBlock;
  58569. /** @hidden */
  58570. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58571. private _endpoints;
  58572. private _associatedVariableName;
  58573. private _direction;
  58574. /** @hidden */
  58575. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58576. /** @hidden */
  58577. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58578. private _type;
  58579. /** @hidden */
  58580. _enforceAssociatedVariableName: boolean;
  58581. /** Gets the direction of the point */
  58582. get direction(): NodeMaterialConnectionPointDirection;
  58583. /**
  58584. * Gets or sets the additional types supported by this connection point
  58585. */
  58586. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58587. /**
  58588. * Gets or sets the additional types excluded by this connection point
  58589. */
  58590. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58591. /**
  58592. * Observable triggered when this point is connected
  58593. */
  58594. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58595. /**
  58596. * Gets or sets the associated variable name in the shader
  58597. */
  58598. get associatedVariableName(): string;
  58599. set associatedVariableName(value: string);
  58600. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58601. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58602. /**
  58603. * Gets or sets the connection point type (default is float)
  58604. */
  58605. get type(): NodeMaterialBlockConnectionPointTypes;
  58606. set type(value: NodeMaterialBlockConnectionPointTypes);
  58607. /**
  58608. * Gets or sets the connection point name
  58609. */
  58610. name: string;
  58611. /**
  58612. * Gets or sets a boolean indicating that this connection point can be omitted
  58613. */
  58614. isOptional: boolean;
  58615. /**
  58616. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58617. */
  58618. define: string;
  58619. /** @hidden */
  58620. _prioritizeVertex: boolean;
  58621. private _target;
  58622. /** Gets or sets the target of that connection point */
  58623. get target(): NodeMaterialBlockTargets;
  58624. set target(value: NodeMaterialBlockTargets);
  58625. /**
  58626. * Gets a boolean indicating that the current point is connected
  58627. */
  58628. get isConnected(): boolean;
  58629. /**
  58630. * Gets a boolean indicating that the current point is connected to an input block
  58631. */
  58632. get isConnectedToInputBlock(): boolean;
  58633. /**
  58634. * Gets a the connected input block (if any)
  58635. */
  58636. get connectInputBlock(): Nullable<InputBlock>;
  58637. /** Get the other side of the connection (if any) */
  58638. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58639. /** Get the block that owns this connection point */
  58640. get ownerBlock(): NodeMaterialBlock;
  58641. /** Get the block connected on the other side of this connection (if any) */
  58642. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58643. /** Get the block connected on the endpoints of this connection (if any) */
  58644. get connectedBlocks(): Array<NodeMaterialBlock>;
  58645. /** Gets the list of connected endpoints */
  58646. get endpoints(): NodeMaterialConnectionPoint[];
  58647. /** Gets a boolean indicating if that output point is connected to at least one input */
  58648. get hasEndpoints(): boolean;
  58649. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58650. get isConnectedInVertexShader(): boolean;
  58651. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58652. get isConnectedInFragmentShader(): boolean;
  58653. /**
  58654. * Creates a new connection point
  58655. * @param name defines the connection point name
  58656. * @param ownerBlock defines the block hosting this connection point
  58657. * @param direction defines the direction of the connection point
  58658. */
  58659. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58660. /**
  58661. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58662. * @returns the class name
  58663. */
  58664. getClassName(): string;
  58665. /**
  58666. * Gets a boolean indicating if the current point can be connected to another point
  58667. * @param connectionPoint defines the other connection point
  58668. * @returns a boolean
  58669. */
  58670. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58671. /**
  58672. * Gets a number indicating if the current point can be connected to another point
  58673. * @param connectionPoint defines the other connection point
  58674. * @returns a number defining the compatibility state
  58675. */
  58676. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58677. /**
  58678. * Connect this point to another connection point
  58679. * @param connectionPoint defines the other connection point
  58680. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58681. * @returns the current connection point
  58682. */
  58683. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58684. /**
  58685. * Disconnect this point from one of his endpoint
  58686. * @param endpoint defines the other connection point
  58687. * @returns the current connection point
  58688. */
  58689. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58690. /**
  58691. * Serializes this point in a JSON representation
  58692. * @returns the serialized point object
  58693. */
  58694. serialize(): any;
  58695. /**
  58696. * Release resources
  58697. */
  58698. dispose(): void;
  58699. }
  58700. }
  58701. declare module BABYLON {
  58702. /**
  58703. * Block used to add support for vertex skinning (bones)
  58704. */
  58705. export class BonesBlock extends NodeMaterialBlock {
  58706. /**
  58707. * Creates a new BonesBlock
  58708. * @param name defines the block name
  58709. */
  58710. constructor(name: string);
  58711. /**
  58712. * Initialize the block and prepare the context for build
  58713. * @param state defines the state that will be used for the build
  58714. */
  58715. initialize(state: NodeMaterialBuildState): void;
  58716. /**
  58717. * Gets the current class name
  58718. * @returns the class name
  58719. */
  58720. getClassName(): string;
  58721. /**
  58722. * Gets the matrix indices input component
  58723. */
  58724. get matricesIndices(): NodeMaterialConnectionPoint;
  58725. /**
  58726. * Gets the matrix weights input component
  58727. */
  58728. get matricesWeights(): NodeMaterialConnectionPoint;
  58729. /**
  58730. * Gets the extra matrix indices input component
  58731. */
  58732. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58733. /**
  58734. * Gets the extra matrix weights input component
  58735. */
  58736. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58737. /**
  58738. * Gets the world input component
  58739. */
  58740. get world(): NodeMaterialConnectionPoint;
  58741. /**
  58742. * Gets the output component
  58743. */
  58744. get output(): NodeMaterialConnectionPoint;
  58745. autoConfigure(material: NodeMaterial): void;
  58746. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58747. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58749. protected _buildBlock(state: NodeMaterialBuildState): this;
  58750. }
  58751. }
  58752. declare module BABYLON {
  58753. /**
  58754. * Block used to add support for instances
  58755. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58756. */
  58757. export class InstancesBlock extends NodeMaterialBlock {
  58758. /**
  58759. * Creates a new InstancesBlock
  58760. * @param name defines the block name
  58761. */
  58762. constructor(name: string);
  58763. /**
  58764. * Gets the current class name
  58765. * @returns the class name
  58766. */
  58767. getClassName(): string;
  58768. /**
  58769. * Gets the first world row input component
  58770. */
  58771. get world0(): NodeMaterialConnectionPoint;
  58772. /**
  58773. * Gets the second world row input component
  58774. */
  58775. get world1(): NodeMaterialConnectionPoint;
  58776. /**
  58777. * Gets the third world row input component
  58778. */
  58779. get world2(): NodeMaterialConnectionPoint;
  58780. /**
  58781. * Gets the forth world row input component
  58782. */
  58783. get world3(): NodeMaterialConnectionPoint;
  58784. /**
  58785. * Gets the world input component
  58786. */
  58787. get world(): NodeMaterialConnectionPoint;
  58788. /**
  58789. * Gets the output component
  58790. */
  58791. get output(): NodeMaterialConnectionPoint;
  58792. /**
  58793. * Gets the isntanceID component
  58794. */
  58795. get instanceID(): NodeMaterialConnectionPoint;
  58796. autoConfigure(material: NodeMaterial): void;
  58797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58798. protected _buildBlock(state: NodeMaterialBuildState): this;
  58799. }
  58800. }
  58801. declare module BABYLON {
  58802. /**
  58803. * Block used to add morph targets support to vertex shader
  58804. */
  58805. export class MorphTargetsBlock extends NodeMaterialBlock {
  58806. private _repeatableContentAnchor;
  58807. /**
  58808. * Create a new MorphTargetsBlock
  58809. * @param name defines the block name
  58810. */
  58811. constructor(name: string);
  58812. /**
  58813. * Gets the current class name
  58814. * @returns the class name
  58815. */
  58816. getClassName(): string;
  58817. /**
  58818. * Gets the position input component
  58819. */
  58820. get position(): NodeMaterialConnectionPoint;
  58821. /**
  58822. * Gets the normal input component
  58823. */
  58824. get normal(): NodeMaterialConnectionPoint;
  58825. /**
  58826. * Gets the tangent input component
  58827. */
  58828. get tangent(): NodeMaterialConnectionPoint;
  58829. /**
  58830. * Gets the tangent input component
  58831. */
  58832. get uv(): NodeMaterialConnectionPoint;
  58833. /**
  58834. * Gets the position output component
  58835. */
  58836. get positionOutput(): NodeMaterialConnectionPoint;
  58837. /**
  58838. * Gets the normal output component
  58839. */
  58840. get normalOutput(): NodeMaterialConnectionPoint;
  58841. /**
  58842. * Gets the tangent output component
  58843. */
  58844. get tangentOutput(): NodeMaterialConnectionPoint;
  58845. /**
  58846. * Gets the tangent output component
  58847. */
  58848. get uvOutput(): NodeMaterialConnectionPoint;
  58849. initialize(state: NodeMaterialBuildState): void;
  58850. autoConfigure(material: NodeMaterial): void;
  58851. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58852. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58853. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58854. protected _buildBlock(state: NodeMaterialBuildState): this;
  58855. }
  58856. }
  58857. declare module BABYLON {
  58858. /**
  58859. * Block used to get data information from a light
  58860. */
  58861. export class LightInformationBlock extends NodeMaterialBlock {
  58862. private _lightDataUniformName;
  58863. private _lightColorUniformName;
  58864. private _lightTypeDefineName;
  58865. /**
  58866. * Gets or sets the light associated with this block
  58867. */
  58868. light: Nullable<Light>;
  58869. /**
  58870. * Creates a new LightInformationBlock
  58871. * @param name defines the block name
  58872. */
  58873. constructor(name: string);
  58874. /**
  58875. * Gets the current class name
  58876. * @returns the class name
  58877. */
  58878. getClassName(): string;
  58879. /**
  58880. * Gets the world position input component
  58881. */
  58882. get worldPosition(): NodeMaterialConnectionPoint;
  58883. /**
  58884. * Gets the direction output component
  58885. */
  58886. get direction(): NodeMaterialConnectionPoint;
  58887. /**
  58888. * Gets the direction output component
  58889. */
  58890. get color(): NodeMaterialConnectionPoint;
  58891. /**
  58892. * Gets the direction output component
  58893. */
  58894. get intensity(): NodeMaterialConnectionPoint;
  58895. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58897. protected _buildBlock(state: NodeMaterialBuildState): this;
  58898. serialize(): any;
  58899. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58900. }
  58901. }
  58902. declare module BABYLON {
  58903. /**
  58904. * Block used to add image processing support to fragment shader
  58905. */
  58906. export class ImageProcessingBlock extends NodeMaterialBlock {
  58907. /**
  58908. * Create a new ImageProcessingBlock
  58909. * @param name defines the block name
  58910. */
  58911. constructor(name: string);
  58912. /**
  58913. * Gets the current class name
  58914. * @returns the class name
  58915. */
  58916. getClassName(): string;
  58917. /**
  58918. * Gets the color input component
  58919. */
  58920. get color(): NodeMaterialConnectionPoint;
  58921. /**
  58922. * Gets the output component
  58923. */
  58924. get output(): NodeMaterialConnectionPoint;
  58925. /**
  58926. * Initialize the block and prepare the context for build
  58927. * @param state defines the state that will be used for the build
  58928. */
  58929. initialize(state: NodeMaterialBuildState): void;
  58930. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58931. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58932. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58933. protected _buildBlock(state: NodeMaterialBuildState): this;
  58934. }
  58935. }
  58936. declare module BABYLON {
  58937. /**
  58938. * Block used to pertub normals based on a normal map
  58939. */
  58940. export class PerturbNormalBlock extends NodeMaterialBlock {
  58941. private _tangentSpaceParameterName;
  58942. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58943. invertX: boolean;
  58944. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58945. invertY: boolean;
  58946. /**
  58947. * Create a new PerturbNormalBlock
  58948. * @param name defines the block name
  58949. */
  58950. constructor(name: string);
  58951. /**
  58952. * Gets the current class name
  58953. * @returns the class name
  58954. */
  58955. getClassName(): string;
  58956. /**
  58957. * Gets the world position input component
  58958. */
  58959. get worldPosition(): NodeMaterialConnectionPoint;
  58960. /**
  58961. * Gets the world normal input component
  58962. */
  58963. get worldNormal(): NodeMaterialConnectionPoint;
  58964. /**
  58965. * Gets the world tangent input component
  58966. */
  58967. get worldTangent(): NodeMaterialConnectionPoint;
  58968. /**
  58969. * Gets the uv input component
  58970. */
  58971. get uv(): NodeMaterialConnectionPoint;
  58972. /**
  58973. * Gets the normal map color input component
  58974. */
  58975. get normalMapColor(): NodeMaterialConnectionPoint;
  58976. /**
  58977. * Gets the strength input component
  58978. */
  58979. get strength(): NodeMaterialConnectionPoint;
  58980. /**
  58981. * Gets the output component
  58982. */
  58983. get output(): NodeMaterialConnectionPoint;
  58984. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58985. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58986. autoConfigure(material: NodeMaterial): void;
  58987. protected _buildBlock(state: NodeMaterialBuildState): this;
  58988. protected _dumpPropertiesCode(): string;
  58989. serialize(): any;
  58990. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58991. }
  58992. }
  58993. declare module BABYLON {
  58994. /**
  58995. * Block used to discard a pixel if a value is smaller than a cutoff
  58996. */
  58997. export class DiscardBlock extends NodeMaterialBlock {
  58998. /**
  58999. * Create a new DiscardBlock
  59000. * @param name defines the block name
  59001. */
  59002. constructor(name: string);
  59003. /**
  59004. * Gets the current class name
  59005. * @returns the class name
  59006. */
  59007. getClassName(): string;
  59008. /**
  59009. * Gets the color input component
  59010. */
  59011. get value(): NodeMaterialConnectionPoint;
  59012. /**
  59013. * Gets the cutoff input component
  59014. */
  59015. get cutoff(): NodeMaterialConnectionPoint;
  59016. protected _buildBlock(state: NodeMaterialBuildState): this;
  59017. }
  59018. }
  59019. declare module BABYLON {
  59020. /**
  59021. * Block used to test if the fragment shader is front facing
  59022. */
  59023. export class FrontFacingBlock extends NodeMaterialBlock {
  59024. /**
  59025. * Creates a new FrontFacingBlock
  59026. * @param name defines the block name
  59027. */
  59028. constructor(name: string);
  59029. /**
  59030. * Gets the current class name
  59031. * @returns the class name
  59032. */
  59033. getClassName(): string;
  59034. /**
  59035. * Gets the output component
  59036. */
  59037. get output(): NodeMaterialConnectionPoint;
  59038. protected _buildBlock(state: NodeMaterialBuildState): this;
  59039. }
  59040. }
  59041. declare module BABYLON {
  59042. /**
  59043. * Block used to get the derivative value on x and y of a given input
  59044. */
  59045. export class DerivativeBlock extends NodeMaterialBlock {
  59046. /**
  59047. * Create a new DerivativeBlock
  59048. * @param name defines the block name
  59049. */
  59050. constructor(name: string);
  59051. /**
  59052. * Gets the current class name
  59053. * @returns the class name
  59054. */
  59055. getClassName(): string;
  59056. /**
  59057. * Gets the input component
  59058. */
  59059. get input(): NodeMaterialConnectionPoint;
  59060. /**
  59061. * Gets the derivative output on x
  59062. */
  59063. get dx(): NodeMaterialConnectionPoint;
  59064. /**
  59065. * Gets the derivative output on y
  59066. */
  59067. get dy(): NodeMaterialConnectionPoint;
  59068. protected _buildBlock(state: NodeMaterialBuildState): this;
  59069. }
  59070. }
  59071. declare module BABYLON {
  59072. /**
  59073. * Block used to add support for scene fog
  59074. */
  59075. export class FogBlock extends NodeMaterialBlock {
  59076. private _fogDistanceName;
  59077. private _fogParameters;
  59078. /**
  59079. * Create a new FogBlock
  59080. * @param name defines the block name
  59081. */
  59082. constructor(name: string);
  59083. /**
  59084. * Gets the current class name
  59085. * @returns the class name
  59086. */
  59087. getClassName(): string;
  59088. /**
  59089. * Gets the world position input component
  59090. */
  59091. get worldPosition(): NodeMaterialConnectionPoint;
  59092. /**
  59093. * Gets the view input component
  59094. */
  59095. get view(): NodeMaterialConnectionPoint;
  59096. /**
  59097. * Gets the color input component
  59098. */
  59099. get input(): NodeMaterialConnectionPoint;
  59100. /**
  59101. * Gets the fog color input component
  59102. */
  59103. get fogColor(): NodeMaterialConnectionPoint;
  59104. /**
  59105. * Gets the output component
  59106. */
  59107. get output(): NodeMaterialConnectionPoint;
  59108. autoConfigure(material: NodeMaterial): void;
  59109. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59110. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59111. protected _buildBlock(state: NodeMaterialBuildState): this;
  59112. }
  59113. }
  59114. declare module BABYLON {
  59115. /**
  59116. * Block used to add light in the fragment shader
  59117. */
  59118. export class LightBlock extends NodeMaterialBlock {
  59119. private _lightId;
  59120. /**
  59121. * Gets or sets the light associated with this block
  59122. */
  59123. light: Nullable<Light>;
  59124. /**
  59125. * Create a new LightBlock
  59126. * @param name defines the block name
  59127. */
  59128. constructor(name: string);
  59129. /**
  59130. * Gets the current class name
  59131. * @returns the class name
  59132. */
  59133. getClassName(): string;
  59134. /**
  59135. * Gets the world position input component
  59136. */
  59137. get worldPosition(): NodeMaterialConnectionPoint;
  59138. /**
  59139. * Gets the world normal input component
  59140. */
  59141. get worldNormal(): NodeMaterialConnectionPoint;
  59142. /**
  59143. * Gets the camera (or eye) position component
  59144. */
  59145. get cameraPosition(): NodeMaterialConnectionPoint;
  59146. /**
  59147. * Gets the glossiness component
  59148. */
  59149. get glossiness(): NodeMaterialConnectionPoint;
  59150. /**
  59151. * Gets the glossinness power component
  59152. */
  59153. get glossPower(): NodeMaterialConnectionPoint;
  59154. /**
  59155. * Gets the diffuse color component
  59156. */
  59157. get diffuseColor(): NodeMaterialConnectionPoint;
  59158. /**
  59159. * Gets the specular color component
  59160. */
  59161. get specularColor(): NodeMaterialConnectionPoint;
  59162. /**
  59163. * Gets the diffuse output component
  59164. */
  59165. get diffuseOutput(): NodeMaterialConnectionPoint;
  59166. /**
  59167. * Gets the specular output component
  59168. */
  59169. get specularOutput(): NodeMaterialConnectionPoint;
  59170. /**
  59171. * Gets the shadow output component
  59172. */
  59173. get shadow(): NodeMaterialConnectionPoint;
  59174. autoConfigure(material: NodeMaterial): void;
  59175. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59176. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59177. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59178. private _injectVertexCode;
  59179. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59180. serialize(): any;
  59181. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59182. }
  59183. }
  59184. declare module BABYLON {
  59185. /**
  59186. * Block used to multiply 2 values
  59187. */
  59188. export class MultiplyBlock extends NodeMaterialBlock {
  59189. /**
  59190. * Creates a new MultiplyBlock
  59191. * @param name defines the block name
  59192. */
  59193. constructor(name: string);
  59194. /**
  59195. * Gets the current class name
  59196. * @returns the class name
  59197. */
  59198. getClassName(): string;
  59199. /**
  59200. * Gets the left operand input component
  59201. */
  59202. get left(): NodeMaterialConnectionPoint;
  59203. /**
  59204. * Gets the right operand input component
  59205. */
  59206. get right(): NodeMaterialConnectionPoint;
  59207. /**
  59208. * Gets the output component
  59209. */
  59210. get output(): NodeMaterialConnectionPoint;
  59211. protected _buildBlock(state: NodeMaterialBuildState): this;
  59212. }
  59213. }
  59214. declare module BABYLON {
  59215. /**
  59216. * Block used to add 2 vectors
  59217. */
  59218. export class AddBlock extends NodeMaterialBlock {
  59219. /**
  59220. * Creates a new AddBlock
  59221. * @param name defines the block name
  59222. */
  59223. constructor(name: string);
  59224. /**
  59225. * Gets the current class name
  59226. * @returns the class name
  59227. */
  59228. getClassName(): string;
  59229. /**
  59230. * Gets the left operand input component
  59231. */
  59232. get left(): NodeMaterialConnectionPoint;
  59233. /**
  59234. * Gets the right operand input component
  59235. */
  59236. get right(): NodeMaterialConnectionPoint;
  59237. /**
  59238. * Gets the output component
  59239. */
  59240. get output(): NodeMaterialConnectionPoint;
  59241. protected _buildBlock(state: NodeMaterialBuildState): this;
  59242. }
  59243. }
  59244. declare module BABYLON {
  59245. /**
  59246. * Block used to scale a vector by a float
  59247. */
  59248. export class ScaleBlock extends NodeMaterialBlock {
  59249. /**
  59250. * Creates a new ScaleBlock
  59251. * @param name defines the block name
  59252. */
  59253. constructor(name: string);
  59254. /**
  59255. * Gets the current class name
  59256. * @returns the class name
  59257. */
  59258. getClassName(): string;
  59259. /**
  59260. * Gets the input component
  59261. */
  59262. get input(): NodeMaterialConnectionPoint;
  59263. /**
  59264. * Gets the factor input component
  59265. */
  59266. get factor(): NodeMaterialConnectionPoint;
  59267. /**
  59268. * Gets the output component
  59269. */
  59270. get output(): NodeMaterialConnectionPoint;
  59271. protected _buildBlock(state: NodeMaterialBuildState): this;
  59272. }
  59273. }
  59274. declare module BABYLON {
  59275. /**
  59276. * Block used to clamp a float
  59277. */
  59278. export class ClampBlock extends NodeMaterialBlock {
  59279. /** Gets or sets the minimum range */
  59280. minimum: number;
  59281. /** Gets or sets the maximum range */
  59282. maximum: number;
  59283. /**
  59284. * Creates a new ClampBlock
  59285. * @param name defines the block name
  59286. */
  59287. constructor(name: string);
  59288. /**
  59289. * Gets the current class name
  59290. * @returns the class name
  59291. */
  59292. getClassName(): string;
  59293. /**
  59294. * Gets the value input component
  59295. */
  59296. get value(): NodeMaterialConnectionPoint;
  59297. /**
  59298. * Gets the output component
  59299. */
  59300. get output(): NodeMaterialConnectionPoint;
  59301. protected _buildBlock(state: NodeMaterialBuildState): this;
  59302. protected _dumpPropertiesCode(): string;
  59303. serialize(): any;
  59304. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59305. }
  59306. }
  59307. declare module BABYLON {
  59308. /**
  59309. * Block used to apply a cross product between 2 vectors
  59310. */
  59311. export class CrossBlock extends NodeMaterialBlock {
  59312. /**
  59313. * Creates a new CrossBlock
  59314. * @param name defines the block name
  59315. */
  59316. constructor(name: string);
  59317. /**
  59318. * Gets the current class name
  59319. * @returns the class name
  59320. */
  59321. getClassName(): string;
  59322. /**
  59323. * Gets the left operand input component
  59324. */
  59325. get left(): NodeMaterialConnectionPoint;
  59326. /**
  59327. * Gets the right operand input component
  59328. */
  59329. get right(): NodeMaterialConnectionPoint;
  59330. /**
  59331. * Gets the output component
  59332. */
  59333. get output(): NodeMaterialConnectionPoint;
  59334. protected _buildBlock(state: NodeMaterialBuildState): this;
  59335. }
  59336. }
  59337. declare module BABYLON {
  59338. /**
  59339. * Block used to apply a dot product between 2 vectors
  59340. */
  59341. export class DotBlock extends NodeMaterialBlock {
  59342. /**
  59343. * Creates a new DotBlock
  59344. * @param name defines the block name
  59345. */
  59346. constructor(name: string);
  59347. /**
  59348. * Gets the current class name
  59349. * @returns the class name
  59350. */
  59351. getClassName(): string;
  59352. /**
  59353. * Gets the left operand input component
  59354. */
  59355. get left(): NodeMaterialConnectionPoint;
  59356. /**
  59357. * Gets the right operand input component
  59358. */
  59359. get right(): NodeMaterialConnectionPoint;
  59360. /**
  59361. * Gets the output component
  59362. */
  59363. get output(): NodeMaterialConnectionPoint;
  59364. protected _buildBlock(state: NodeMaterialBuildState): this;
  59365. }
  59366. }
  59367. declare module BABYLON {
  59368. /**
  59369. * Block used to remap a float from a range to a new one
  59370. */
  59371. export class RemapBlock extends NodeMaterialBlock {
  59372. /**
  59373. * Gets or sets the source range
  59374. */
  59375. sourceRange: Vector2;
  59376. /**
  59377. * Gets or sets the target range
  59378. */
  59379. targetRange: Vector2;
  59380. /**
  59381. * Creates a new RemapBlock
  59382. * @param name defines the block name
  59383. */
  59384. constructor(name: string);
  59385. /**
  59386. * Gets the current class name
  59387. * @returns the class name
  59388. */
  59389. getClassName(): string;
  59390. /**
  59391. * Gets the input component
  59392. */
  59393. get input(): NodeMaterialConnectionPoint;
  59394. /**
  59395. * Gets the source min input component
  59396. */
  59397. get sourceMin(): NodeMaterialConnectionPoint;
  59398. /**
  59399. * Gets the source max input component
  59400. */
  59401. get sourceMax(): NodeMaterialConnectionPoint;
  59402. /**
  59403. * Gets the target min input component
  59404. */
  59405. get targetMin(): NodeMaterialConnectionPoint;
  59406. /**
  59407. * Gets the target max input component
  59408. */
  59409. get targetMax(): NodeMaterialConnectionPoint;
  59410. /**
  59411. * Gets the output component
  59412. */
  59413. get output(): NodeMaterialConnectionPoint;
  59414. protected _buildBlock(state: NodeMaterialBuildState): this;
  59415. protected _dumpPropertiesCode(): string;
  59416. serialize(): any;
  59417. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59418. }
  59419. }
  59420. declare module BABYLON {
  59421. /**
  59422. * Block used to normalize a vector
  59423. */
  59424. export class NormalizeBlock extends NodeMaterialBlock {
  59425. /**
  59426. * Creates a new NormalizeBlock
  59427. * @param name defines the block name
  59428. */
  59429. constructor(name: string);
  59430. /**
  59431. * Gets the current class name
  59432. * @returns the class name
  59433. */
  59434. getClassName(): string;
  59435. /**
  59436. * Gets the input component
  59437. */
  59438. get input(): NodeMaterialConnectionPoint;
  59439. /**
  59440. * Gets the output component
  59441. */
  59442. get output(): NodeMaterialConnectionPoint;
  59443. protected _buildBlock(state: NodeMaterialBuildState): this;
  59444. }
  59445. }
  59446. declare module BABYLON {
  59447. /**
  59448. * Operations supported by the Trigonometry block
  59449. */
  59450. export enum TrigonometryBlockOperations {
  59451. /** Cos */
  59452. Cos = 0,
  59453. /** Sin */
  59454. Sin = 1,
  59455. /** Abs */
  59456. Abs = 2,
  59457. /** Exp */
  59458. Exp = 3,
  59459. /** Exp2 */
  59460. Exp2 = 4,
  59461. /** Round */
  59462. Round = 5,
  59463. /** Floor */
  59464. Floor = 6,
  59465. /** Ceiling */
  59466. Ceiling = 7,
  59467. /** Square root */
  59468. Sqrt = 8,
  59469. /** Log */
  59470. Log = 9,
  59471. /** Tangent */
  59472. Tan = 10,
  59473. /** Arc tangent */
  59474. ArcTan = 11,
  59475. /** Arc cosinus */
  59476. ArcCos = 12,
  59477. /** Arc sinus */
  59478. ArcSin = 13,
  59479. /** Fraction */
  59480. Fract = 14,
  59481. /** Sign */
  59482. Sign = 15,
  59483. /** To radians (from degrees) */
  59484. Radians = 16,
  59485. /** To degrees (from radians) */
  59486. Degrees = 17
  59487. }
  59488. /**
  59489. * Block used to apply trigonometry operation to floats
  59490. */
  59491. export class TrigonometryBlock extends NodeMaterialBlock {
  59492. /**
  59493. * Gets or sets the operation applied by the block
  59494. */
  59495. operation: TrigonometryBlockOperations;
  59496. /**
  59497. * Creates a new TrigonometryBlock
  59498. * @param name defines the block name
  59499. */
  59500. constructor(name: string);
  59501. /**
  59502. * Gets the current class name
  59503. * @returns the class name
  59504. */
  59505. getClassName(): string;
  59506. /**
  59507. * Gets the input component
  59508. */
  59509. get input(): NodeMaterialConnectionPoint;
  59510. /**
  59511. * Gets the output component
  59512. */
  59513. get output(): NodeMaterialConnectionPoint;
  59514. protected _buildBlock(state: NodeMaterialBuildState): this;
  59515. serialize(): any;
  59516. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59517. protected _dumpPropertiesCode(): string;
  59518. }
  59519. }
  59520. declare module BABYLON {
  59521. /**
  59522. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59523. */
  59524. export class ColorMergerBlock extends NodeMaterialBlock {
  59525. /**
  59526. * Create a new ColorMergerBlock
  59527. * @param name defines the block name
  59528. */
  59529. constructor(name: string);
  59530. /**
  59531. * Gets the current class name
  59532. * @returns the class name
  59533. */
  59534. getClassName(): string;
  59535. /**
  59536. * Gets the rgb component (input)
  59537. */
  59538. get rgbIn(): NodeMaterialConnectionPoint;
  59539. /**
  59540. * Gets the r component (input)
  59541. */
  59542. get r(): NodeMaterialConnectionPoint;
  59543. /**
  59544. * Gets the g component (input)
  59545. */
  59546. get g(): NodeMaterialConnectionPoint;
  59547. /**
  59548. * Gets the b component (input)
  59549. */
  59550. get b(): NodeMaterialConnectionPoint;
  59551. /**
  59552. * Gets the a component (input)
  59553. */
  59554. get a(): NodeMaterialConnectionPoint;
  59555. /**
  59556. * Gets the rgba component (output)
  59557. */
  59558. get rgba(): NodeMaterialConnectionPoint;
  59559. /**
  59560. * Gets the rgb component (output)
  59561. */
  59562. get rgbOut(): NodeMaterialConnectionPoint;
  59563. /**
  59564. * Gets the rgb component (output)
  59565. * @deprecated Please use rgbOut instead.
  59566. */
  59567. get rgb(): NodeMaterialConnectionPoint;
  59568. protected _buildBlock(state: NodeMaterialBuildState): this;
  59569. }
  59570. }
  59571. declare module BABYLON {
  59572. /**
  59573. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59574. */
  59575. export class VectorMergerBlock extends NodeMaterialBlock {
  59576. /**
  59577. * Create a new VectorMergerBlock
  59578. * @param name defines the block name
  59579. */
  59580. constructor(name: string);
  59581. /**
  59582. * Gets the current class name
  59583. * @returns the class name
  59584. */
  59585. getClassName(): string;
  59586. /**
  59587. * Gets the xyz component (input)
  59588. */
  59589. get xyzIn(): NodeMaterialConnectionPoint;
  59590. /**
  59591. * Gets the xy component (input)
  59592. */
  59593. get xyIn(): NodeMaterialConnectionPoint;
  59594. /**
  59595. * Gets the x component (input)
  59596. */
  59597. get x(): NodeMaterialConnectionPoint;
  59598. /**
  59599. * Gets the y component (input)
  59600. */
  59601. get y(): NodeMaterialConnectionPoint;
  59602. /**
  59603. * Gets the z component (input)
  59604. */
  59605. get z(): NodeMaterialConnectionPoint;
  59606. /**
  59607. * Gets the w component (input)
  59608. */
  59609. get w(): NodeMaterialConnectionPoint;
  59610. /**
  59611. * Gets the xyzw component (output)
  59612. */
  59613. get xyzw(): NodeMaterialConnectionPoint;
  59614. /**
  59615. * Gets the xyz component (output)
  59616. */
  59617. get xyzOut(): NodeMaterialConnectionPoint;
  59618. /**
  59619. * Gets the xy component (output)
  59620. */
  59621. get xyOut(): NodeMaterialConnectionPoint;
  59622. /**
  59623. * Gets the xy component (output)
  59624. * @deprecated Please use xyOut instead.
  59625. */
  59626. get xy(): NodeMaterialConnectionPoint;
  59627. /**
  59628. * Gets the xyz component (output)
  59629. * @deprecated Please use xyzOut instead.
  59630. */
  59631. get xyz(): NodeMaterialConnectionPoint;
  59632. protected _buildBlock(state: NodeMaterialBuildState): this;
  59633. }
  59634. }
  59635. declare module BABYLON {
  59636. /**
  59637. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59638. */
  59639. export class ColorSplitterBlock extends NodeMaterialBlock {
  59640. /**
  59641. * Create a new ColorSplitterBlock
  59642. * @param name defines the block name
  59643. */
  59644. constructor(name: string);
  59645. /**
  59646. * Gets the current class name
  59647. * @returns the class name
  59648. */
  59649. getClassName(): string;
  59650. /**
  59651. * Gets the rgba component (input)
  59652. */
  59653. get rgba(): NodeMaterialConnectionPoint;
  59654. /**
  59655. * Gets the rgb component (input)
  59656. */
  59657. get rgbIn(): NodeMaterialConnectionPoint;
  59658. /**
  59659. * Gets the rgb component (output)
  59660. */
  59661. get rgbOut(): NodeMaterialConnectionPoint;
  59662. /**
  59663. * Gets the r component (output)
  59664. */
  59665. get r(): NodeMaterialConnectionPoint;
  59666. /**
  59667. * Gets the g component (output)
  59668. */
  59669. get g(): NodeMaterialConnectionPoint;
  59670. /**
  59671. * Gets the b component (output)
  59672. */
  59673. get b(): NodeMaterialConnectionPoint;
  59674. /**
  59675. * Gets the a component (output)
  59676. */
  59677. get a(): NodeMaterialConnectionPoint;
  59678. protected _inputRename(name: string): string;
  59679. protected _outputRename(name: string): string;
  59680. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59681. }
  59682. }
  59683. declare module BABYLON {
  59684. /**
  59685. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59686. */
  59687. export class VectorSplitterBlock extends NodeMaterialBlock {
  59688. /**
  59689. * Create a new VectorSplitterBlock
  59690. * @param name defines the block name
  59691. */
  59692. constructor(name: string);
  59693. /**
  59694. * Gets the current class name
  59695. * @returns the class name
  59696. */
  59697. getClassName(): string;
  59698. /**
  59699. * Gets the xyzw component (input)
  59700. */
  59701. get xyzw(): NodeMaterialConnectionPoint;
  59702. /**
  59703. * Gets the xyz component (input)
  59704. */
  59705. get xyzIn(): NodeMaterialConnectionPoint;
  59706. /**
  59707. * Gets the xy component (input)
  59708. */
  59709. get xyIn(): NodeMaterialConnectionPoint;
  59710. /**
  59711. * Gets the xyz component (output)
  59712. */
  59713. get xyzOut(): NodeMaterialConnectionPoint;
  59714. /**
  59715. * Gets the xy component (output)
  59716. */
  59717. get xyOut(): NodeMaterialConnectionPoint;
  59718. /**
  59719. * Gets the x component (output)
  59720. */
  59721. get x(): NodeMaterialConnectionPoint;
  59722. /**
  59723. * Gets the y component (output)
  59724. */
  59725. get y(): NodeMaterialConnectionPoint;
  59726. /**
  59727. * Gets the z component (output)
  59728. */
  59729. get z(): NodeMaterialConnectionPoint;
  59730. /**
  59731. * Gets the w component (output)
  59732. */
  59733. get w(): NodeMaterialConnectionPoint;
  59734. protected _inputRename(name: string): string;
  59735. protected _outputRename(name: string): string;
  59736. protected _buildBlock(state: NodeMaterialBuildState): this;
  59737. }
  59738. }
  59739. declare module BABYLON {
  59740. /**
  59741. * Block used to lerp between 2 values
  59742. */
  59743. export class LerpBlock extends NodeMaterialBlock {
  59744. /**
  59745. * Creates a new LerpBlock
  59746. * @param name defines the block name
  59747. */
  59748. constructor(name: string);
  59749. /**
  59750. * Gets the current class name
  59751. * @returns the class name
  59752. */
  59753. getClassName(): string;
  59754. /**
  59755. * Gets the left operand input component
  59756. */
  59757. get left(): NodeMaterialConnectionPoint;
  59758. /**
  59759. * Gets the right operand input component
  59760. */
  59761. get right(): NodeMaterialConnectionPoint;
  59762. /**
  59763. * Gets the gradient operand input component
  59764. */
  59765. get gradient(): NodeMaterialConnectionPoint;
  59766. /**
  59767. * Gets the output component
  59768. */
  59769. get output(): NodeMaterialConnectionPoint;
  59770. protected _buildBlock(state: NodeMaterialBuildState): this;
  59771. }
  59772. }
  59773. declare module BABYLON {
  59774. /**
  59775. * Block used to divide 2 vectors
  59776. */
  59777. export class DivideBlock extends NodeMaterialBlock {
  59778. /**
  59779. * Creates a new DivideBlock
  59780. * @param name defines the block name
  59781. */
  59782. constructor(name: string);
  59783. /**
  59784. * Gets the current class name
  59785. * @returns the class name
  59786. */
  59787. getClassName(): string;
  59788. /**
  59789. * Gets the left operand input component
  59790. */
  59791. get left(): NodeMaterialConnectionPoint;
  59792. /**
  59793. * Gets the right operand input component
  59794. */
  59795. get right(): NodeMaterialConnectionPoint;
  59796. /**
  59797. * Gets the output component
  59798. */
  59799. get output(): NodeMaterialConnectionPoint;
  59800. protected _buildBlock(state: NodeMaterialBuildState): this;
  59801. }
  59802. }
  59803. declare module BABYLON {
  59804. /**
  59805. * Block used to subtract 2 vectors
  59806. */
  59807. export class SubtractBlock extends NodeMaterialBlock {
  59808. /**
  59809. * Creates a new SubtractBlock
  59810. * @param name defines the block name
  59811. */
  59812. constructor(name: string);
  59813. /**
  59814. * Gets the current class name
  59815. * @returns the class name
  59816. */
  59817. getClassName(): string;
  59818. /**
  59819. * Gets the left operand input component
  59820. */
  59821. get left(): NodeMaterialConnectionPoint;
  59822. /**
  59823. * Gets the right operand input component
  59824. */
  59825. get right(): NodeMaterialConnectionPoint;
  59826. /**
  59827. * Gets the output component
  59828. */
  59829. get output(): NodeMaterialConnectionPoint;
  59830. protected _buildBlock(state: NodeMaterialBuildState): this;
  59831. }
  59832. }
  59833. declare module BABYLON {
  59834. /**
  59835. * Block used to step a value
  59836. */
  59837. export class StepBlock extends NodeMaterialBlock {
  59838. /**
  59839. * Creates a new StepBlock
  59840. * @param name defines the block name
  59841. */
  59842. constructor(name: string);
  59843. /**
  59844. * Gets the current class name
  59845. * @returns the class name
  59846. */
  59847. getClassName(): string;
  59848. /**
  59849. * Gets the value operand input component
  59850. */
  59851. get value(): NodeMaterialConnectionPoint;
  59852. /**
  59853. * Gets the edge operand input component
  59854. */
  59855. get edge(): NodeMaterialConnectionPoint;
  59856. /**
  59857. * Gets the output component
  59858. */
  59859. get output(): NodeMaterialConnectionPoint;
  59860. protected _buildBlock(state: NodeMaterialBuildState): this;
  59861. }
  59862. }
  59863. declare module BABYLON {
  59864. /**
  59865. * Block used to get the opposite (1 - x) of a value
  59866. */
  59867. export class OneMinusBlock extends NodeMaterialBlock {
  59868. /**
  59869. * Creates a new OneMinusBlock
  59870. * @param name defines the block name
  59871. */
  59872. constructor(name: string);
  59873. /**
  59874. * Gets the current class name
  59875. * @returns the class name
  59876. */
  59877. getClassName(): string;
  59878. /**
  59879. * Gets the input component
  59880. */
  59881. get input(): NodeMaterialConnectionPoint;
  59882. /**
  59883. * Gets the output component
  59884. */
  59885. get output(): NodeMaterialConnectionPoint;
  59886. protected _buildBlock(state: NodeMaterialBuildState): this;
  59887. }
  59888. }
  59889. declare module BABYLON {
  59890. /**
  59891. * Block used to get the view direction
  59892. */
  59893. export class ViewDirectionBlock extends NodeMaterialBlock {
  59894. /**
  59895. * Creates a new ViewDirectionBlock
  59896. * @param name defines the block name
  59897. */
  59898. constructor(name: string);
  59899. /**
  59900. * Gets the current class name
  59901. * @returns the class name
  59902. */
  59903. getClassName(): string;
  59904. /**
  59905. * Gets the world position component
  59906. */
  59907. get worldPosition(): NodeMaterialConnectionPoint;
  59908. /**
  59909. * Gets the camera position component
  59910. */
  59911. get cameraPosition(): NodeMaterialConnectionPoint;
  59912. /**
  59913. * Gets the output component
  59914. */
  59915. get output(): NodeMaterialConnectionPoint;
  59916. autoConfigure(material: NodeMaterial): void;
  59917. protected _buildBlock(state: NodeMaterialBuildState): this;
  59918. }
  59919. }
  59920. declare module BABYLON {
  59921. /**
  59922. * Block used to compute fresnel value
  59923. */
  59924. export class FresnelBlock extends NodeMaterialBlock {
  59925. /**
  59926. * Create a new FresnelBlock
  59927. * @param name defines the block name
  59928. */
  59929. constructor(name: string);
  59930. /**
  59931. * Gets the current class name
  59932. * @returns the class name
  59933. */
  59934. getClassName(): string;
  59935. /**
  59936. * Gets the world normal input component
  59937. */
  59938. get worldNormal(): NodeMaterialConnectionPoint;
  59939. /**
  59940. * Gets the view direction input component
  59941. */
  59942. get viewDirection(): NodeMaterialConnectionPoint;
  59943. /**
  59944. * Gets the bias input component
  59945. */
  59946. get bias(): NodeMaterialConnectionPoint;
  59947. /**
  59948. * Gets the camera (or eye) position component
  59949. */
  59950. get power(): NodeMaterialConnectionPoint;
  59951. /**
  59952. * Gets the fresnel output component
  59953. */
  59954. get fresnel(): NodeMaterialConnectionPoint;
  59955. autoConfigure(material: NodeMaterial): void;
  59956. protected _buildBlock(state: NodeMaterialBuildState): this;
  59957. }
  59958. }
  59959. declare module BABYLON {
  59960. /**
  59961. * Block used to get the max of 2 values
  59962. */
  59963. export class MaxBlock extends NodeMaterialBlock {
  59964. /**
  59965. * Creates a new MaxBlock
  59966. * @param name defines the block name
  59967. */
  59968. constructor(name: string);
  59969. /**
  59970. * Gets the current class name
  59971. * @returns the class name
  59972. */
  59973. getClassName(): string;
  59974. /**
  59975. * Gets the left operand input component
  59976. */
  59977. get left(): NodeMaterialConnectionPoint;
  59978. /**
  59979. * Gets the right operand input component
  59980. */
  59981. get right(): NodeMaterialConnectionPoint;
  59982. /**
  59983. * Gets the output component
  59984. */
  59985. get output(): NodeMaterialConnectionPoint;
  59986. protected _buildBlock(state: NodeMaterialBuildState): this;
  59987. }
  59988. }
  59989. declare module BABYLON {
  59990. /**
  59991. * Block used to get the min of 2 values
  59992. */
  59993. export class MinBlock extends NodeMaterialBlock {
  59994. /**
  59995. * Creates a new MinBlock
  59996. * @param name defines the block name
  59997. */
  59998. constructor(name: string);
  59999. /**
  60000. * Gets the current class name
  60001. * @returns the class name
  60002. */
  60003. getClassName(): string;
  60004. /**
  60005. * Gets the left operand input component
  60006. */
  60007. get left(): NodeMaterialConnectionPoint;
  60008. /**
  60009. * Gets the right operand input component
  60010. */
  60011. get right(): NodeMaterialConnectionPoint;
  60012. /**
  60013. * Gets the output component
  60014. */
  60015. get output(): NodeMaterialConnectionPoint;
  60016. protected _buildBlock(state: NodeMaterialBuildState): this;
  60017. }
  60018. }
  60019. declare module BABYLON {
  60020. /**
  60021. * Block used to get the distance between 2 values
  60022. */
  60023. export class DistanceBlock extends NodeMaterialBlock {
  60024. /**
  60025. * Creates a new DistanceBlock
  60026. * @param name defines the block name
  60027. */
  60028. constructor(name: string);
  60029. /**
  60030. * Gets the current class name
  60031. * @returns the class name
  60032. */
  60033. getClassName(): string;
  60034. /**
  60035. * Gets the left operand input component
  60036. */
  60037. get left(): NodeMaterialConnectionPoint;
  60038. /**
  60039. * Gets the right operand input component
  60040. */
  60041. get right(): NodeMaterialConnectionPoint;
  60042. /**
  60043. * Gets the output component
  60044. */
  60045. get output(): NodeMaterialConnectionPoint;
  60046. protected _buildBlock(state: NodeMaterialBuildState): this;
  60047. }
  60048. }
  60049. declare module BABYLON {
  60050. /**
  60051. * Block used to get the length of a vector
  60052. */
  60053. export class LengthBlock extends NodeMaterialBlock {
  60054. /**
  60055. * Creates a new LengthBlock
  60056. * @param name defines the block name
  60057. */
  60058. constructor(name: string);
  60059. /**
  60060. * Gets the current class name
  60061. * @returns the class name
  60062. */
  60063. getClassName(): string;
  60064. /**
  60065. * Gets the value input component
  60066. */
  60067. get value(): NodeMaterialConnectionPoint;
  60068. /**
  60069. * Gets the output component
  60070. */
  60071. get output(): NodeMaterialConnectionPoint;
  60072. protected _buildBlock(state: NodeMaterialBuildState): this;
  60073. }
  60074. }
  60075. declare module BABYLON {
  60076. /**
  60077. * Block used to get negative version of a value (i.e. x * -1)
  60078. */
  60079. export class NegateBlock extends NodeMaterialBlock {
  60080. /**
  60081. * Creates a new NegateBlock
  60082. * @param name defines the block name
  60083. */
  60084. constructor(name: string);
  60085. /**
  60086. * Gets the current class name
  60087. * @returns the class name
  60088. */
  60089. getClassName(): string;
  60090. /**
  60091. * Gets the value input component
  60092. */
  60093. get value(): NodeMaterialConnectionPoint;
  60094. /**
  60095. * Gets the output component
  60096. */
  60097. get output(): NodeMaterialConnectionPoint;
  60098. protected _buildBlock(state: NodeMaterialBuildState): this;
  60099. }
  60100. }
  60101. declare module BABYLON {
  60102. /**
  60103. * Block used to get the value of the first parameter raised to the power of the second
  60104. */
  60105. export class PowBlock extends NodeMaterialBlock {
  60106. /**
  60107. * Creates a new PowBlock
  60108. * @param name defines the block name
  60109. */
  60110. constructor(name: string);
  60111. /**
  60112. * Gets the current class name
  60113. * @returns the class name
  60114. */
  60115. getClassName(): string;
  60116. /**
  60117. * Gets the value operand input component
  60118. */
  60119. get value(): NodeMaterialConnectionPoint;
  60120. /**
  60121. * Gets the power operand input component
  60122. */
  60123. get power(): NodeMaterialConnectionPoint;
  60124. /**
  60125. * Gets the output component
  60126. */
  60127. get output(): NodeMaterialConnectionPoint;
  60128. protected _buildBlock(state: NodeMaterialBuildState): this;
  60129. }
  60130. }
  60131. declare module BABYLON {
  60132. /**
  60133. * Block used to get a random number
  60134. */
  60135. export class RandomNumberBlock extends NodeMaterialBlock {
  60136. /**
  60137. * Creates a new RandomNumberBlock
  60138. * @param name defines the block name
  60139. */
  60140. constructor(name: string);
  60141. /**
  60142. * Gets the current class name
  60143. * @returns the class name
  60144. */
  60145. getClassName(): string;
  60146. /**
  60147. * Gets the seed input component
  60148. */
  60149. get seed(): NodeMaterialConnectionPoint;
  60150. /**
  60151. * Gets the output component
  60152. */
  60153. get output(): NodeMaterialConnectionPoint;
  60154. protected _buildBlock(state: NodeMaterialBuildState): this;
  60155. }
  60156. }
  60157. declare module BABYLON {
  60158. /**
  60159. * Block used to compute arc tangent of 2 values
  60160. */
  60161. export class ArcTan2Block extends NodeMaterialBlock {
  60162. /**
  60163. * Creates a new ArcTan2Block
  60164. * @param name defines the block name
  60165. */
  60166. constructor(name: string);
  60167. /**
  60168. * Gets the current class name
  60169. * @returns the class name
  60170. */
  60171. getClassName(): string;
  60172. /**
  60173. * Gets the x operand input component
  60174. */
  60175. get x(): NodeMaterialConnectionPoint;
  60176. /**
  60177. * Gets the y operand input component
  60178. */
  60179. get y(): NodeMaterialConnectionPoint;
  60180. /**
  60181. * Gets the output component
  60182. */
  60183. get output(): NodeMaterialConnectionPoint;
  60184. protected _buildBlock(state: NodeMaterialBuildState): this;
  60185. }
  60186. }
  60187. declare module BABYLON {
  60188. /**
  60189. * Block used to smooth step a value
  60190. */
  60191. export class SmoothStepBlock extends NodeMaterialBlock {
  60192. /**
  60193. * Creates a new SmoothStepBlock
  60194. * @param name defines the block name
  60195. */
  60196. constructor(name: string);
  60197. /**
  60198. * Gets the current class name
  60199. * @returns the class name
  60200. */
  60201. getClassName(): string;
  60202. /**
  60203. * Gets the value operand input component
  60204. */
  60205. get value(): NodeMaterialConnectionPoint;
  60206. /**
  60207. * Gets the first edge operand input component
  60208. */
  60209. get edge0(): NodeMaterialConnectionPoint;
  60210. /**
  60211. * Gets the second edge operand input component
  60212. */
  60213. get edge1(): NodeMaterialConnectionPoint;
  60214. /**
  60215. * Gets the output component
  60216. */
  60217. get output(): NodeMaterialConnectionPoint;
  60218. protected _buildBlock(state: NodeMaterialBuildState): this;
  60219. }
  60220. }
  60221. declare module BABYLON {
  60222. /**
  60223. * Block used to get the reciprocal (1 / x) of a value
  60224. */
  60225. export class ReciprocalBlock extends NodeMaterialBlock {
  60226. /**
  60227. * Creates a new ReciprocalBlock
  60228. * @param name defines the block name
  60229. */
  60230. constructor(name: string);
  60231. /**
  60232. * Gets the current class name
  60233. * @returns the class name
  60234. */
  60235. getClassName(): string;
  60236. /**
  60237. * Gets the input component
  60238. */
  60239. get input(): NodeMaterialConnectionPoint;
  60240. /**
  60241. * Gets the output component
  60242. */
  60243. get output(): NodeMaterialConnectionPoint;
  60244. protected _buildBlock(state: NodeMaterialBuildState): this;
  60245. }
  60246. }
  60247. declare module BABYLON {
  60248. /**
  60249. * Block used to replace a color by another one
  60250. */
  60251. export class ReplaceColorBlock extends NodeMaterialBlock {
  60252. /**
  60253. * Creates a new ReplaceColorBlock
  60254. * @param name defines the block name
  60255. */
  60256. constructor(name: string);
  60257. /**
  60258. * Gets the current class name
  60259. * @returns the class name
  60260. */
  60261. getClassName(): string;
  60262. /**
  60263. * Gets the value input component
  60264. */
  60265. get value(): NodeMaterialConnectionPoint;
  60266. /**
  60267. * Gets the reference input component
  60268. */
  60269. get reference(): NodeMaterialConnectionPoint;
  60270. /**
  60271. * Gets the distance input component
  60272. */
  60273. get distance(): NodeMaterialConnectionPoint;
  60274. /**
  60275. * Gets the replacement input component
  60276. */
  60277. get replacement(): NodeMaterialConnectionPoint;
  60278. /**
  60279. * Gets the output component
  60280. */
  60281. get output(): NodeMaterialConnectionPoint;
  60282. protected _buildBlock(state: NodeMaterialBuildState): this;
  60283. }
  60284. }
  60285. declare module BABYLON {
  60286. /**
  60287. * Block used to posterize a value
  60288. * @see https://en.wikipedia.org/wiki/Posterization
  60289. */
  60290. export class PosterizeBlock extends NodeMaterialBlock {
  60291. /**
  60292. * Creates a new PosterizeBlock
  60293. * @param name defines the block name
  60294. */
  60295. constructor(name: string);
  60296. /**
  60297. * Gets the current class name
  60298. * @returns the class name
  60299. */
  60300. getClassName(): string;
  60301. /**
  60302. * Gets the value input component
  60303. */
  60304. get value(): NodeMaterialConnectionPoint;
  60305. /**
  60306. * Gets the steps input component
  60307. */
  60308. get steps(): NodeMaterialConnectionPoint;
  60309. /**
  60310. * Gets the output component
  60311. */
  60312. get output(): NodeMaterialConnectionPoint;
  60313. protected _buildBlock(state: NodeMaterialBuildState): this;
  60314. }
  60315. }
  60316. declare module BABYLON {
  60317. /**
  60318. * Operations supported by the Wave block
  60319. */
  60320. export enum WaveBlockKind {
  60321. /** SawTooth */
  60322. SawTooth = 0,
  60323. /** Square */
  60324. Square = 1,
  60325. /** Triangle */
  60326. Triangle = 2
  60327. }
  60328. /**
  60329. * Block used to apply wave operation to floats
  60330. */
  60331. export class WaveBlock extends NodeMaterialBlock {
  60332. /**
  60333. * Gets or sets the kibnd of wave to be applied by the block
  60334. */
  60335. kind: WaveBlockKind;
  60336. /**
  60337. * Creates a new WaveBlock
  60338. * @param name defines the block name
  60339. */
  60340. constructor(name: string);
  60341. /**
  60342. * Gets the current class name
  60343. * @returns the class name
  60344. */
  60345. getClassName(): string;
  60346. /**
  60347. * Gets the input component
  60348. */
  60349. get input(): NodeMaterialConnectionPoint;
  60350. /**
  60351. * Gets the output component
  60352. */
  60353. get output(): NodeMaterialConnectionPoint;
  60354. protected _buildBlock(state: NodeMaterialBuildState): this;
  60355. serialize(): any;
  60356. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60357. }
  60358. }
  60359. declare module BABYLON {
  60360. /**
  60361. * Class used to store a color step for the GradientBlock
  60362. */
  60363. export class GradientBlockColorStep {
  60364. /**
  60365. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60366. */
  60367. step: number;
  60368. /**
  60369. * Gets or sets the color associated with this step
  60370. */
  60371. color: Color3;
  60372. /**
  60373. * Creates a new GradientBlockColorStep
  60374. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60375. * @param color defines the color associated with this step
  60376. */
  60377. constructor(
  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. /**
  60388. * Block used to return a color from a gradient based on an input value between 0 and 1
  60389. */
  60390. export class GradientBlock extends NodeMaterialBlock {
  60391. /**
  60392. * Gets or sets the list of color steps
  60393. */
  60394. colorSteps: GradientBlockColorStep[];
  60395. /**
  60396. * Creates a new GradientBlock
  60397. * @param name defines the block name
  60398. */
  60399. constructor(name: string);
  60400. /**
  60401. * Gets the current class name
  60402. * @returns the class name
  60403. */
  60404. getClassName(): string;
  60405. /**
  60406. * Gets the gradient input component
  60407. */
  60408. get gradient(): NodeMaterialConnectionPoint;
  60409. /**
  60410. * Gets the output component
  60411. */
  60412. get output(): NodeMaterialConnectionPoint;
  60413. private _writeColorConstant;
  60414. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60415. serialize(): any;
  60416. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60417. protected _dumpPropertiesCode(): string;
  60418. }
  60419. }
  60420. declare module BABYLON {
  60421. /**
  60422. * Block used to normalize lerp between 2 values
  60423. */
  60424. export class NLerpBlock extends NodeMaterialBlock {
  60425. /**
  60426. * Creates a new NLerpBlock
  60427. * @param name defines the block name
  60428. */
  60429. constructor(name: string);
  60430. /**
  60431. * Gets the current class name
  60432. * @returns the class name
  60433. */
  60434. getClassName(): string;
  60435. /**
  60436. * Gets the left operand input component
  60437. */
  60438. get left(): NodeMaterialConnectionPoint;
  60439. /**
  60440. * Gets the right operand input component
  60441. */
  60442. get right(): NodeMaterialConnectionPoint;
  60443. /**
  60444. * Gets the gradient operand input component
  60445. */
  60446. get gradient(): NodeMaterialConnectionPoint;
  60447. /**
  60448. * Gets the output component
  60449. */
  60450. get output(): NodeMaterialConnectionPoint;
  60451. protected _buildBlock(state: NodeMaterialBuildState): this;
  60452. }
  60453. }
  60454. declare module BABYLON {
  60455. /**
  60456. * block used to Generate a Worley Noise 3D Noise Pattern
  60457. */
  60458. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60459. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60460. manhattanDistance: boolean;
  60461. /**
  60462. * Creates a new WorleyNoise3DBlock
  60463. * @param name defines the block name
  60464. */
  60465. constructor(name: string);
  60466. /**
  60467. * Gets the current class name
  60468. * @returns the class name
  60469. */
  60470. getClassName(): string;
  60471. /**
  60472. * Gets the seed input component
  60473. */
  60474. get seed(): NodeMaterialConnectionPoint;
  60475. /**
  60476. * Gets the jitter input component
  60477. */
  60478. get jitter(): NodeMaterialConnectionPoint;
  60479. /**
  60480. * Gets the output component
  60481. */
  60482. get output(): NodeMaterialConnectionPoint;
  60483. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60484. /**
  60485. * Exposes the properties to the UI?
  60486. */
  60487. protected _dumpPropertiesCode(): string;
  60488. /**
  60489. * Exposes the properties to the Seralize?
  60490. */
  60491. serialize(): any;
  60492. /**
  60493. * Exposes the properties to the deseralize?
  60494. */
  60495. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60496. }
  60497. }
  60498. declare module BABYLON {
  60499. /**
  60500. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60501. */
  60502. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60503. /**
  60504. * Creates a new SimplexPerlin3DBlock
  60505. * @param name defines the block name
  60506. */
  60507. constructor(name: string);
  60508. /**
  60509. * Gets the current class name
  60510. * @returns the class name
  60511. */
  60512. getClassName(): string;
  60513. /**
  60514. * Gets the seed operand input component
  60515. */
  60516. get seed(): NodeMaterialConnectionPoint;
  60517. /**
  60518. * Gets the output component
  60519. */
  60520. get output(): NodeMaterialConnectionPoint;
  60521. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60522. }
  60523. }
  60524. declare module BABYLON {
  60525. /**
  60526. * Block used to blend normals
  60527. */
  60528. export class NormalBlendBlock extends NodeMaterialBlock {
  60529. /**
  60530. * Creates a new NormalBlendBlock
  60531. * @param name defines the block name
  60532. */
  60533. constructor(name: string);
  60534. /**
  60535. * Gets the current class name
  60536. * @returns the class name
  60537. */
  60538. getClassName(): string;
  60539. /**
  60540. * Gets the first input component
  60541. */
  60542. get normalMap0(): NodeMaterialConnectionPoint;
  60543. /**
  60544. * Gets the second input component
  60545. */
  60546. get normalMap1(): NodeMaterialConnectionPoint;
  60547. /**
  60548. * Gets the output component
  60549. */
  60550. get output(): NodeMaterialConnectionPoint;
  60551. protected _buildBlock(state: NodeMaterialBuildState): this;
  60552. }
  60553. }
  60554. declare module BABYLON {
  60555. /**
  60556. * Block used to rotate a 2d vector by a given angle
  60557. */
  60558. export class Rotate2dBlock extends NodeMaterialBlock {
  60559. /**
  60560. * Creates a new Rotate2dBlock
  60561. * @param name defines the block name
  60562. */
  60563. constructor(name: string);
  60564. /**
  60565. * Gets the current class name
  60566. * @returns the class name
  60567. */
  60568. getClassName(): string;
  60569. /**
  60570. * Gets the input vector
  60571. */
  60572. get input(): NodeMaterialConnectionPoint;
  60573. /**
  60574. * Gets the input angle
  60575. */
  60576. get angle(): NodeMaterialConnectionPoint;
  60577. /**
  60578. * Gets the output component
  60579. */
  60580. get output(): NodeMaterialConnectionPoint;
  60581. autoConfigure(material: NodeMaterial): void;
  60582. protected _buildBlock(state: NodeMaterialBuildState): this;
  60583. }
  60584. }
  60585. declare module BABYLON {
  60586. /**
  60587. * Block used to get the reflected vector from a direction and a normal
  60588. */
  60589. export class ReflectBlock extends NodeMaterialBlock {
  60590. /**
  60591. * Creates a new ReflectBlock
  60592. * @param name defines the block name
  60593. */
  60594. constructor(name: string);
  60595. /**
  60596. * Gets the current class name
  60597. * @returns the class name
  60598. */
  60599. getClassName(): string;
  60600. /**
  60601. * Gets the incident component
  60602. */
  60603. get incident(): NodeMaterialConnectionPoint;
  60604. /**
  60605. * Gets the normal component
  60606. */
  60607. get normal(): NodeMaterialConnectionPoint;
  60608. /**
  60609. * Gets the output component
  60610. */
  60611. get output(): NodeMaterialConnectionPoint;
  60612. protected _buildBlock(state: NodeMaterialBuildState): this;
  60613. }
  60614. }
  60615. declare module BABYLON {
  60616. /**
  60617. * Block used to get the refracted vector from a direction and a normal
  60618. */
  60619. export class RefractBlock extends NodeMaterialBlock {
  60620. /**
  60621. * Creates a new RefractBlock
  60622. * @param name defines the block name
  60623. */
  60624. constructor(name: string);
  60625. /**
  60626. * Gets the current class name
  60627. * @returns the class name
  60628. */
  60629. getClassName(): string;
  60630. /**
  60631. * Gets the incident component
  60632. */
  60633. get incident(): NodeMaterialConnectionPoint;
  60634. /**
  60635. * Gets the normal component
  60636. */
  60637. get normal(): NodeMaterialConnectionPoint;
  60638. /**
  60639. * Gets the index of refraction component
  60640. */
  60641. get ior(): NodeMaterialConnectionPoint;
  60642. /**
  60643. * Gets the output component
  60644. */
  60645. get output(): NodeMaterialConnectionPoint;
  60646. protected _buildBlock(state: NodeMaterialBuildState): this;
  60647. }
  60648. }
  60649. declare module BABYLON {
  60650. /**
  60651. * Block used to desaturate a color
  60652. */
  60653. export class DesaturateBlock extends NodeMaterialBlock {
  60654. /**
  60655. * Creates a new DesaturateBlock
  60656. * @param name defines the block name
  60657. */
  60658. constructor(name: string);
  60659. /**
  60660. * Gets the current class name
  60661. * @returns the class name
  60662. */
  60663. getClassName(): string;
  60664. /**
  60665. * Gets the color operand input component
  60666. */
  60667. get color(): NodeMaterialConnectionPoint;
  60668. /**
  60669. * Gets the level operand input component
  60670. */
  60671. get level(): NodeMaterialConnectionPoint;
  60672. /**
  60673. * Gets the output component
  60674. */
  60675. get output(): NodeMaterialConnectionPoint;
  60676. protected _buildBlock(state: NodeMaterialBuildState): this;
  60677. }
  60678. }
  60679. declare module BABYLON {
  60680. /**
  60681. * Effect Render Options
  60682. */
  60683. export interface IEffectRendererOptions {
  60684. /**
  60685. * Defines the vertices positions.
  60686. */
  60687. positions?: number[];
  60688. /**
  60689. * Defines the indices.
  60690. */
  60691. indices?: number[];
  60692. }
  60693. /**
  60694. * Helper class to render one or more effects
  60695. */
  60696. export class EffectRenderer {
  60697. private engine;
  60698. private static _DefaultOptions;
  60699. private _vertexBuffers;
  60700. private _indexBuffer;
  60701. private _ringBufferIndex;
  60702. private _ringScreenBuffer;
  60703. private _fullscreenViewport;
  60704. private _getNextFrameBuffer;
  60705. /**
  60706. * Creates an effect renderer
  60707. * @param engine the engine to use for rendering
  60708. * @param options defines the options of the effect renderer
  60709. */
  60710. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60711. /**
  60712. * Sets the current viewport in normalized coordinates 0-1
  60713. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60714. */
  60715. setViewport(viewport?: Viewport): void;
  60716. /**
  60717. * Binds the embedded attributes buffer to the effect.
  60718. * @param effect Defines the effect to bind the attributes for
  60719. */
  60720. bindBuffers(effect: Effect): void;
  60721. /**
  60722. * Sets the current effect wrapper to use during draw.
  60723. * The effect needs to be ready before calling this api.
  60724. * This also sets the default full screen position attribute.
  60725. * @param effectWrapper Defines the effect to draw with
  60726. */
  60727. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60728. /**
  60729. * Draws a full screen quad.
  60730. */
  60731. draw(): void;
  60732. /**
  60733. * renders one or more effects to a specified texture
  60734. * @param effectWrappers list of effects to renderer
  60735. * @param outputTexture texture to draw to, if null it will render to the screen
  60736. */
  60737. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60738. /**
  60739. * Disposes of the effect renderer
  60740. */
  60741. dispose(): void;
  60742. }
  60743. /**
  60744. * Options to create an EffectWrapper
  60745. */
  60746. interface EffectWrapperCreationOptions {
  60747. /**
  60748. * Engine to use to create the effect
  60749. */
  60750. engine: ThinEngine;
  60751. /**
  60752. * Fragment shader for the effect
  60753. */
  60754. fragmentShader: string;
  60755. /**
  60756. * Vertex shader for the effect
  60757. */
  60758. vertexShader?: string;
  60759. /**
  60760. * Attributes to use in the shader
  60761. */
  60762. attributeNames?: Array<string>;
  60763. /**
  60764. * Uniforms to use in the shader
  60765. */
  60766. uniformNames?: Array<string>;
  60767. /**
  60768. * Texture sampler names to use in the shader
  60769. */
  60770. samplerNames?: Array<string>;
  60771. /**
  60772. * The friendly name of the effect displayed in Spector.
  60773. */
  60774. name?: string;
  60775. }
  60776. /**
  60777. * Wraps an effect to be used for rendering
  60778. */
  60779. export class EffectWrapper {
  60780. /**
  60781. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60782. */
  60783. onApplyObservable: Observable<{}>;
  60784. /**
  60785. * The underlying effect
  60786. */
  60787. effect: Effect;
  60788. /**
  60789. * Creates an effect to be renderer
  60790. * @param creationOptions options to create the effect
  60791. */
  60792. constructor(creationOptions: EffectWrapperCreationOptions);
  60793. /**
  60794. * Disposes of the effect wrapper
  60795. */
  60796. dispose(): void;
  60797. }
  60798. }
  60799. declare module BABYLON {
  60800. /**
  60801. * Helper class to push actions to a pool of workers.
  60802. */
  60803. export class WorkerPool implements IDisposable {
  60804. private _workerInfos;
  60805. private _pendingActions;
  60806. /**
  60807. * Constructor
  60808. * @param workers Array of workers to use for actions
  60809. */
  60810. constructor(workers: Array<Worker>);
  60811. /**
  60812. * Terminates all workers and clears any pending actions.
  60813. */
  60814. dispose(): void;
  60815. /**
  60816. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60817. * pended until a worker has completed its action.
  60818. * @param action The action to perform. Call onComplete when the action is complete.
  60819. */
  60820. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60821. private _execute;
  60822. }
  60823. }
  60824. declare module BABYLON {
  60825. /**
  60826. * Configuration for Draco compression
  60827. */
  60828. export interface IDracoCompressionConfiguration {
  60829. /**
  60830. * Configuration for the decoder.
  60831. */
  60832. decoder: {
  60833. /**
  60834. * The url to the WebAssembly module.
  60835. */
  60836. wasmUrl?: string;
  60837. /**
  60838. * The url to the WebAssembly binary.
  60839. */
  60840. wasmBinaryUrl?: string;
  60841. /**
  60842. * The url to the fallback JavaScript module.
  60843. */
  60844. fallbackUrl?: string;
  60845. };
  60846. }
  60847. /**
  60848. * Draco compression (https://google.github.io/draco/)
  60849. *
  60850. * This class wraps the Draco module.
  60851. *
  60852. * **Encoder**
  60853. *
  60854. * The encoder is not currently implemented.
  60855. *
  60856. * **Decoder**
  60857. *
  60858. * 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.
  60859. *
  60860. * To update the configuration, use the following code:
  60861. * ```javascript
  60862. * DracoCompression.Configuration = {
  60863. * decoder: {
  60864. * wasmUrl: "<url to the WebAssembly library>",
  60865. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60866. * fallbackUrl: "<url to the fallback JavaScript library>",
  60867. * }
  60868. * };
  60869. * ```
  60870. *
  60871. * 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.
  60872. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60873. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60874. *
  60875. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60876. * ```javascript
  60877. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60878. * ```
  60879. *
  60880. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60881. */
  60882. export class DracoCompression implements IDisposable {
  60883. private _workerPoolPromise?;
  60884. private _decoderModulePromise?;
  60885. /**
  60886. * The configuration. Defaults to the following urls:
  60887. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60888. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60889. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60890. */
  60891. static Configuration: IDracoCompressionConfiguration;
  60892. /**
  60893. * Returns true if the decoder configuration is available.
  60894. */
  60895. static get DecoderAvailable(): boolean;
  60896. /**
  60897. * Default number of workers to create when creating the draco compression object.
  60898. */
  60899. static DefaultNumWorkers: number;
  60900. private static GetDefaultNumWorkers;
  60901. private static _Default;
  60902. /**
  60903. * Default instance for the draco compression object.
  60904. */
  60905. static get Default(): DracoCompression;
  60906. /**
  60907. * Constructor
  60908. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60909. */
  60910. constructor(numWorkers?: number);
  60911. /**
  60912. * Stop all async operations and release resources.
  60913. */
  60914. dispose(): void;
  60915. /**
  60916. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60917. * @returns a promise that resolves when ready
  60918. */
  60919. whenReadyAsync(): Promise<void>;
  60920. /**
  60921. * Decode Draco compressed mesh data to vertex data.
  60922. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60923. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60924. * @returns A promise that resolves with the decoded vertex data
  60925. */
  60926. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60927. [kind: string]: number;
  60928. }): Promise<VertexData>;
  60929. }
  60930. }
  60931. declare module BABYLON {
  60932. /**
  60933. * Class for building Constructive Solid Geometry
  60934. */
  60935. export class CSG {
  60936. private polygons;
  60937. /**
  60938. * The world matrix
  60939. */
  60940. matrix: Matrix;
  60941. /**
  60942. * Stores the position
  60943. */
  60944. position: Vector3;
  60945. /**
  60946. * Stores the rotation
  60947. */
  60948. rotation: Vector3;
  60949. /**
  60950. * Stores the rotation quaternion
  60951. */
  60952. rotationQuaternion: Nullable<Quaternion>;
  60953. /**
  60954. * Stores the scaling vector
  60955. */
  60956. scaling: Vector3;
  60957. /**
  60958. * Convert the Mesh to CSG
  60959. * @param mesh The Mesh to convert to CSG
  60960. * @returns A new CSG from the Mesh
  60961. */
  60962. static FromMesh(mesh: Mesh): CSG;
  60963. /**
  60964. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60965. * @param polygons Polygons used to construct a CSG solid
  60966. */
  60967. private static FromPolygons;
  60968. /**
  60969. * Clones, or makes a deep copy, of the CSG
  60970. * @returns A new CSG
  60971. */
  60972. clone(): CSG;
  60973. /**
  60974. * Unions this CSG with another CSG
  60975. * @param csg The CSG to union against this CSG
  60976. * @returns The unioned CSG
  60977. */
  60978. union(csg: CSG): CSG;
  60979. /**
  60980. * Unions this CSG with another CSG in place
  60981. * @param csg The CSG to union against this CSG
  60982. */
  60983. unionInPlace(csg: CSG): void;
  60984. /**
  60985. * Subtracts this CSG with another CSG
  60986. * @param csg The CSG to subtract against this CSG
  60987. * @returns A new CSG
  60988. */
  60989. subtract(csg: CSG): CSG;
  60990. /**
  60991. * Subtracts this CSG with another CSG in place
  60992. * @param csg The CSG to subtact against this CSG
  60993. */
  60994. subtractInPlace(csg: CSG): void;
  60995. /**
  60996. * Intersect this CSG with another CSG
  60997. * @param csg The CSG to intersect against this CSG
  60998. * @returns A new CSG
  60999. */
  61000. intersect(csg: CSG): CSG;
  61001. /**
  61002. * Intersects this CSG with another CSG in place
  61003. * @param csg The CSG to intersect against this CSG
  61004. */
  61005. intersectInPlace(csg: CSG): void;
  61006. /**
  61007. * Return a new CSG solid with solid and empty space switched. This solid is
  61008. * not modified.
  61009. * @returns A new CSG solid with solid and empty space switched
  61010. */
  61011. inverse(): CSG;
  61012. /**
  61013. * Inverses the CSG in place
  61014. */
  61015. inverseInPlace(): void;
  61016. /**
  61017. * This is used to keep meshes transformations so they can be restored
  61018. * when we build back a Babylon Mesh
  61019. * NB : All CSG operations are performed in world coordinates
  61020. * @param csg The CSG to copy the transform attributes from
  61021. * @returns This CSG
  61022. */
  61023. copyTransformAttributes(csg: CSG): CSG;
  61024. /**
  61025. * Build Raw mesh from CSG
  61026. * Coordinates here are in world space
  61027. * @param name The name of the mesh geometry
  61028. * @param scene The Scene
  61029. * @param keepSubMeshes Specifies if the submeshes should be kept
  61030. * @returns A new Mesh
  61031. */
  61032. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61033. /**
  61034. * Build Mesh from CSG taking material and transforms into account
  61035. * @param name The name of the Mesh
  61036. * @param material The material of the Mesh
  61037. * @param scene The Scene
  61038. * @param keepSubMeshes Specifies if submeshes should be kept
  61039. * @returns The new Mesh
  61040. */
  61041. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61042. }
  61043. }
  61044. declare module BABYLON {
  61045. /**
  61046. * Class used to create a trail following a mesh
  61047. */
  61048. export class TrailMesh extends Mesh {
  61049. private _generator;
  61050. private _autoStart;
  61051. private _running;
  61052. private _diameter;
  61053. private _length;
  61054. private _sectionPolygonPointsCount;
  61055. private _sectionVectors;
  61056. private _sectionNormalVectors;
  61057. private _beforeRenderObserver;
  61058. /**
  61059. * @constructor
  61060. * @param name The value used by scene.getMeshByName() to do a lookup.
  61061. * @param generator The mesh or transform node to generate a trail.
  61062. * @param scene The scene to add this mesh to.
  61063. * @param diameter Diameter of trailing mesh. Default is 1.
  61064. * @param length Length of trailing mesh. Default is 60.
  61065. * @param autoStart Automatically start trailing mesh. Default true.
  61066. */
  61067. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61068. /**
  61069. * "TrailMesh"
  61070. * @returns "TrailMesh"
  61071. */
  61072. getClassName(): string;
  61073. private _createMesh;
  61074. /**
  61075. * Start trailing mesh.
  61076. */
  61077. start(): void;
  61078. /**
  61079. * Stop trailing mesh.
  61080. */
  61081. stop(): void;
  61082. /**
  61083. * Update trailing mesh geometry.
  61084. */
  61085. update(): void;
  61086. /**
  61087. * Returns a new TrailMesh object.
  61088. * @param name is a string, the name given to the new mesh
  61089. * @param newGenerator use new generator object for cloned trail mesh
  61090. * @returns a new mesh
  61091. */
  61092. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61093. /**
  61094. * Serializes this trail mesh
  61095. * @param serializationObject object to write serialization to
  61096. */
  61097. serialize(serializationObject: any): void;
  61098. /**
  61099. * Parses a serialized trail mesh
  61100. * @param parsedMesh the serialized mesh
  61101. * @param scene the scene to create the trail mesh in
  61102. * @returns the created trail mesh
  61103. */
  61104. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61105. }
  61106. }
  61107. declare module BABYLON {
  61108. /**
  61109. * Class containing static functions to help procedurally build meshes
  61110. */
  61111. export class TiledBoxBuilder {
  61112. /**
  61113. * Creates a box mesh
  61114. * 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)
  61115. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61117. * * 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
  61118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61119. * @param name defines the name of the mesh
  61120. * @param options defines the options used to create the mesh
  61121. * @param scene defines the hosting scene
  61122. * @returns the box mesh
  61123. */
  61124. static CreateTiledBox(name: string, options: {
  61125. pattern?: number;
  61126. width?: number;
  61127. height?: number;
  61128. depth?: number;
  61129. tileSize?: number;
  61130. tileWidth?: number;
  61131. tileHeight?: number;
  61132. alignHorizontal?: number;
  61133. alignVertical?: number;
  61134. faceUV?: Vector4[];
  61135. faceColors?: Color4[];
  61136. sideOrientation?: number;
  61137. updatable?: boolean;
  61138. }, scene?: Nullable<Scene>): Mesh;
  61139. }
  61140. }
  61141. declare module BABYLON {
  61142. /**
  61143. * Class containing static functions to help procedurally build meshes
  61144. */
  61145. export class TorusKnotBuilder {
  61146. /**
  61147. * Creates a torus knot mesh
  61148. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61149. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61150. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61151. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61153. * * 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
  61154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61155. * @param name defines the name of the mesh
  61156. * @param options defines the options used to create the mesh
  61157. * @param scene defines the hosting scene
  61158. * @returns the torus knot mesh
  61159. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61160. */
  61161. static CreateTorusKnot(name: string, options: {
  61162. radius?: number;
  61163. tube?: number;
  61164. radialSegments?: number;
  61165. tubularSegments?: number;
  61166. p?: number;
  61167. q?: number;
  61168. updatable?: boolean;
  61169. sideOrientation?: number;
  61170. frontUVs?: Vector4;
  61171. backUVs?: Vector4;
  61172. }, scene: any): Mesh;
  61173. }
  61174. }
  61175. declare module BABYLON {
  61176. /**
  61177. * Polygon
  61178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61179. */
  61180. export class Polygon {
  61181. /**
  61182. * Creates a rectangle
  61183. * @param xmin bottom X coord
  61184. * @param ymin bottom Y coord
  61185. * @param xmax top X coord
  61186. * @param ymax top Y coord
  61187. * @returns points that make the resulting rectation
  61188. */
  61189. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61190. /**
  61191. * Creates a circle
  61192. * @param radius radius of circle
  61193. * @param cx scale in x
  61194. * @param cy scale in y
  61195. * @param numberOfSides number of sides that make up the circle
  61196. * @returns points that make the resulting circle
  61197. */
  61198. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61199. /**
  61200. * Creates a polygon from input string
  61201. * @param input Input polygon data
  61202. * @returns the parsed points
  61203. */
  61204. static Parse(input: string): Vector2[];
  61205. /**
  61206. * Starts building a polygon from x and y coordinates
  61207. * @param x x coordinate
  61208. * @param y y coordinate
  61209. * @returns the started path2
  61210. */
  61211. static StartingAt(x: number, y: number): Path2;
  61212. }
  61213. /**
  61214. * Builds a polygon
  61215. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61216. */
  61217. export class PolygonMeshBuilder {
  61218. private _points;
  61219. private _outlinepoints;
  61220. private _holes;
  61221. private _name;
  61222. private _scene;
  61223. private _epoints;
  61224. private _eholes;
  61225. private _addToepoint;
  61226. /**
  61227. * Babylon reference to the earcut plugin.
  61228. */
  61229. bjsEarcut: any;
  61230. /**
  61231. * Creates a PolygonMeshBuilder
  61232. * @param name name of the builder
  61233. * @param contours Path of the polygon
  61234. * @param scene scene to add to when creating the mesh
  61235. * @param earcutInjection can be used to inject your own earcut reference
  61236. */
  61237. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61238. /**
  61239. * Adds a whole within the polygon
  61240. * @param hole Array of points defining the hole
  61241. * @returns this
  61242. */
  61243. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61244. /**
  61245. * Creates the polygon
  61246. * @param updatable If the mesh should be updatable
  61247. * @param depth The depth of the mesh created
  61248. * @returns the created mesh
  61249. */
  61250. build(updatable?: boolean, depth?: number): Mesh;
  61251. /**
  61252. * Creates the polygon
  61253. * @param depth The depth of the mesh created
  61254. * @returns the created VertexData
  61255. */
  61256. buildVertexData(depth?: number): VertexData;
  61257. /**
  61258. * Adds a side to the polygon
  61259. * @param positions points that make the polygon
  61260. * @param normals normals of the polygon
  61261. * @param uvs uvs of the polygon
  61262. * @param indices indices of the polygon
  61263. * @param bounds bounds of the polygon
  61264. * @param points points of the polygon
  61265. * @param depth depth of the polygon
  61266. * @param flip flip of the polygon
  61267. */
  61268. private addSide;
  61269. }
  61270. }
  61271. declare module BABYLON {
  61272. /**
  61273. * Class containing static functions to help procedurally build meshes
  61274. */
  61275. export class PolygonBuilder {
  61276. /**
  61277. * Creates a polygon mesh
  61278. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61279. * * 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
  61280. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61282. * * 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)
  61283. * * Remember you can only change the shape positions, not their number when updating a polygon
  61284. * @param name defines the name of the mesh
  61285. * @param options defines the options used to create the mesh
  61286. * @param scene defines the hosting scene
  61287. * @param earcutInjection can be used to inject your own earcut reference
  61288. * @returns the polygon mesh
  61289. */
  61290. static CreatePolygon(name: string, options: {
  61291. shape: Vector3[];
  61292. holes?: Vector3[][];
  61293. depth?: number;
  61294. faceUV?: Vector4[];
  61295. faceColors?: Color4[];
  61296. updatable?: boolean;
  61297. sideOrientation?: number;
  61298. frontUVs?: Vector4;
  61299. backUVs?: Vector4;
  61300. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61301. /**
  61302. * Creates an extruded polygon mesh, with depth in the Y direction.
  61303. * * 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)
  61304. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61305. * @param name defines the name of the mesh
  61306. * @param options defines the options used to create the mesh
  61307. * @param scene defines the hosting scene
  61308. * @param earcutInjection can be used to inject your own earcut reference
  61309. * @returns the polygon mesh
  61310. */
  61311. static ExtrudePolygon(name: string, options: {
  61312. shape: Vector3[];
  61313. holes?: Vector3[][];
  61314. depth?: number;
  61315. faceUV?: Vector4[];
  61316. faceColors?: Color4[];
  61317. updatable?: boolean;
  61318. sideOrientation?: number;
  61319. frontUVs?: Vector4;
  61320. backUVs?: Vector4;
  61321. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61322. }
  61323. }
  61324. declare module BABYLON {
  61325. /**
  61326. * Class containing static functions to help procedurally build meshes
  61327. */
  61328. export class LatheBuilder {
  61329. /**
  61330. * Creates lathe mesh.
  61331. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61332. * * 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
  61333. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61334. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61335. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61336. * * 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
  61337. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61338. * * 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
  61339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61340. * * 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
  61341. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61343. * @param name defines the name of the mesh
  61344. * @param options defines the options used to create the mesh
  61345. * @param scene defines the hosting scene
  61346. * @returns the lathe mesh
  61347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61348. */
  61349. static CreateLathe(name: string, options: {
  61350. shape: Vector3[];
  61351. radius?: number;
  61352. tessellation?: number;
  61353. clip?: number;
  61354. arc?: number;
  61355. closed?: boolean;
  61356. updatable?: boolean;
  61357. sideOrientation?: number;
  61358. frontUVs?: Vector4;
  61359. backUVs?: Vector4;
  61360. cap?: number;
  61361. invertUV?: boolean;
  61362. }, scene?: Nullable<Scene>): Mesh;
  61363. }
  61364. }
  61365. declare module BABYLON {
  61366. /**
  61367. * Class containing static functions to help procedurally build meshes
  61368. */
  61369. export class TiledPlaneBuilder {
  61370. /**
  61371. * Creates a tiled plane mesh
  61372. * * The parameter `pattern` will, depending on value, do nothing or
  61373. * * * flip (reflect about central vertical) alternate tiles across and up
  61374. * * * flip every tile on alternate rows
  61375. * * * rotate (180 degs) alternate tiles across and up
  61376. * * * rotate every tile on alternate rows
  61377. * * * flip and rotate alternate tiles across and up
  61378. * * * flip and rotate every tile on alternate rows
  61379. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61380. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61381. * * 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
  61382. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61383. * * 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)
  61384. * * 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)
  61385. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61386. * @param name defines the name of the mesh
  61387. * @param options defines the options used to create the mesh
  61388. * @param scene defines the hosting scene
  61389. * @returns the box mesh
  61390. */
  61391. static CreateTiledPlane(name: string, options: {
  61392. pattern?: number;
  61393. tileSize?: number;
  61394. tileWidth?: number;
  61395. tileHeight?: number;
  61396. size?: number;
  61397. width?: number;
  61398. height?: number;
  61399. alignHorizontal?: number;
  61400. alignVertical?: number;
  61401. sideOrientation?: number;
  61402. frontUVs?: Vector4;
  61403. backUVs?: Vector4;
  61404. updatable?: boolean;
  61405. }, scene?: Nullable<Scene>): Mesh;
  61406. }
  61407. }
  61408. declare module BABYLON {
  61409. /**
  61410. * Class containing static functions to help procedurally build meshes
  61411. */
  61412. export class TubeBuilder {
  61413. /**
  61414. * Creates a tube mesh.
  61415. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61416. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61417. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61418. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61419. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61420. * * 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)
  61421. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61422. * * 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
  61423. * * 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
  61424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61425. * * 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
  61426. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61428. * @param name defines the name of the mesh
  61429. * @param options defines the options used to create the mesh
  61430. * @param scene defines the hosting scene
  61431. * @returns the tube mesh
  61432. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61433. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61434. */
  61435. static CreateTube(name: string, options: {
  61436. path: Vector3[];
  61437. radius?: number;
  61438. tessellation?: number;
  61439. radiusFunction?: {
  61440. (i: number, distance: number): number;
  61441. };
  61442. cap?: number;
  61443. arc?: number;
  61444. updatable?: boolean;
  61445. sideOrientation?: number;
  61446. frontUVs?: Vector4;
  61447. backUVs?: Vector4;
  61448. instance?: Mesh;
  61449. invertUV?: boolean;
  61450. }, scene?: Nullable<Scene>): Mesh;
  61451. }
  61452. }
  61453. declare module BABYLON {
  61454. /**
  61455. * Class containing static functions to help procedurally build meshes
  61456. */
  61457. export class IcoSphereBuilder {
  61458. /**
  61459. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61460. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61461. * * 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`)
  61462. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61463. * * 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
  61464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61465. * * 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
  61466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61467. * @param name defines the name of the mesh
  61468. * @param options defines the options used to create the mesh
  61469. * @param scene defines the hosting scene
  61470. * @returns the icosahedron mesh
  61471. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61472. */
  61473. static CreateIcoSphere(name: string, options: {
  61474. radius?: number;
  61475. radiusX?: number;
  61476. radiusY?: number;
  61477. radiusZ?: number;
  61478. flat?: boolean;
  61479. subdivisions?: number;
  61480. sideOrientation?: number;
  61481. frontUVs?: Vector4;
  61482. backUVs?: Vector4;
  61483. updatable?: boolean;
  61484. }, scene?: Nullable<Scene>): Mesh;
  61485. }
  61486. }
  61487. declare module BABYLON {
  61488. /**
  61489. * Class containing static functions to help procedurally build meshes
  61490. */
  61491. export class DecalBuilder {
  61492. /**
  61493. * Creates a decal mesh.
  61494. * 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
  61495. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61496. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61497. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61498. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61499. * @param name defines the name of the mesh
  61500. * @param sourceMesh defines the mesh where the decal must be applied
  61501. * @param options defines the options used to create the mesh
  61502. * @param scene defines the hosting scene
  61503. * @returns the decal mesh
  61504. * @see https://doc.babylonjs.com/how_to/decals
  61505. */
  61506. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61507. position?: Vector3;
  61508. normal?: Vector3;
  61509. size?: Vector3;
  61510. angle?: number;
  61511. }): Mesh;
  61512. }
  61513. }
  61514. declare module BABYLON {
  61515. /**
  61516. * Class containing static functions to help procedurally build meshes
  61517. */
  61518. export class MeshBuilder {
  61519. /**
  61520. * Creates a box mesh
  61521. * * The parameter `size` sets the size (float) of each box side (default 1)
  61522. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61523. * * 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)
  61524. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61526. * * 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
  61527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61528. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61529. * @param name defines the name of the mesh
  61530. * @param options defines the options used to create the mesh
  61531. * @param scene defines the hosting scene
  61532. * @returns the box mesh
  61533. */
  61534. static CreateBox(name: string, options: {
  61535. size?: number;
  61536. width?: number;
  61537. height?: number;
  61538. depth?: number;
  61539. faceUV?: Vector4[];
  61540. faceColors?: Color4[];
  61541. sideOrientation?: number;
  61542. frontUVs?: Vector4;
  61543. backUVs?: Vector4;
  61544. wrap?: boolean;
  61545. topBaseAt?: number;
  61546. bottomBaseAt?: number;
  61547. updatable?: boolean;
  61548. }, scene?: Nullable<Scene>): Mesh;
  61549. /**
  61550. * Creates a tiled box mesh
  61551. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61553. * @param name defines the name of the mesh
  61554. * @param options defines the options used to create the mesh
  61555. * @param scene defines the hosting scene
  61556. * @returns the tiled box mesh
  61557. */
  61558. static CreateTiledBox(name: string, options: {
  61559. pattern?: number;
  61560. size?: number;
  61561. width?: number;
  61562. height?: number;
  61563. depth: number;
  61564. tileSize?: number;
  61565. tileWidth?: number;
  61566. tileHeight?: number;
  61567. faceUV?: Vector4[];
  61568. faceColors?: Color4[];
  61569. alignHorizontal?: number;
  61570. alignVertical?: number;
  61571. sideOrientation?: number;
  61572. updatable?: boolean;
  61573. }, scene?: Nullable<Scene>): Mesh;
  61574. /**
  61575. * Creates a sphere mesh
  61576. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61577. * * 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`)
  61578. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61579. * * 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
  61580. * * 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)
  61581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61582. * * 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
  61583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61584. * @param name defines the name of the mesh
  61585. * @param options defines the options used to create the mesh
  61586. * @param scene defines the hosting scene
  61587. * @returns the sphere mesh
  61588. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61589. */
  61590. static CreateSphere(name: string, options: {
  61591. segments?: number;
  61592. diameter?: number;
  61593. diameterX?: number;
  61594. diameterY?: number;
  61595. diameterZ?: number;
  61596. arc?: number;
  61597. slice?: number;
  61598. sideOrientation?: number;
  61599. frontUVs?: Vector4;
  61600. backUVs?: Vector4;
  61601. updatable?: boolean;
  61602. }, scene?: Nullable<Scene>): Mesh;
  61603. /**
  61604. * Creates a plane polygonal mesh. By default, this is a disc
  61605. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61606. * * 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
  61607. * * 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
  61608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61609. * * 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
  61610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61611. * @param name defines the name of the mesh
  61612. * @param options defines the options used to create the mesh
  61613. * @param scene defines the hosting scene
  61614. * @returns the plane polygonal mesh
  61615. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61616. */
  61617. static CreateDisc(name: string, options: {
  61618. radius?: number;
  61619. tessellation?: number;
  61620. arc?: number;
  61621. updatable?: boolean;
  61622. sideOrientation?: number;
  61623. frontUVs?: Vector4;
  61624. backUVs?: Vector4;
  61625. }, scene?: Nullable<Scene>): Mesh;
  61626. /**
  61627. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61628. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61629. * * 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`)
  61630. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61631. * * 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
  61632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61633. * * 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
  61634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61635. * @param name defines the name of the mesh
  61636. * @param options defines the options used to create the mesh
  61637. * @param scene defines the hosting scene
  61638. * @returns the icosahedron mesh
  61639. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61640. */
  61641. static CreateIcoSphere(name: string, options: {
  61642. radius?: number;
  61643. radiusX?: number;
  61644. radiusY?: number;
  61645. radiusZ?: number;
  61646. flat?: boolean;
  61647. subdivisions?: number;
  61648. sideOrientation?: number;
  61649. frontUVs?: Vector4;
  61650. backUVs?: Vector4;
  61651. updatable?: boolean;
  61652. }, scene?: Nullable<Scene>): Mesh;
  61653. /**
  61654. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61655. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61656. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61657. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61658. * * 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
  61659. * * 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
  61660. * * 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
  61661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61662. * * 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
  61663. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61664. * * 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
  61665. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61666. * * 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
  61667. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61669. * @param name defines the name of the mesh
  61670. * @param options defines the options used to create the mesh
  61671. * @param scene defines the hosting scene
  61672. * @returns the ribbon mesh
  61673. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61674. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61675. */
  61676. static CreateRibbon(name: string, options: {
  61677. pathArray: Vector3[][];
  61678. closeArray?: boolean;
  61679. closePath?: boolean;
  61680. offset?: number;
  61681. updatable?: boolean;
  61682. sideOrientation?: number;
  61683. frontUVs?: Vector4;
  61684. backUVs?: Vector4;
  61685. instance?: Mesh;
  61686. invertUV?: boolean;
  61687. uvs?: Vector2[];
  61688. colors?: Color4[];
  61689. }, scene?: Nullable<Scene>): Mesh;
  61690. /**
  61691. * Creates a cylinder or a cone mesh
  61692. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61693. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61694. * * 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.
  61695. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61696. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61697. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61698. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61699. * * 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).
  61700. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61701. * * 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).
  61702. * * 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
  61703. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61704. * * 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
  61705. * * 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.
  61706. * * If `enclose` is false, a ring surface is one element.
  61707. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61708. * * 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
  61709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61710. * * 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
  61711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61712. * @param name defines the name of the mesh
  61713. * @param options defines the options used to create the mesh
  61714. * @param scene defines the hosting scene
  61715. * @returns the cylinder mesh
  61716. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61717. */
  61718. static CreateCylinder(name: string, options: {
  61719. height?: number;
  61720. diameterTop?: number;
  61721. diameterBottom?: number;
  61722. diameter?: number;
  61723. tessellation?: number;
  61724. subdivisions?: number;
  61725. arc?: number;
  61726. faceColors?: Color4[];
  61727. faceUV?: Vector4[];
  61728. updatable?: boolean;
  61729. hasRings?: boolean;
  61730. enclose?: boolean;
  61731. cap?: number;
  61732. sideOrientation?: number;
  61733. frontUVs?: Vector4;
  61734. backUVs?: Vector4;
  61735. }, scene?: Nullable<Scene>): Mesh;
  61736. /**
  61737. * Creates a torus mesh
  61738. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61739. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61740. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61742. * * 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
  61743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61744. * @param name defines the name of the mesh
  61745. * @param options defines the options used to create the mesh
  61746. * @param scene defines the hosting scene
  61747. * @returns the torus mesh
  61748. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61749. */
  61750. static CreateTorus(name: string, options: {
  61751. diameter?: number;
  61752. thickness?: number;
  61753. tessellation?: number;
  61754. updatable?: boolean;
  61755. sideOrientation?: number;
  61756. frontUVs?: Vector4;
  61757. backUVs?: Vector4;
  61758. }, scene?: Nullable<Scene>): Mesh;
  61759. /**
  61760. * Creates a torus knot mesh
  61761. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61762. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61763. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61764. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61766. * * 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
  61767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61768. * @param name defines the name of the mesh
  61769. * @param options defines the options used to create the mesh
  61770. * @param scene defines the hosting scene
  61771. * @returns the torus knot mesh
  61772. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61773. */
  61774. static CreateTorusKnot(name: string, options: {
  61775. radius?: number;
  61776. tube?: number;
  61777. radialSegments?: number;
  61778. tubularSegments?: number;
  61779. p?: number;
  61780. q?: number;
  61781. updatable?: boolean;
  61782. sideOrientation?: number;
  61783. frontUVs?: Vector4;
  61784. backUVs?: Vector4;
  61785. }, scene?: Nullable<Scene>): Mesh;
  61786. /**
  61787. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61788. * * 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
  61789. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61790. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61791. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61792. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61793. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61794. * * 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
  61795. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61797. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61798. * @param name defines the name of the new line system
  61799. * @param options defines the options used to create the line system
  61800. * @param scene defines the hosting scene
  61801. * @returns a new line system mesh
  61802. */
  61803. static CreateLineSystem(name: string, options: {
  61804. lines: Vector3[][];
  61805. updatable?: boolean;
  61806. instance?: Nullable<LinesMesh>;
  61807. colors?: Nullable<Color4[][]>;
  61808. useVertexAlpha?: boolean;
  61809. }, scene: Nullable<Scene>): LinesMesh;
  61810. /**
  61811. * Creates a line mesh
  61812. * 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
  61813. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61814. * * The parameter `points` is an array successive Vector3
  61815. * * 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
  61816. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61817. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61818. * * When updating an instance, remember that only point positions can change, not the number of points
  61819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61821. * @param name defines the name of the new line system
  61822. * @param options defines the options used to create the line system
  61823. * @param scene defines the hosting scene
  61824. * @returns a new line mesh
  61825. */
  61826. static CreateLines(name: string, options: {
  61827. points: Vector3[];
  61828. updatable?: boolean;
  61829. instance?: Nullable<LinesMesh>;
  61830. colors?: Color4[];
  61831. useVertexAlpha?: boolean;
  61832. }, scene?: Nullable<Scene>): LinesMesh;
  61833. /**
  61834. * Creates a dashed line mesh
  61835. * * 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
  61836. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61837. * * The parameter `points` is an array successive Vector3
  61838. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61839. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61840. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61841. * * 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
  61842. * * When updating an instance, remember that only point positions can change, not the number of points
  61843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61844. * @param name defines the name of the mesh
  61845. * @param options defines the options used to create the mesh
  61846. * @param scene defines the hosting scene
  61847. * @returns the dashed line mesh
  61848. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61849. */
  61850. static CreateDashedLines(name: string, options: {
  61851. points: Vector3[];
  61852. dashSize?: number;
  61853. gapSize?: number;
  61854. dashNb?: number;
  61855. updatable?: boolean;
  61856. instance?: LinesMesh;
  61857. }, scene?: Nullable<Scene>): LinesMesh;
  61858. /**
  61859. * 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.
  61860. * * 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.
  61861. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61862. * * 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.
  61863. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61864. * * 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
  61865. * * 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
  61866. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61868. * * 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
  61869. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61871. * @param name defines the name of the mesh
  61872. * @param options defines the options used to create the mesh
  61873. * @param scene defines the hosting scene
  61874. * @returns the extruded shape mesh
  61875. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61876. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61877. */
  61878. static ExtrudeShape(name: string, options: {
  61879. shape: Vector3[];
  61880. path: Vector3[];
  61881. scale?: number;
  61882. rotation?: number;
  61883. cap?: number;
  61884. updatable?: boolean;
  61885. sideOrientation?: number;
  61886. frontUVs?: Vector4;
  61887. backUVs?: Vector4;
  61888. instance?: Mesh;
  61889. invertUV?: boolean;
  61890. }, scene?: Nullable<Scene>): Mesh;
  61891. /**
  61892. * Creates an custom extruded shape mesh.
  61893. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61894. * * 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.
  61895. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61896. * * 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
  61897. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61898. * * 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
  61899. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61900. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61901. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61902. * * 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
  61903. * * 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
  61904. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61906. * * 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
  61907. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61909. * @param name defines the name of the mesh
  61910. * @param options defines the options used to create the mesh
  61911. * @param scene defines the hosting scene
  61912. * @returns the custom extruded shape mesh
  61913. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61914. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61915. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61916. */
  61917. static ExtrudeShapeCustom(name: string, options: {
  61918. shape: Vector3[];
  61919. path: Vector3[];
  61920. scaleFunction?: any;
  61921. rotationFunction?: any;
  61922. ribbonCloseArray?: boolean;
  61923. ribbonClosePath?: boolean;
  61924. cap?: number;
  61925. updatable?: boolean;
  61926. sideOrientation?: number;
  61927. frontUVs?: Vector4;
  61928. backUVs?: Vector4;
  61929. instance?: Mesh;
  61930. invertUV?: boolean;
  61931. }, scene?: Nullable<Scene>): Mesh;
  61932. /**
  61933. * Creates lathe mesh.
  61934. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61935. * * 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
  61936. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61937. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61938. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61939. * * 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
  61940. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61941. * * 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
  61942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61943. * * 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
  61944. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61946. * @param name defines the name of the mesh
  61947. * @param options defines the options used to create the mesh
  61948. * @param scene defines the hosting scene
  61949. * @returns the lathe mesh
  61950. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61951. */
  61952. static CreateLathe(name: string, options: {
  61953. shape: Vector3[];
  61954. radius?: number;
  61955. tessellation?: number;
  61956. clip?: number;
  61957. arc?: number;
  61958. closed?: boolean;
  61959. updatable?: boolean;
  61960. sideOrientation?: number;
  61961. frontUVs?: Vector4;
  61962. backUVs?: Vector4;
  61963. cap?: number;
  61964. invertUV?: boolean;
  61965. }, scene?: Nullable<Scene>): Mesh;
  61966. /**
  61967. * Creates a tiled plane mesh
  61968. * * You can set a limited pattern arrangement with the tiles
  61969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61970. * * 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
  61971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61972. * @param name defines the name of the mesh
  61973. * @param options defines the options used to create the mesh
  61974. * @param scene defines the hosting scene
  61975. * @returns the plane mesh
  61976. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61977. */
  61978. static CreateTiledPlane(name: string, options: {
  61979. pattern?: number;
  61980. tileSize?: number;
  61981. tileWidth?: number;
  61982. tileHeight?: number;
  61983. size?: number;
  61984. width?: number;
  61985. height?: number;
  61986. alignHorizontal?: number;
  61987. alignVertical?: number;
  61988. sideOrientation?: number;
  61989. frontUVs?: Vector4;
  61990. backUVs?: Vector4;
  61991. updatable?: boolean;
  61992. }, scene?: Nullable<Scene>): Mesh;
  61993. /**
  61994. * Creates a plane mesh
  61995. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61996. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61997. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61999. * * 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
  62000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62001. * @param name defines the name of the mesh
  62002. * @param options defines the options used to create the mesh
  62003. * @param scene defines the hosting scene
  62004. * @returns the plane mesh
  62005. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62006. */
  62007. static CreatePlane(name: string, options: {
  62008. size?: number;
  62009. width?: number;
  62010. height?: number;
  62011. sideOrientation?: number;
  62012. frontUVs?: Vector4;
  62013. backUVs?: Vector4;
  62014. updatable?: boolean;
  62015. sourcePlane?: Plane;
  62016. }, scene?: Nullable<Scene>): Mesh;
  62017. /**
  62018. * Creates a ground mesh
  62019. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62020. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62022. * @param name defines the name of the mesh
  62023. * @param options defines the options used to create the mesh
  62024. * @param scene defines the hosting scene
  62025. * @returns the ground mesh
  62026. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62027. */
  62028. static CreateGround(name: string, options: {
  62029. width?: number;
  62030. height?: number;
  62031. subdivisions?: number;
  62032. subdivisionsX?: number;
  62033. subdivisionsY?: number;
  62034. updatable?: boolean;
  62035. }, scene?: Nullable<Scene>): Mesh;
  62036. /**
  62037. * Creates a tiled ground mesh
  62038. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62039. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62040. * * 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
  62041. * * 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
  62042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62043. * @param name defines the name of the mesh
  62044. * @param options defines the options used to create the mesh
  62045. * @param scene defines the hosting scene
  62046. * @returns the tiled ground mesh
  62047. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62048. */
  62049. static CreateTiledGround(name: string, options: {
  62050. xmin: number;
  62051. zmin: number;
  62052. xmax: number;
  62053. zmax: number;
  62054. subdivisions?: {
  62055. w: number;
  62056. h: number;
  62057. };
  62058. precision?: {
  62059. w: number;
  62060. h: number;
  62061. };
  62062. updatable?: boolean;
  62063. }, scene?: Nullable<Scene>): Mesh;
  62064. /**
  62065. * Creates a ground mesh from a height map
  62066. * * The parameter `url` sets the URL of the height map image resource.
  62067. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62068. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62069. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62070. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62071. * * 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.
  62072. * * 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).
  62073. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62075. * @param name defines the name of the mesh
  62076. * @param url defines the url to the height map
  62077. * @param options defines the options used to create the mesh
  62078. * @param scene defines the hosting scene
  62079. * @returns the ground mesh
  62080. * @see https://doc.babylonjs.com/babylon101/height_map
  62081. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62082. */
  62083. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62084. width?: number;
  62085. height?: number;
  62086. subdivisions?: number;
  62087. minHeight?: number;
  62088. maxHeight?: number;
  62089. colorFilter?: Color3;
  62090. alphaFilter?: number;
  62091. updatable?: boolean;
  62092. onReady?: (mesh: GroundMesh) => void;
  62093. }, scene?: Nullable<Scene>): GroundMesh;
  62094. /**
  62095. * Creates a polygon mesh
  62096. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62097. * * 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
  62098. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62100. * * 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)
  62101. * * Remember you can only change the shape positions, not their number when updating a polygon
  62102. * @param name defines the name of the mesh
  62103. * @param options defines the options used to create the mesh
  62104. * @param scene defines the hosting scene
  62105. * @param earcutInjection can be used to inject your own earcut reference
  62106. * @returns the polygon mesh
  62107. */
  62108. static CreatePolygon(name: string, options: {
  62109. shape: Vector3[];
  62110. holes?: Vector3[][];
  62111. depth?: number;
  62112. faceUV?: Vector4[];
  62113. faceColors?: Color4[];
  62114. updatable?: boolean;
  62115. sideOrientation?: number;
  62116. frontUVs?: Vector4;
  62117. backUVs?: Vector4;
  62118. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62119. /**
  62120. * Creates an extruded polygon mesh, with depth in the Y direction.
  62121. * * 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)
  62122. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62123. * @param name defines the name of the mesh
  62124. * @param options defines the options used to create the mesh
  62125. * @param scene defines the hosting scene
  62126. * @param earcutInjection can be used to inject your own earcut reference
  62127. * @returns the polygon mesh
  62128. */
  62129. static ExtrudePolygon(name: string, options: {
  62130. shape: Vector3[];
  62131. holes?: Vector3[][];
  62132. depth?: number;
  62133. faceUV?: Vector4[];
  62134. faceColors?: Color4[];
  62135. updatable?: boolean;
  62136. sideOrientation?: number;
  62137. frontUVs?: Vector4;
  62138. backUVs?: Vector4;
  62139. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62140. /**
  62141. * Creates a tube mesh.
  62142. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62143. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62144. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62145. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62146. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62147. * * 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)
  62148. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62149. * * 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
  62150. * * 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
  62151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62152. * * 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
  62153. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62155. * @param name defines the name of the mesh
  62156. * @param options defines the options used to create the mesh
  62157. * @param scene defines the hosting scene
  62158. * @returns the tube mesh
  62159. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62160. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62161. */
  62162. static CreateTube(name: string, options: {
  62163. path: Vector3[];
  62164. radius?: number;
  62165. tessellation?: number;
  62166. radiusFunction?: {
  62167. (i: number, distance: number): number;
  62168. };
  62169. cap?: number;
  62170. arc?: number;
  62171. updatable?: boolean;
  62172. sideOrientation?: number;
  62173. frontUVs?: Vector4;
  62174. backUVs?: Vector4;
  62175. instance?: Mesh;
  62176. invertUV?: boolean;
  62177. }, scene?: Nullable<Scene>): Mesh;
  62178. /**
  62179. * Creates a polyhedron mesh
  62180. * * 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
  62181. * * The parameter `size` (positive float, default 1) sets the polygon size
  62182. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62183. * * 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`
  62184. * * 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
  62185. * * 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)`)
  62186. * * 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
  62187. * * 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
  62188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62189. * * 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
  62190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62191. * @param name defines the name of the mesh
  62192. * @param options defines the options used to create the mesh
  62193. * @param scene defines the hosting scene
  62194. * @returns the polyhedron mesh
  62195. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62196. */
  62197. static CreatePolyhedron(name: string, options: {
  62198. type?: number;
  62199. size?: number;
  62200. sizeX?: number;
  62201. sizeY?: number;
  62202. sizeZ?: number;
  62203. custom?: any;
  62204. faceUV?: Vector4[];
  62205. faceColors?: Color4[];
  62206. flat?: boolean;
  62207. updatable?: boolean;
  62208. sideOrientation?: number;
  62209. frontUVs?: Vector4;
  62210. backUVs?: Vector4;
  62211. }, scene?: Nullable<Scene>): Mesh;
  62212. /**
  62213. * Creates a decal mesh.
  62214. * 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
  62215. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62216. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62217. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62218. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62219. * @param name defines the name of the mesh
  62220. * @param sourceMesh defines the mesh where the decal must be applied
  62221. * @param options defines the options used to create the mesh
  62222. * @param scene defines the hosting scene
  62223. * @returns the decal mesh
  62224. * @see https://doc.babylonjs.com/how_to/decals
  62225. */
  62226. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62227. position?: Vector3;
  62228. normal?: Vector3;
  62229. size?: Vector3;
  62230. angle?: number;
  62231. }): Mesh;
  62232. }
  62233. }
  62234. declare module BABYLON {
  62235. /**
  62236. * A simplifier interface for future simplification implementations
  62237. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62238. */
  62239. export interface ISimplifier {
  62240. /**
  62241. * Simplification of a given mesh according to the given settings.
  62242. * Since this requires computation, it is assumed that the function runs async.
  62243. * @param settings The settings of the simplification, including quality and distance
  62244. * @param successCallback A callback that will be called after the mesh was simplified.
  62245. * @param errorCallback in case of an error, this callback will be called. optional.
  62246. */
  62247. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62248. }
  62249. /**
  62250. * Expected simplification settings.
  62251. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62252. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62253. */
  62254. export interface ISimplificationSettings {
  62255. /**
  62256. * Gets or sets the expected quality
  62257. */
  62258. quality: number;
  62259. /**
  62260. * Gets or sets the distance when this optimized version should be used
  62261. */
  62262. distance: number;
  62263. /**
  62264. * Gets an already optimized mesh
  62265. */
  62266. optimizeMesh?: boolean;
  62267. }
  62268. /**
  62269. * Class used to specify simplification options
  62270. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62271. */
  62272. export class SimplificationSettings implements ISimplificationSettings {
  62273. /** expected quality */
  62274. quality: number;
  62275. /** distance when this optimized version should be used */
  62276. distance: number;
  62277. /** already optimized mesh */
  62278. optimizeMesh?: boolean | undefined;
  62279. /**
  62280. * Creates a SimplificationSettings
  62281. * @param quality expected quality
  62282. * @param distance distance when this optimized version should be used
  62283. * @param optimizeMesh already optimized mesh
  62284. */
  62285. constructor(
  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. /**
  62294. * Interface used to define a simplification task
  62295. */
  62296. export interface ISimplificationTask {
  62297. /**
  62298. * Array of settings
  62299. */
  62300. settings: Array<ISimplificationSettings>;
  62301. /**
  62302. * Simplification type
  62303. */
  62304. simplificationType: SimplificationType;
  62305. /**
  62306. * Mesh to simplify
  62307. */
  62308. mesh: Mesh;
  62309. /**
  62310. * Callback called on success
  62311. */
  62312. successCallback?: () => void;
  62313. /**
  62314. * Defines if parallel processing can be used
  62315. */
  62316. parallelProcessing: boolean;
  62317. }
  62318. /**
  62319. * Queue used to order the simplification tasks
  62320. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62321. */
  62322. export class SimplificationQueue {
  62323. private _simplificationArray;
  62324. /**
  62325. * Gets a boolean indicating that the process is still running
  62326. */
  62327. running: boolean;
  62328. /**
  62329. * Creates a new queue
  62330. */
  62331. constructor();
  62332. /**
  62333. * Adds a new simplification task
  62334. * @param task defines a task to add
  62335. */
  62336. addTask(task: ISimplificationTask): void;
  62337. /**
  62338. * Execute next task
  62339. */
  62340. executeNext(): void;
  62341. /**
  62342. * Execute a simplification task
  62343. * @param task defines the task to run
  62344. */
  62345. runSimplification(task: ISimplificationTask): void;
  62346. private getSimplifier;
  62347. }
  62348. /**
  62349. * The implemented types of simplification
  62350. * At the moment only Quadratic Error Decimation is implemented
  62351. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62352. */
  62353. export enum SimplificationType {
  62354. /** Quadratic error decimation */
  62355. QUADRATIC = 0
  62356. }
  62357. /**
  62358. * An implementation of the Quadratic Error simplification algorithm.
  62359. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62360. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62361. * @author RaananW
  62362. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62363. */
  62364. export class QuadraticErrorSimplification implements ISimplifier {
  62365. private _mesh;
  62366. private triangles;
  62367. private vertices;
  62368. private references;
  62369. private _reconstructedMesh;
  62370. /** Gets or sets the number pf sync interations */
  62371. syncIterations: number;
  62372. /** Gets or sets the aggressiveness of the simplifier */
  62373. aggressiveness: number;
  62374. /** Gets or sets the number of allowed iterations for decimation */
  62375. decimationIterations: number;
  62376. /** Gets or sets the espilon to use for bounding box computation */
  62377. boundingBoxEpsilon: number;
  62378. /**
  62379. * Creates a new QuadraticErrorSimplification
  62380. * @param _mesh defines the target mesh
  62381. */
  62382. constructor(_mesh: Mesh);
  62383. /**
  62384. * Simplification of a given mesh according to the given settings.
  62385. * Since this requires computation, it is assumed that the function runs async.
  62386. * @param settings The settings of the simplification, including quality and distance
  62387. * @param successCallback A callback that will be called after the mesh was simplified.
  62388. */
  62389. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62390. private runDecimation;
  62391. private initWithMesh;
  62392. private init;
  62393. private reconstructMesh;
  62394. private initDecimatedMesh;
  62395. private isFlipped;
  62396. private updateTriangles;
  62397. private identifyBorder;
  62398. private updateMesh;
  62399. private vertexError;
  62400. private calculateError;
  62401. }
  62402. }
  62403. declare module BABYLON {
  62404. interface Scene {
  62405. /** @hidden (Backing field) */
  62406. _simplificationQueue: SimplificationQueue;
  62407. /**
  62408. * Gets or sets the simplification queue attached to the scene
  62409. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62410. */
  62411. simplificationQueue: SimplificationQueue;
  62412. }
  62413. interface Mesh {
  62414. /**
  62415. * Simplify the mesh according to the given array of settings.
  62416. * Function will return immediately and will simplify async
  62417. * @param settings a collection of simplification settings
  62418. * @param parallelProcessing should all levels calculate parallel or one after the other
  62419. * @param simplificationType the type of simplification to run
  62420. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62421. * @returns the current mesh
  62422. */
  62423. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62424. }
  62425. /**
  62426. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62427. * created in a scene
  62428. */
  62429. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62430. /**
  62431. * The component name helpfull to identify the component in the list of scene components.
  62432. */
  62433. readonly name: string;
  62434. /**
  62435. * The scene the component belongs to.
  62436. */
  62437. scene: Scene;
  62438. /**
  62439. * Creates a new instance of the component for the given scene
  62440. * @param scene Defines the scene to register the component in
  62441. */
  62442. constructor(scene: Scene);
  62443. /**
  62444. * Registers the component in a given scene
  62445. */
  62446. register(): void;
  62447. /**
  62448. * Rebuilds the elements related to this component in case of
  62449. * context lost for instance.
  62450. */
  62451. rebuild(): void;
  62452. /**
  62453. * Disposes the component and the associated ressources
  62454. */
  62455. dispose(): void;
  62456. private _beforeCameraUpdate;
  62457. }
  62458. }
  62459. declare module BABYLON {
  62460. /**
  62461. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62462. */
  62463. export interface INavigationEnginePlugin {
  62464. /**
  62465. * plugin name
  62466. */
  62467. name: string;
  62468. /**
  62469. * Creates a navigation mesh
  62470. * @param meshes array of all the geometry used to compute the navigatio mesh
  62471. * @param parameters bunch of parameters used to filter geometry
  62472. */
  62473. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62474. /**
  62475. * Create a navigation mesh debug mesh
  62476. * @param scene is where the mesh will be added
  62477. * @returns debug display mesh
  62478. */
  62479. createDebugNavMesh(scene: Scene): Mesh;
  62480. /**
  62481. * Get a navigation mesh constrained position, closest to the parameter position
  62482. * @param position world position
  62483. * @returns the closest point to position constrained by the navigation mesh
  62484. */
  62485. getClosestPoint(position: Vector3): Vector3;
  62486. /**
  62487. * Get a navigation mesh constrained position, closest to the parameter position
  62488. * @param position world position
  62489. * @param result output the closest point to position constrained by the navigation mesh
  62490. */
  62491. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62492. /**
  62493. * Get a navigation mesh constrained position, within a particular radius
  62494. * @param position world position
  62495. * @param maxRadius the maximum distance to the constrained world position
  62496. * @returns the closest point to position constrained by the navigation mesh
  62497. */
  62498. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62499. /**
  62500. * Get a navigation mesh constrained position, within a particular radius
  62501. * @param position world position
  62502. * @param maxRadius the maximum distance to the constrained world position
  62503. * @param result output the closest point to position constrained by the navigation mesh
  62504. */
  62505. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62506. /**
  62507. * Compute the final position from a segment made of destination-position
  62508. * @param position world position
  62509. * @param destination world position
  62510. * @returns the resulting point along the navmesh
  62511. */
  62512. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62513. /**
  62514. * Compute the final position from a segment made of destination-position
  62515. * @param position world position
  62516. * @param destination world position
  62517. * @param result output the resulting point along the navmesh
  62518. */
  62519. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62520. /**
  62521. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62522. * @param start world position
  62523. * @param end world position
  62524. * @returns array containing world position composing the path
  62525. */
  62526. computePath(start: Vector3, end: Vector3): Vector3[];
  62527. /**
  62528. * If this plugin is supported
  62529. * @returns true if plugin is supported
  62530. */
  62531. isSupported(): boolean;
  62532. /**
  62533. * Create a new Crowd so you can add agents
  62534. * @param maxAgents the maximum agent count in the crowd
  62535. * @param maxAgentRadius the maximum radius an agent can have
  62536. * @param scene to attach the crowd to
  62537. * @returns the crowd you can add agents to
  62538. */
  62539. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62540. /**
  62541. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62542. * The queries will try to find a solution within those bounds
  62543. * default is (1,1,1)
  62544. * @param extent x,y,z value that define the extent around the queries point of reference
  62545. */
  62546. setDefaultQueryExtent(extent: Vector3): void;
  62547. /**
  62548. * Get the Bounding box extent specified by setDefaultQueryExtent
  62549. * @returns the box extent values
  62550. */
  62551. getDefaultQueryExtent(): Vector3;
  62552. /**
  62553. * build the navmesh from a previously saved state using getNavmeshData
  62554. * @param data the Uint8Array returned by getNavmeshData
  62555. */
  62556. buildFromNavmeshData(data: Uint8Array): void;
  62557. /**
  62558. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62559. * @returns data the Uint8Array that can be saved and reused
  62560. */
  62561. getNavmeshData(): Uint8Array;
  62562. /**
  62563. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62564. * @param result output the box extent values
  62565. */
  62566. getDefaultQueryExtentToRef(result: Vector3): void;
  62567. /**
  62568. * Release all resources
  62569. */
  62570. dispose(): void;
  62571. }
  62572. /**
  62573. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62574. */
  62575. export interface ICrowd {
  62576. /**
  62577. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62578. * You can attach anything to that node. The node position is updated in the scene update tick.
  62579. * @param pos world position that will be constrained by the navigation mesh
  62580. * @param parameters agent parameters
  62581. * @param transform hooked to the agent that will be update by the scene
  62582. * @returns agent index
  62583. */
  62584. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62585. /**
  62586. * Returns the agent position in world space
  62587. * @param index agent index returned by addAgent
  62588. * @returns world space position
  62589. */
  62590. getAgentPosition(index: number): Vector3;
  62591. /**
  62592. * Gets the agent position result in world space
  62593. * @param index agent index returned by addAgent
  62594. * @param result output world space position
  62595. */
  62596. getAgentPositionToRef(index: number, result: Vector3): void;
  62597. /**
  62598. * Gets the agent velocity in world space
  62599. * @param index agent index returned by addAgent
  62600. * @returns world space velocity
  62601. */
  62602. getAgentVelocity(index: number): Vector3;
  62603. /**
  62604. * Gets the agent velocity result in world space
  62605. * @param index agent index returned by addAgent
  62606. * @param result output world space velocity
  62607. */
  62608. getAgentVelocityToRef(index: number, result: Vector3): void;
  62609. /**
  62610. * remove a particular agent previously created
  62611. * @param index agent index returned by addAgent
  62612. */
  62613. removeAgent(index: number): void;
  62614. /**
  62615. * get the list of all agents attached to this crowd
  62616. * @returns list of agent indices
  62617. */
  62618. getAgents(): number[];
  62619. /**
  62620. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62621. * @param deltaTime in seconds
  62622. */
  62623. update(deltaTime: number): void;
  62624. /**
  62625. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62626. * @param index agent index returned by addAgent
  62627. * @param destination targeted world position
  62628. */
  62629. agentGoto(index: number, destination: Vector3): void;
  62630. /**
  62631. * Teleport the agent to a new position
  62632. * @param index agent index returned by addAgent
  62633. * @param destination targeted world position
  62634. */
  62635. agentTeleport(index: number, destination: Vector3): void;
  62636. /**
  62637. * Update agent parameters
  62638. * @param index agent index returned by addAgent
  62639. * @param parameters agent parameters
  62640. */
  62641. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62642. /**
  62643. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62644. * The queries will try to find a solution within those bounds
  62645. * default is (1,1,1)
  62646. * @param extent x,y,z value that define the extent around the queries point of reference
  62647. */
  62648. setDefaultQueryExtent(extent: Vector3): void;
  62649. /**
  62650. * Get the Bounding box extent specified by setDefaultQueryExtent
  62651. * @returns the box extent values
  62652. */
  62653. getDefaultQueryExtent(): Vector3;
  62654. /**
  62655. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62656. * @param result output the box extent values
  62657. */
  62658. getDefaultQueryExtentToRef(result: Vector3): void;
  62659. /**
  62660. * Release all resources
  62661. */
  62662. dispose(): void;
  62663. }
  62664. /**
  62665. * Configures an agent
  62666. */
  62667. export interface IAgentParameters {
  62668. /**
  62669. * Agent radius. [Limit: >= 0]
  62670. */
  62671. radius: number;
  62672. /**
  62673. * Agent height. [Limit: > 0]
  62674. */
  62675. height: number;
  62676. /**
  62677. * Maximum allowed acceleration. [Limit: >= 0]
  62678. */
  62679. maxAcceleration: number;
  62680. /**
  62681. * Maximum allowed speed. [Limit: >= 0]
  62682. */
  62683. maxSpeed: number;
  62684. /**
  62685. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62686. */
  62687. collisionQueryRange: number;
  62688. /**
  62689. * The path visibility optimization range. [Limit: > 0]
  62690. */
  62691. pathOptimizationRange: number;
  62692. /**
  62693. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62694. */
  62695. separationWeight: number;
  62696. }
  62697. /**
  62698. * Configures the navigation mesh creation
  62699. */
  62700. export interface INavMeshParameters {
  62701. /**
  62702. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62703. */
  62704. cs: number;
  62705. /**
  62706. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62707. */
  62708. ch: number;
  62709. /**
  62710. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62711. */
  62712. walkableSlopeAngle: number;
  62713. /**
  62714. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62715. * be considered walkable. [Limit: >= 3] [Units: vx]
  62716. */
  62717. walkableHeight: number;
  62718. /**
  62719. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62720. */
  62721. walkableClimb: number;
  62722. /**
  62723. * The distance to erode/shrink the walkable area of the heightfield away from
  62724. * obstructions. [Limit: >=0] [Units: vx]
  62725. */
  62726. walkableRadius: number;
  62727. /**
  62728. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62729. */
  62730. maxEdgeLen: number;
  62731. /**
  62732. * The maximum distance a simplfied contour's border edges should deviate
  62733. * the original raw contour. [Limit: >=0] [Units: vx]
  62734. */
  62735. maxSimplificationError: number;
  62736. /**
  62737. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62738. */
  62739. minRegionArea: number;
  62740. /**
  62741. * Any regions with a span count smaller than this value will, if possible,
  62742. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62743. */
  62744. mergeRegionArea: number;
  62745. /**
  62746. * The maximum number of vertices allowed for polygons generated during the
  62747. * contour to polygon conversion process. [Limit: >= 3]
  62748. */
  62749. maxVertsPerPoly: number;
  62750. /**
  62751. * Sets the sampling distance to use when generating the detail mesh.
  62752. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62753. */
  62754. detailSampleDist: number;
  62755. /**
  62756. * The maximum distance the detail mesh surface should deviate from heightfield
  62757. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62758. */
  62759. detailSampleMaxError: number;
  62760. }
  62761. }
  62762. declare module BABYLON {
  62763. /**
  62764. * RecastJS navigation plugin
  62765. */
  62766. export class RecastJSPlugin implements INavigationEnginePlugin {
  62767. /**
  62768. * Reference to the Recast library
  62769. */
  62770. bjsRECAST: any;
  62771. /**
  62772. * plugin name
  62773. */
  62774. name: string;
  62775. /**
  62776. * the first navmesh created. We might extend this to support multiple navmeshes
  62777. */
  62778. navMesh: any;
  62779. /**
  62780. * Initializes the recastJS plugin
  62781. * @param recastInjection can be used to inject your own recast reference
  62782. */
  62783. constructor(recastInjection?: any);
  62784. /**
  62785. * Creates a navigation mesh
  62786. * @param meshes array of all the geometry used to compute the navigatio mesh
  62787. * @param parameters bunch of parameters used to filter geometry
  62788. */
  62789. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62790. /**
  62791. * Create a navigation mesh debug mesh
  62792. * @param scene is where the mesh will be added
  62793. * @returns debug display mesh
  62794. */
  62795. createDebugNavMesh(scene: Scene): Mesh;
  62796. /**
  62797. * Get a navigation mesh constrained position, closest to the parameter position
  62798. * @param position world position
  62799. * @returns the closest point to position constrained by the navigation mesh
  62800. */
  62801. getClosestPoint(position: Vector3): Vector3;
  62802. /**
  62803. * Get a navigation mesh constrained position, closest to the parameter position
  62804. * @param position world position
  62805. * @param result output the closest point to position constrained by the navigation mesh
  62806. */
  62807. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62808. /**
  62809. * Get a navigation mesh constrained position, within a particular radius
  62810. * @param position world position
  62811. * @param maxRadius the maximum distance to the constrained world position
  62812. * @returns the closest point to position constrained by the navigation mesh
  62813. */
  62814. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62815. /**
  62816. * Get a navigation mesh constrained position, within a particular radius
  62817. * @param position world position
  62818. * @param maxRadius the maximum distance to the constrained world position
  62819. * @param result output the closest point to position constrained by the navigation mesh
  62820. */
  62821. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62822. /**
  62823. * Compute the final position from a segment made of destination-position
  62824. * @param position world position
  62825. * @param destination world position
  62826. * @returns the resulting point along the navmesh
  62827. */
  62828. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62829. /**
  62830. * Compute the final position from a segment made of destination-position
  62831. * @param position world position
  62832. * @param destination world position
  62833. * @param result output the resulting point along the navmesh
  62834. */
  62835. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62836. /**
  62837. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62838. * @param start world position
  62839. * @param end world position
  62840. * @returns array containing world position composing the path
  62841. */
  62842. computePath(start: Vector3, end: Vector3): Vector3[];
  62843. /**
  62844. * Create a new Crowd so you can add agents
  62845. * @param maxAgents the maximum agent count in the crowd
  62846. * @param maxAgentRadius the maximum radius an agent can have
  62847. * @param scene to attach the crowd to
  62848. * @returns the crowd you can add agents to
  62849. */
  62850. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62851. /**
  62852. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62853. * The queries will try to find a solution within those bounds
  62854. * default is (1,1,1)
  62855. * @param extent x,y,z value that define the extent around the queries point of reference
  62856. */
  62857. setDefaultQueryExtent(extent: Vector3): void;
  62858. /**
  62859. * Get the Bounding box extent specified by setDefaultQueryExtent
  62860. * @returns the box extent values
  62861. */
  62862. getDefaultQueryExtent(): Vector3;
  62863. /**
  62864. * build the navmesh from a previously saved state using getNavmeshData
  62865. * @param data the Uint8Array returned by getNavmeshData
  62866. */
  62867. buildFromNavmeshData(data: Uint8Array): void;
  62868. /**
  62869. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62870. * @returns data the Uint8Array that can be saved and reused
  62871. */
  62872. getNavmeshData(): Uint8Array;
  62873. /**
  62874. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62875. * @param result output the box extent values
  62876. */
  62877. getDefaultQueryExtentToRef(result: Vector3): void;
  62878. /**
  62879. * Disposes
  62880. */
  62881. dispose(): void;
  62882. /**
  62883. * If this plugin is supported
  62884. * @returns true if plugin is supported
  62885. */
  62886. isSupported(): boolean;
  62887. }
  62888. /**
  62889. * Recast detour crowd implementation
  62890. */
  62891. export class RecastJSCrowd implements ICrowd {
  62892. /**
  62893. * Recast/detour plugin
  62894. */
  62895. bjsRECASTPlugin: RecastJSPlugin;
  62896. /**
  62897. * Link to the detour crowd
  62898. */
  62899. recastCrowd: any;
  62900. /**
  62901. * One transform per agent
  62902. */
  62903. transforms: TransformNode[];
  62904. /**
  62905. * All agents created
  62906. */
  62907. agents: number[];
  62908. /**
  62909. * Link to the scene is kept to unregister the crowd from the scene
  62910. */
  62911. private _scene;
  62912. /**
  62913. * Observer for crowd updates
  62914. */
  62915. private _onBeforeAnimationsObserver;
  62916. /**
  62917. * Constructor
  62918. * @param plugin recastJS plugin
  62919. * @param maxAgents the maximum agent count in the crowd
  62920. * @param maxAgentRadius the maximum radius an agent can have
  62921. * @param scene to attach the crowd to
  62922. * @returns the crowd you can add agents to
  62923. */
  62924. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62925. /**
  62926. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62927. * You can attach anything to that node. The node position is updated in the scene update tick.
  62928. * @param pos world position that will be constrained by the navigation mesh
  62929. * @param parameters agent parameters
  62930. * @param transform hooked to the agent that will be update by the scene
  62931. * @returns agent index
  62932. */
  62933. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62934. /**
  62935. * Returns the agent position in world space
  62936. * @param index agent index returned by addAgent
  62937. * @returns world space position
  62938. */
  62939. getAgentPosition(index: number): Vector3;
  62940. /**
  62941. * Returns the agent position result in world space
  62942. * @param index agent index returned by addAgent
  62943. * @param result output world space position
  62944. */
  62945. getAgentPositionToRef(index: number, result: Vector3): void;
  62946. /**
  62947. * Returns the agent velocity in world space
  62948. * @param index agent index returned by addAgent
  62949. * @returns world space velocity
  62950. */
  62951. getAgentVelocity(index: number): Vector3;
  62952. /**
  62953. * Returns the agent velocity result in world space
  62954. * @param index agent index returned by addAgent
  62955. * @param result output world space velocity
  62956. */
  62957. getAgentVelocityToRef(index: number, result: Vector3): void;
  62958. /**
  62959. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62960. * @param index agent index returned by addAgent
  62961. * @param destination targeted world position
  62962. */
  62963. agentGoto(index: number, destination: Vector3): void;
  62964. /**
  62965. * Teleport the agent to a new position
  62966. * @param index agent index returned by addAgent
  62967. * @param destination targeted world position
  62968. */
  62969. agentTeleport(index: number, destination: Vector3): void;
  62970. /**
  62971. * Update agent parameters
  62972. * @param index agent index returned by addAgent
  62973. * @param parameters agent parameters
  62974. */
  62975. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62976. /**
  62977. * remove a particular agent previously created
  62978. * @param index agent index returned by addAgent
  62979. */
  62980. removeAgent(index: number): void;
  62981. /**
  62982. * get the list of all agents attached to this crowd
  62983. * @returns list of agent indices
  62984. */
  62985. getAgents(): number[];
  62986. /**
  62987. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62988. * @param deltaTime in seconds
  62989. */
  62990. update(deltaTime: number): void;
  62991. /**
  62992. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62993. * The queries will try to find a solution within those bounds
  62994. * default is (1,1,1)
  62995. * @param extent x,y,z value that define the extent around the queries point of reference
  62996. */
  62997. setDefaultQueryExtent(extent: Vector3): void;
  62998. /**
  62999. * Get the Bounding box extent specified by setDefaultQueryExtent
  63000. * @returns the box extent values
  63001. */
  63002. getDefaultQueryExtent(): Vector3;
  63003. /**
  63004. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63005. * @param result output the box extent values
  63006. */
  63007. getDefaultQueryExtentToRef(result: Vector3): void;
  63008. /**
  63009. * Release all resources
  63010. */
  63011. dispose(): void;
  63012. }
  63013. }
  63014. declare module BABYLON {
  63015. /**
  63016. * Class used to enable access to IndexedDB
  63017. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63018. */
  63019. export class Database implements IOfflineProvider {
  63020. private _callbackManifestChecked;
  63021. private _currentSceneUrl;
  63022. private _db;
  63023. private _enableSceneOffline;
  63024. private _enableTexturesOffline;
  63025. private _manifestVersionFound;
  63026. private _mustUpdateRessources;
  63027. private _hasReachedQuota;
  63028. private _isSupported;
  63029. private _idbFactory;
  63030. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63031. private static IsUASupportingBlobStorage;
  63032. /**
  63033. * Gets a boolean indicating if Database storate is enabled (off by default)
  63034. */
  63035. static IDBStorageEnabled: boolean;
  63036. /**
  63037. * Gets a boolean indicating if scene must be saved in the database
  63038. */
  63039. get enableSceneOffline(): boolean;
  63040. /**
  63041. * Gets a boolean indicating if textures must be saved in the database
  63042. */
  63043. get enableTexturesOffline(): boolean;
  63044. /**
  63045. * Creates a new Database
  63046. * @param urlToScene defines the url to load the scene
  63047. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63048. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63049. */
  63050. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63051. private static _ParseURL;
  63052. private static _ReturnFullUrlLocation;
  63053. private _checkManifestFile;
  63054. /**
  63055. * Open the database and make it available
  63056. * @param successCallback defines the callback to call on success
  63057. * @param errorCallback defines the callback to call on error
  63058. */
  63059. open(successCallback: () => void, errorCallback: () => void): void;
  63060. /**
  63061. * Loads an image from the database
  63062. * @param url defines the url to load from
  63063. * @param image defines the target DOM image
  63064. */
  63065. loadImage(url: string, image: HTMLImageElement): void;
  63066. private _loadImageFromDBAsync;
  63067. private _saveImageIntoDBAsync;
  63068. private _checkVersionFromDB;
  63069. private _loadVersionFromDBAsync;
  63070. private _saveVersionIntoDBAsync;
  63071. /**
  63072. * Loads a file from database
  63073. * @param url defines the URL to load from
  63074. * @param sceneLoaded defines a callback to call on success
  63075. * @param progressCallBack defines a callback to call when progress changed
  63076. * @param errorCallback defines a callback to call on error
  63077. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63078. */
  63079. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63080. private _loadFileAsync;
  63081. private _saveFileAsync;
  63082. /**
  63083. * Validates if xhr data is correct
  63084. * @param xhr defines the request to validate
  63085. * @param dataType defines the expected data type
  63086. * @returns true if data is correct
  63087. */
  63088. private static _ValidateXHRData;
  63089. }
  63090. }
  63091. declare module BABYLON {
  63092. /** @hidden */
  63093. export var gpuUpdateParticlesPixelShader: {
  63094. name: string;
  63095. shader: string;
  63096. };
  63097. }
  63098. declare module BABYLON {
  63099. /** @hidden */
  63100. export var gpuUpdateParticlesVertexShader: {
  63101. name: string;
  63102. shader: string;
  63103. };
  63104. }
  63105. declare module BABYLON {
  63106. /** @hidden */
  63107. export var clipPlaneFragmentDeclaration2: {
  63108. name: string;
  63109. shader: string;
  63110. };
  63111. }
  63112. declare module BABYLON {
  63113. /** @hidden */
  63114. export var gpuRenderParticlesPixelShader: {
  63115. name: string;
  63116. shader: string;
  63117. };
  63118. }
  63119. declare module BABYLON {
  63120. /** @hidden */
  63121. export var clipPlaneVertexDeclaration2: {
  63122. name: string;
  63123. shader: string;
  63124. };
  63125. }
  63126. declare module BABYLON {
  63127. /** @hidden */
  63128. export var gpuRenderParticlesVertexShader: {
  63129. name: string;
  63130. shader: string;
  63131. };
  63132. }
  63133. declare module BABYLON {
  63134. /**
  63135. * This represents a GPU particle system in Babylon
  63136. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63137. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63138. */
  63139. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63140. /**
  63141. * The layer mask we are rendering the particles through.
  63142. */
  63143. layerMask: number;
  63144. private _capacity;
  63145. private _activeCount;
  63146. private _currentActiveCount;
  63147. private _accumulatedCount;
  63148. private _renderEffect;
  63149. private _updateEffect;
  63150. private _buffer0;
  63151. private _buffer1;
  63152. private _spriteBuffer;
  63153. private _updateVAO;
  63154. private _renderVAO;
  63155. private _targetIndex;
  63156. private _sourceBuffer;
  63157. private _targetBuffer;
  63158. private _engine;
  63159. private _currentRenderId;
  63160. private _started;
  63161. private _stopped;
  63162. private _timeDelta;
  63163. private _randomTexture;
  63164. private _randomTexture2;
  63165. private _attributesStrideSize;
  63166. private _updateEffectOptions;
  63167. private _randomTextureSize;
  63168. private _actualFrame;
  63169. private readonly _rawTextureWidth;
  63170. /**
  63171. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63172. */
  63173. static get IsSupported(): boolean;
  63174. /**
  63175. * An event triggered when the system is disposed.
  63176. */
  63177. onDisposeObservable: Observable<GPUParticleSystem>;
  63178. /**
  63179. * Gets the maximum number of particles active at the same time.
  63180. * @returns The max number of active particles.
  63181. */
  63182. getCapacity(): number;
  63183. /**
  63184. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63185. * to override the particles.
  63186. */
  63187. forceDepthWrite: boolean;
  63188. /**
  63189. * Gets or set the number of active particles
  63190. */
  63191. get activeParticleCount(): number;
  63192. set activeParticleCount(value: number);
  63193. private _preWarmDone;
  63194. /**
  63195. * Specifies if the particles are updated in emitter local space or world space.
  63196. * This is always false for GPU particles
  63197. */
  63198. get isLocal(): boolean;
  63199. set isLocal(value: boolean);
  63200. /**
  63201. * Is this system ready to be used/rendered
  63202. * @return true if the system is ready
  63203. */
  63204. isReady(): boolean;
  63205. /**
  63206. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63207. * @returns True if it has been started, otherwise false.
  63208. */
  63209. isStarted(): boolean;
  63210. /**
  63211. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63212. * @returns True if it has been stopped, otherwise false.
  63213. */
  63214. isStopped(): boolean;
  63215. /**
  63216. * Gets a boolean indicating that the system is stopping
  63217. * @returns true if the system is currently stopping
  63218. */
  63219. isStopping(): boolean;
  63220. /**
  63221. * Gets the number of particles active at the same time.
  63222. * @returns The number of active particles.
  63223. */
  63224. getActiveCount(): number;
  63225. /**
  63226. * Starts the particle system and begins to emit
  63227. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63228. */
  63229. start(delay?: number): void;
  63230. /**
  63231. * Stops the particle system.
  63232. */
  63233. stop(): void;
  63234. /**
  63235. * Remove all active particles
  63236. */
  63237. reset(): void;
  63238. /**
  63239. * Returns the string "GPUParticleSystem"
  63240. * @returns a string containing the class name
  63241. */
  63242. getClassName(): string;
  63243. private _colorGradientsTexture;
  63244. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63245. /**
  63246. * Adds a new color gradient
  63247. * @param gradient defines the gradient to use (between 0 and 1)
  63248. * @param color1 defines the color to affect to the specified gradient
  63249. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63250. * @returns the current particle system
  63251. */
  63252. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63253. private _refreshColorGradient;
  63254. /** Force the system to rebuild all gradients that need to be resync */
  63255. forceRefreshGradients(): void;
  63256. /**
  63257. * Remove a specific color gradient
  63258. * @param gradient defines the gradient to remove
  63259. * @returns the current particle system
  63260. */
  63261. removeColorGradient(gradient: number): GPUParticleSystem;
  63262. private _angularSpeedGradientsTexture;
  63263. private _sizeGradientsTexture;
  63264. private _velocityGradientsTexture;
  63265. private _limitVelocityGradientsTexture;
  63266. private _dragGradientsTexture;
  63267. private _addFactorGradient;
  63268. /**
  63269. * Adds a new size gradient
  63270. * @param gradient defines the gradient to use (between 0 and 1)
  63271. * @param factor defines the size factor to affect to the specified gradient
  63272. * @returns the current particle system
  63273. */
  63274. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63275. /**
  63276. * Remove a specific size gradient
  63277. * @param gradient defines the gradient to remove
  63278. * @returns the current particle system
  63279. */
  63280. removeSizeGradient(gradient: number): GPUParticleSystem;
  63281. private _refreshFactorGradient;
  63282. /**
  63283. * Adds a new angular speed gradient
  63284. * @param gradient defines the gradient to use (between 0 and 1)
  63285. * @param factor defines the angular speed to affect to the specified gradient
  63286. * @returns the current particle system
  63287. */
  63288. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63289. /**
  63290. * Remove a specific angular speed gradient
  63291. * @param gradient defines the gradient to remove
  63292. * @returns the current particle system
  63293. */
  63294. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63295. /**
  63296. * Adds a new velocity gradient
  63297. * @param gradient defines the gradient to use (between 0 and 1)
  63298. * @param factor defines the velocity to affect to the specified gradient
  63299. * @returns the current particle system
  63300. */
  63301. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63302. /**
  63303. * Remove a specific velocity gradient
  63304. * @param gradient defines the gradient to remove
  63305. * @returns the current particle system
  63306. */
  63307. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63308. /**
  63309. * Adds a new limit velocity gradient
  63310. * @param gradient defines the gradient to use (between 0 and 1)
  63311. * @param factor defines the limit velocity value to affect to the specified gradient
  63312. * @returns the current particle system
  63313. */
  63314. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63315. /**
  63316. * Remove a specific limit velocity gradient
  63317. * @param gradient defines the gradient to remove
  63318. * @returns the current particle system
  63319. */
  63320. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63321. /**
  63322. * Adds a new drag gradient
  63323. * @param gradient defines the gradient to use (between 0 and 1)
  63324. * @param factor defines the drag value to affect to the specified gradient
  63325. * @returns the current particle system
  63326. */
  63327. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63328. /**
  63329. * Remove a specific drag gradient
  63330. * @param gradient defines the gradient to remove
  63331. * @returns the current particle system
  63332. */
  63333. removeDragGradient(gradient: number): GPUParticleSystem;
  63334. /**
  63335. * Not supported by GPUParticleSystem
  63336. * @param gradient defines the gradient to use (between 0 and 1)
  63337. * @param factor defines the emit rate value to affect to the specified gradient
  63338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63339. * @returns the current particle system
  63340. */
  63341. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63342. /**
  63343. * Not supported by GPUParticleSystem
  63344. * @param gradient defines the gradient to remove
  63345. * @returns the current particle system
  63346. */
  63347. removeEmitRateGradient(gradient: number): IParticleSystem;
  63348. /**
  63349. * Not supported by GPUParticleSystem
  63350. * @param gradient defines the gradient to use (between 0 and 1)
  63351. * @param factor defines the start size value to affect to the specified gradient
  63352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63353. * @returns the current particle system
  63354. */
  63355. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63356. /**
  63357. * Not supported by GPUParticleSystem
  63358. * @param gradient defines the gradient to remove
  63359. * @returns the current particle system
  63360. */
  63361. removeStartSizeGradient(gradient: number): IParticleSystem;
  63362. /**
  63363. * Not supported by GPUParticleSystem
  63364. * @param gradient defines the gradient to use (between 0 and 1)
  63365. * @param min defines the color remap minimal range
  63366. * @param max defines the color remap maximal range
  63367. * @returns the current particle system
  63368. */
  63369. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63370. /**
  63371. * Not supported by GPUParticleSystem
  63372. * @param gradient defines the gradient to remove
  63373. * @returns the current particle system
  63374. */
  63375. removeColorRemapGradient(): IParticleSystem;
  63376. /**
  63377. * Not supported by GPUParticleSystem
  63378. * @param gradient defines the gradient to use (between 0 and 1)
  63379. * @param min defines the alpha remap minimal range
  63380. * @param max defines the alpha remap maximal range
  63381. * @returns the current particle system
  63382. */
  63383. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63384. /**
  63385. * Not supported by GPUParticleSystem
  63386. * @param gradient defines the gradient to remove
  63387. * @returns the current particle system
  63388. */
  63389. removeAlphaRemapGradient(): IParticleSystem;
  63390. /**
  63391. * Not supported by GPUParticleSystem
  63392. * @param gradient defines the gradient to use (between 0 and 1)
  63393. * @param color defines the color to affect to the specified gradient
  63394. * @returns the current particle system
  63395. */
  63396. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63397. /**
  63398. * Not supported by GPUParticleSystem
  63399. * @param gradient defines the gradient to remove
  63400. * @returns the current particle system
  63401. */
  63402. removeRampGradient(): IParticleSystem;
  63403. /**
  63404. * Not supported by GPUParticleSystem
  63405. * @returns the list of ramp gradients
  63406. */
  63407. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63408. /**
  63409. * Not supported by GPUParticleSystem
  63410. * Gets or sets a boolean indicating that ramp gradients must be used
  63411. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63412. */
  63413. get useRampGradients(): boolean;
  63414. set useRampGradients(value: boolean);
  63415. /**
  63416. * Not supported by GPUParticleSystem
  63417. * @param gradient defines the gradient to use (between 0 and 1)
  63418. * @param factor defines the life time factor to affect to the specified gradient
  63419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63420. * @returns the current particle system
  63421. */
  63422. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63423. /**
  63424. * Not supported by GPUParticleSystem
  63425. * @param gradient defines the gradient to remove
  63426. * @returns the current particle system
  63427. */
  63428. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63429. /**
  63430. * Instantiates a GPU particle system.
  63431. * 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.
  63432. * @param name The name of the particle system
  63433. * @param options The options used to create the system
  63434. * @param scene The scene the particle system belongs to
  63435. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63436. */
  63437. constructor(name: string, options: Partial<{
  63438. capacity: number;
  63439. randomTextureSize: number;
  63440. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63441. protected _reset(): void;
  63442. private _createUpdateVAO;
  63443. private _createRenderVAO;
  63444. private _initialize;
  63445. /** @hidden */
  63446. _recreateUpdateEffect(): void;
  63447. /** @hidden */
  63448. _recreateRenderEffect(): void;
  63449. /**
  63450. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63451. * @param preWarm defines if we are in the pre-warmimg phase
  63452. */
  63453. animate(preWarm?: boolean): void;
  63454. private _createFactorGradientTexture;
  63455. private _createSizeGradientTexture;
  63456. private _createAngularSpeedGradientTexture;
  63457. private _createVelocityGradientTexture;
  63458. private _createLimitVelocityGradientTexture;
  63459. private _createDragGradientTexture;
  63460. private _createColorGradientTexture;
  63461. /**
  63462. * Renders the particle system in its current state
  63463. * @param preWarm defines if the system should only update the particles but not render them
  63464. * @returns the current number of particles
  63465. */
  63466. render(preWarm?: boolean): number;
  63467. /**
  63468. * Rebuilds the particle system
  63469. */
  63470. rebuild(): void;
  63471. private _releaseBuffers;
  63472. private _releaseVAOs;
  63473. /**
  63474. * Disposes the particle system and free the associated resources
  63475. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63476. */
  63477. dispose(disposeTexture?: boolean): void;
  63478. /**
  63479. * Clones the particle system.
  63480. * @param name The name of the cloned object
  63481. * @param newEmitter The new emitter to use
  63482. * @returns the cloned particle system
  63483. */
  63484. clone(name: string, newEmitter: any): GPUParticleSystem;
  63485. /**
  63486. * Serializes the particle system to a JSON object
  63487. * @param serializeTexture defines if the texture must be serialized as well
  63488. * @returns the JSON object
  63489. */
  63490. serialize(serializeTexture?: boolean): any;
  63491. /**
  63492. * Parses a JSON object to create a GPU particle system.
  63493. * @param parsedParticleSystem The JSON object to parse
  63494. * @param scene The scene to create the particle system in
  63495. * @param rootUrl The root url to use to load external dependencies like texture
  63496. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63497. * @returns the parsed GPU particle system
  63498. */
  63499. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63500. }
  63501. }
  63502. declare module BABYLON {
  63503. /**
  63504. * Represents a set of particle systems working together to create a specific effect
  63505. */
  63506. export class ParticleSystemSet implements IDisposable {
  63507. /**
  63508. * Gets or sets base Assets URL
  63509. */
  63510. static BaseAssetsUrl: string;
  63511. private _emitterCreationOptions;
  63512. private _emitterNode;
  63513. /**
  63514. * Gets the particle system list
  63515. */
  63516. systems: IParticleSystem[];
  63517. /**
  63518. * Gets the emitter node used with this set
  63519. */
  63520. get emitterNode(): Nullable<TransformNode>;
  63521. /**
  63522. * Creates a new emitter mesh as a sphere
  63523. * @param options defines the options used to create the sphere
  63524. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63525. * @param scene defines the hosting scene
  63526. */
  63527. setEmitterAsSphere(options: {
  63528. diameter: number;
  63529. segments: number;
  63530. color: Color3;
  63531. }, renderingGroupId: number, scene: Scene): void;
  63532. /**
  63533. * Starts all particle systems of the set
  63534. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63535. */
  63536. start(emitter?: AbstractMesh): void;
  63537. /**
  63538. * Release all associated resources
  63539. */
  63540. dispose(): void;
  63541. /**
  63542. * Serialize the set into a JSON compatible object
  63543. * @param serializeTexture defines if the texture must be serialized as well
  63544. * @returns a JSON compatible representation of the set
  63545. */
  63546. serialize(serializeTexture?: boolean): any;
  63547. /**
  63548. * Parse a new ParticleSystemSet from a serialized source
  63549. * @param data defines a JSON compatible representation of the set
  63550. * @param scene defines the hosting scene
  63551. * @param gpu defines if we want GPU particles or CPU particles
  63552. * @returns a new ParticleSystemSet
  63553. */
  63554. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63555. }
  63556. }
  63557. declare module BABYLON {
  63558. /**
  63559. * This class is made for on one-liner static method to help creating particle system set.
  63560. */
  63561. export class ParticleHelper {
  63562. /**
  63563. * Gets or sets base Assets URL
  63564. */
  63565. static BaseAssetsUrl: string;
  63566. /** Define the Url to load snippets */
  63567. static SnippetUrl: string;
  63568. /**
  63569. * Create a default particle system that you can tweak
  63570. * @param emitter defines the emitter to use
  63571. * @param capacity defines the system capacity (default is 500 particles)
  63572. * @param scene defines the hosting scene
  63573. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63574. * @returns the new Particle system
  63575. */
  63576. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63577. /**
  63578. * This is the main static method (one-liner) of this helper to create different particle systems
  63579. * @param type This string represents the type to the particle system to create
  63580. * @param scene The scene where the particle system should live
  63581. * @param gpu If the system will use gpu
  63582. * @returns the ParticleSystemSet created
  63583. */
  63584. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63585. /**
  63586. * Static function used to export a particle system to a ParticleSystemSet variable.
  63587. * Please note that the emitter shape is not exported
  63588. * @param systems defines the particle systems to export
  63589. * @returns the created particle system set
  63590. */
  63591. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63592. /**
  63593. * Creates a particle system from a snippet saved in a remote file
  63594. * @param name defines the name of the particle system to create
  63595. * @param url defines the url to load from
  63596. * @param scene defines the hosting scene
  63597. * @param gpu If the system will use gpu
  63598. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63599. * @returns a promise that will resolve to the new particle system
  63600. */
  63601. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63602. /**
  63603. * Creates a particle system from a snippet saved by the particle system editor
  63604. * @param snippetId defines the snippet to load
  63605. * @param scene defines the hosting scene
  63606. * @param gpu If the system will use gpu
  63607. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63608. * @returns a promise that will resolve to the new particle system
  63609. */
  63610. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63611. }
  63612. }
  63613. declare module BABYLON {
  63614. interface Engine {
  63615. /**
  63616. * Create an effect to use with particle systems.
  63617. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63618. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63619. * @param uniformsNames defines a list of attribute names
  63620. * @param samplers defines an array of string used to represent textures
  63621. * @param defines defines the string containing the defines to use to compile the shaders
  63622. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63623. * @param onCompiled defines a function to call when the effect creation is successful
  63624. * @param onError defines a function to call when the effect creation has failed
  63625. * @returns the new Effect
  63626. */
  63627. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63628. }
  63629. interface Mesh {
  63630. /**
  63631. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63632. * @returns an array of IParticleSystem
  63633. */
  63634. getEmittedParticleSystems(): IParticleSystem[];
  63635. /**
  63636. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63637. * @returns an array of IParticleSystem
  63638. */
  63639. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63640. }
  63641. /**
  63642. * @hidden
  63643. */
  63644. export var _IDoNeedToBeInTheBuild: number;
  63645. }
  63646. declare module BABYLON {
  63647. /** Defines the 4 color options */
  63648. export enum PointColor {
  63649. /** color value */
  63650. Color = 2,
  63651. /** uv value */
  63652. UV = 1,
  63653. /** random value */
  63654. Random = 0,
  63655. /** stated value */
  63656. Stated = 3
  63657. }
  63658. /**
  63659. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63660. * 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.
  63661. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63662. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63663. *
  63664. * Full documentation here : TO BE ENTERED
  63665. */
  63666. export class PointsCloudSystem implements IDisposable {
  63667. /**
  63668. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63669. * Example : var p = SPS.particles[i];
  63670. */
  63671. particles: CloudPoint[];
  63672. /**
  63673. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63674. */
  63675. nbParticles: number;
  63676. /**
  63677. * This a counter for your own usage. It's not set by any SPS functions.
  63678. */
  63679. counter: number;
  63680. /**
  63681. * The PCS name. This name is also given to the underlying mesh.
  63682. */
  63683. name: string;
  63684. /**
  63685. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63686. */
  63687. mesh: Mesh;
  63688. /**
  63689. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63690. * Please read :
  63691. */
  63692. vars: any;
  63693. /**
  63694. * @hidden
  63695. */
  63696. _size: number;
  63697. private _scene;
  63698. private _promises;
  63699. private _positions;
  63700. private _indices;
  63701. private _normals;
  63702. private _colors;
  63703. private _uvs;
  63704. private _indices32;
  63705. private _positions32;
  63706. private _colors32;
  63707. private _uvs32;
  63708. private _updatable;
  63709. private _isVisibilityBoxLocked;
  63710. private _alwaysVisible;
  63711. private _groups;
  63712. private _groupCounter;
  63713. private _computeParticleColor;
  63714. private _computeParticleTexture;
  63715. private _computeParticleRotation;
  63716. private _computeBoundingBox;
  63717. private _isReady;
  63718. /**
  63719. * Creates a PCS (Points Cloud System) object
  63720. * @param name (String) is the PCS name, this will be the underlying mesh name
  63721. * @param pointSize (number) is the size for each point
  63722. * @param scene (Scene) is the scene in which the PCS is added
  63723. * @param options defines the options of the PCS e.g.
  63724. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63725. */
  63726. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63727. updatable?: boolean;
  63728. });
  63729. /**
  63730. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63731. * If no points were added to the PCS, the returned mesh is just a single point.
  63732. * @returns a promise for the created mesh
  63733. */
  63734. buildMeshAsync(): Promise<Mesh>;
  63735. /**
  63736. * @hidden
  63737. */
  63738. private _buildMesh;
  63739. private _addParticle;
  63740. private _randomUnitVector;
  63741. private _getColorIndicesForCoord;
  63742. private _setPointsColorOrUV;
  63743. private _colorFromTexture;
  63744. private _calculateDensity;
  63745. /**
  63746. * Adds points to the PCS in random positions within a unit sphere
  63747. * @param nb (positive integer) the number of particles to be created from this model
  63748. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63749. * @returns the number of groups in the system
  63750. */
  63751. addPoints(nb: number, pointFunction?: any): number;
  63752. /**
  63753. * Adds points to the PCS from the surface of the model shape
  63754. * @param mesh is any Mesh object that will be used as a surface model for the points
  63755. * @param nb (positive integer) the number of particles to be created from this model
  63756. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63757. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63758. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63759. * @returns the number of groups in the system
  63760. */
  63761. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63762. /**
  63763. * Adds points to the PCS inside the model shape
  63764. * @param mesh is any Mesh object that will be used as a surface model for the points
  63765. * @param nb (positive integer) the number of particles to be created from this model
  63766. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63767. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63768. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63769. * @returns the number of groups in the system
  63770. */
  63771. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63772. /**
  63773. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63774. * This method calls `updateParticle()` for each particle of the SPS.
  63775. * For an animated SPS, it is usually called within the render loop.
  63776. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63777. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63778. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63779. * @returns the PCS.
  63780. */
  63781. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63782. /**
  63783. * Disposes the PCS.
  63784. */
  63785. dispose(): void;
  63786. /**
  63787. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63788. * doc :
  63789. * @returns the PCS.
  63790. */
  63791. refreshVisibleSize(): PointsCloudSystem;
  63792. /**
  63793. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63794. * @param size the size (float) of the visibility box
  63795. * note : this doesn't lock the PCS mesh bounding box.
  63796. * doc :
  63797. */
  63798. setVisibilityBox(size: number): void;
  63799. /**
  63800. * Gets whether the PCS is always visible or not
  63801. * doc :
  63802. */
  63803. get isAlwaysVisible(): boolean;
  63804. /**
  63805. * Sets the PCS as always visible or not
  63806. * doc :
  63807. */
  63808. set isAlwaysVisible(val: boolean);
  63809. /**
  63810. * Tells to `setParticles()` to compute the particle rotations or not
  63811. * Default value : false. The PCS is faster when it's set to false
  63812. * Note : particle rotations are only applied to parent particles
  63813. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63814. */
  63815. set computeParticleRotation(val: boolean);
  63816. /**
  63817. * Tells to `setParticles()` to compute the particle colors or not.
  63818. * Default value : true. The PCS is faster when it's set to false.
  63819. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63820. */
  63821. set computeParticleColor(val: boolean);
  63822. set computeParticleTexture(val: boolean);
  63823. /**
  63824. * Gets if `setParticles()` computes the particle colors or not.
  63825. * Default value : false. The PCS is faster when it's set to false.
  63826. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63827. */
  63828. get computeParticleColor(): boolean;
  63829. /**
  63830. * Gets if `setParticles()` computes the particle textures or not.
  63831. * Default value : false. The PCS is faster when it's set to false.
  63832. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63833. */
  63834. get computeParticleTexture(): boolean;
  63835. /**
  63836. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63837. */
  63838. set computeBoundingBox(val: boolean);
  63839. /**
  63840. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63841. */
  63842. get computeBoundingBox(): boolean;
  63843. /**
  63844. * This function does nothing. It may be overwritten to set all the particle first values.
  63845. * The PCS doesn't call this function, you may have to call it by your own.
  63846. * doc :
  63847. */
  63848. initParticles(): void;
  63849. /**
  63850. * This function does nothing. It may be overwritten to recycle a particle
  63851. * The PCS doesn't call this function, you can to call it
  63852. * doc :
  63853. * @param particle The particle to recycle
  63854. * @returns the recycled particle
  63855. */
  63856. recycleParticle(particle: CloudPoint): CloudPoint;
  63857. /**
  63858. * Updates a particle : this function should be overwritten by the user.
  63859. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63860. * doc :
  63861. * @example : just set a particle position or velocity and recycle conditions
  63862. * @param particle The particle to update
  63863. * @returns the updated particle
  63864. */
  63865. updateParticle(particle: CloudPoint): CloudPoint;
  63866. /**
  63867. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63868. * This does nothing and may be overwritten by the user.
  63869. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63870. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63871. * @param update the boolean update value actually passed to setParticles()
  63872. */
  63873. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63874. /**
  63875. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63876. * This will be passed three parameters.
  63877. * This does nothing and may be overwritten by the user.
  63878. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63879. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63880. * @param update the boolean update value actually passed to setParticles()
  63881. */
  63882. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63883. }
  63884. }
  63885. declare module BABYLON {
  63886. /**
  63887. * Represents one particle of a points cloud system.
  63888. */
  63889. export class CloudPoint {
  63890. /**
  63891. * particle global index
  63892. */
  63893. idx: number;
  63894. /**
  63895. * The color of the particle
  63896. */
  63897. color: Nullable<Color4>;
  63898. /**
  63899. * The world space position of the particle.
  63900. */
  63901. position: Vector3;
  63902. /**
  63903. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63904. */
  63905. rotation: Vector3;
  63906. /**
  63907. * The world space rotation quaternion of the particle.
  63908. */
  63909. rotationQuaternion: Nullable<Quaternion>;
  63910. /**
  63911. * The uv of the particle.
  63912. */
  63913. uv: Nullable<Vector2>;
  63914. /**
  63915. * The current speed of the particle.
  63916. */
  63917. velocity: Vector3;
  63918. /**
  63919. * The pivot point in the particle local space.
  63920. */
  63921. pivot: Vector3;
  63922. /**
  63923. * Must the particle be translated from its pivot point in its local space ?
  63924. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63925. * Default : false
  63926. */
  63927. translateFromPivot: boolean;
  63928. /**
  63929. * Index of this particle in the global "positions" array (Internal use)
  63930. * @hidden
  63931. */
  63932. _pos: number;
  63933. /**
  63934. * @hidden Index of this particle in the global "indices" array (Internal use)
  63935. */
  63936. _ind: number;
  63937. /**
  63938. * Group this particle belongs to
  63939. */
  63940. _group: PointsGroup;
  63941. /**
  63942. * Group id of this particle
  63943. */
  63944. groupId: number;
  63945. /**
  63946. * Index of the particle in its group id (Internal use)
  63947. */
  63948. idxInGroup: number;
  63949. /**
  63950. * @hidden Particle BoundingInfo object (Internal use)
  63951. */
  63952. _boundingInfo: BoundingInfo;
  63953. /**
  63954. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63955. */
  63956. _pcs: PointsCloudSystem;
  63957. /**
  63958. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63959. */
  63960. _stillInvisible: boolean;
  63961. /**
  63962. * @hidden Last computed particle rotation matrix
  63963. */
  63964. _rotationMatrix: number[];
  63965. /**
  63966. * Parent particle Id, if any.
  63967. * Default null.
  63968. */
  63969. parentId: Nullable<number>;
  63970. /**
  63971. * @hidden Internal global position in the PCS.
  63972. */
  63973. _globalPosition: Vector3;
  63974. /**
  63975. * Creates a Point Cloud object.
  63976. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63977. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63978. * @param group (PointsGroup) is the group the particle belongs to
  63979. * @param groupId (integer) is the group identifier in the PCS.
  63980. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63981. * @param pcs defines the PCS it is associated to
  63982. */
  63983. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63984. /**
  63985. * get point size
  63986. */
  63987. get size(): Vector3;
  63988. /**
  63989. * Set point size
  63990. */
  63991. set size(scale: Vector3);
  63992. /**
  63993. * Legacy support, changed quaternion to rotationQuaternion
  63994. */
  63995. get quaternion(): Nullable<Quaternion>;
  63996. /**
  63997. * Legacy support, changed quaternion to rotationQuaternion
  63998. */
  63999. set quaternion(q: Nullable<Quaternion>);
  64000. /**
  64001. * Returns a boolean. True if the particle intersects a mesh, else false
  64002. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64003. * @param target is the object (point or mesh) what the intersection is computed against
  64004. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64005. * @returns true if it intersects
  64006. */
  64007. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64008. /**
  64009. * get the rotation matrix of the particle
  64010. * @hidden
  64011. */
  64012. getRotationMatrix(m: Matrix): void;
  64013. }
  64014. /**
  64015. * Represents a group of points in a points cloud system
  64016. * * PCS internal tool, don't use it manually.
  64017. */
  64018. export class PointsGroup {
  64019. /**
  64020. * The group id
  64021. * @hidden
  64022. */
  64023. groupID: number;
  64024. /**
  64025. * image data for group (internal use)
  64026. * @hidden
  64027. */
  64028. _groupImageData: Nullable<ArrayBufferView>;
  64029. /**
  64030. * Image Width (internal use)
  64031. * @hidden
  64032. */
  64033. _groupImgWidth: number;
  64034. /**
  64035. * Image Height (internal use)
  64036. * @hidden
  64037. */
  64038. _groupImgHeight: number;
  64039. /**
  64040. * Custom position function (internal use)
  64041. * @hidden
  64042. */
  64043. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64044. /**
  64045. * density per facet for surface points
  64046. * @hidden
  64047. */
  64048. _groupDensity: number[];
  64049. /**
  64050. * Only when points are colored by texture carries pointer to texture list array
  64051. * @hidden
  64052. */
  64053. _textureNb: number;
  64054. /**
  64055. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64056. * PCS internal tool, don't use it manually.
  64057. * @hidden
  64058. */
  64059. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64060. }
  64061. }
  64062. declare module BABYLON {
  64063. /**
  64064. * Represents a set of particle systems working together to create a specific effect
  64065. */
  64066. export class ParticleSystemDebugger implements IDisposable {
  64067. /**
  64068. * Defines the particle system to debug
  64069. */
  64070. system: IParticleSystem;
  64071. /**
  64072. * Creates a new particle system debugger
  64073. * @param system defines the particle system to debug
  64074. */
  64075. constructor(
  64076. /**
  64077. * Defines the particle system to debug
  64078. */
  64079. system: IParticleSystem);
  64080. /** Clear all the resources */
  64081. dispose(): void;
  64082. }
  64083. }
  64084. declare module BABYLON {
  64085. interface Scene {
  64086. /** @hidden (Backing field) */
  64087. _physicsEngine: Nullable<IPhysicsEngine>;
  64088. /** @hidden */
  64089. _physicsTimeAccumulator: number;
  64090. /**
  64091. * Gets the current physics engine
  64092. * @returns a IPhysicsEngine or null if none attached
  64093. */
  64094. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64095. /**
  64096. * Enables physics to the current scene
  64097. * @param gravity defines the scene's gravity for the physics engine
  64098. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64099. * @return a boolean indicating if the physics engine was initialized
  64100. */
  64101. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64102. /**
  64103. * Disables and disposes the physics engine associated with the scene
  64104. */
  64105. disablePhysicsEngine(): void;
  64106. /**
  64107. * Gets a boolean indicating if there is an active physics engine
  64108. * @returns a boolean indicating if there is an active physics engine
  64109. */
  64110. isPhysicsEnabled(): boolean;
  64111. /**
  64112. * Deletes a physics compound impostor
  64113. * @param compound defines the compound to delete
  64114. */
  64115. deleteCompoundImpostor(compound: any): void;
  64116. /**
  64117. * An event triggered when physic simulation is about to be run
  64118. */
  64119. onBeforePhysicsObservable: Observable<Scene>;
  64120. /**
  64121. * An event triggered when physic simulation has been done
  64122. */
  64123. onAfterPhysicsObservable: Observable<Scene>;
  64124. }
  64125. interface AbstractMesh {
  64126. /** @hidden */
  64127. _physicsImpostor: Nullable<PhysicsImpostor>;
  64128. /**
  64129. * Gets or sets impostor used for physic simulation
  64130. * @see http://doc.babylonjs.com/features/physics_engine
  64131. */
  64132. physicsImpostor: Nullable<PhysicsImpostor>;
  64133. /**
  64134. * Gets the current physics impostor
  64135. * @see http://doc.babylonjs.com/features/physics_engine
  64136. * @returns a physics impostor or null
  64137. */
  64138. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64139. /** Apply a physic impulse to the mesh
  64140. * @param force defines the force to apply
  64141. * @param contactPoint defines where to apply the force
  64142. * @returns the current mesh
  64143. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64144. */
  64145. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64146. /**
  64147. * Creates a physic joint between two meshes
  64148. * @param otherMesh defines the other mesh to use
  64149. * @param pivot1 defines the pivot to use on this mesh
  64150. * @param pivot2 defines the pivot to use on the other mesh
  64151. * @param options defines additional options (can be plugin dependent)
  64152. * @returns the current mesh
  64153. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64154. */
  64155. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64156. /** @hidden */
  64157. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64158. }
  64159. /**
  64160. * Defines the physics engine scene component responsible to manage a physics engine
  64161. */
  64162. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64163. /**
  64164. * The component name helpful to identify the component in the list of scene components.
  64165. */
  64166. readonly name: string;
  64167. /**
  64168. * The scene the component belongs to.
  64169. */
  64170. scene: Scene;
  64171. /**
  64172. * Creates a new instance of the component for the given scene
  64173. * @param scene Defines the scene to register the component in
  64174. */
  64175. constructor(scene: Scene);
  64176. /**
  64177. * Registers the component in a given scene
  64178. */
  64179. register(): void;
  64180. /**
  64181. * Rebuilds the elements related to this component in case of
  64182. * context lost for instance.
  64183. */
  64184. rebuild(): void;
  64185. /**
  64186. * Disposes the component and the associated ressources
  64187. */
  64188. dispose(): void;
  64189. }
  64190. }
  64191. declare module BABYLON {
  64192. /**
  64193. * A helper for physics simulations
  64194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64195. */
  64196. export class PhysicsHelper {
  64197. private _scene;
  64198. private _physicsEngine;
  64199. /**
  64200. * Initializes the Physics helper
  64201. * @param scene Babylon.js scene
  64202. */
  64203. constructor(scene: Scene);
  64204. /**
  64205. * Applies a radial explosion impulse
  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. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64213. /**
  64214. * Applies a radial explosion force
  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 radial explosion event, or null
  64220. */
  64221. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64222. /**
  64223. * Creates a gravitational field
  64224. * @param origin the origin of the explosion
  64225. * @param radiusOrEventOptions the radius or the options of radial explosion
  64226. * @param strength the explosion strength
  64227. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64228. * @returns A physics gravitational field event, or null
  64229. */
  64230. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64231. /**
  64232. * Creates a physics updraft event
  64233. * @param origin the origin of the updraft
  64234. * @param radiusOrEventOptions the radius or the options of the updraft
  64235. * @param strength the strength of the updraft
  64236. * @param height the height of the updraft
  64237. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64238. * @returns A physics updraft event, or null
  64239. */
  64240. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64241. /**
  64242. * Creates a physics vortex event
  64243. * @param origin the of the vortex
  64244. * @param radiusOrEventOptions the radius or the options of the vortex
  64245. * @param strength the strength of the vortex
  64246. * @param height the height of the vortex
  64247. * @returns a Physics vortex event, or null
  64248. * A physics vortex event or null
  64249. */
  64250. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64251. }
  64252. /**
  64253. * Represents a physics radial explosion event
  64254. */
  64255. class PhysicsRadialExplosionEvent {
  64256. private _scene;
  64257. private _options;
  64258. private _sphere;
  64259. private _dataFetched;
  64260. /**
  64261. * Initializes a radial explosioin event
  64262. * @param _scene BabylonJS scene
  64263. * @param _options The options for the vortex event
  64264. */
  64265. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64266. /**
  64267. * Returns the data related to the radial explosion event (sphere).
  64268. * @returns The radial explosion event data
  64269. */
  64270. getData(): PhysicsRadialExplosionEventData;
  64271. /**
  64272. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64273. * @param impostor A physics imposter
  64274. * @param origin the origin of the explosion
  64275. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64276. */
  64277. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64278. /**
  64279. * Triggers affecterd impostors callbacks
  64280. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64281. */
  64282. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64283. /**
  64284. * Disposes the sphere.
  64285. * @param force Specifies if the sphere should be disposed by force
  64286. */
  64287. dispose(force?: boolean): void;
  64288. /*** Helpers ***/
  64289. private _prepareSphere;
  64290. private _intersectsWithSphere;
  64291. }
  64292. /**
  64293. * Represents a gravitational field event
  64294. */
  64295. class PhysicsGravitationalFieldEvent {
  64296. private _physicsHelper;
  64297. private _scene;
  64298. private _origin;
  64299. private _options;
  64300. private _tickCallback;
  64301. private _sphere;
  64302. private _dataFetched;
  64303. /**
  64304. * Initializes the physics gravitational field event
  64305. * @param _physicsHelper A physics helper
  64306. * @param _scene BabylonJS scene
  64307. * @param _origin The origin position of the gravitational field event
  64308. * @param _options The options for the vortex event
  64309. */
  64310. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64311. /**
  64312. * Returns the data related to the gravitational field event (sphere).
  64313. * @returns A gravitational field event
  64314. */
  64315. getData(): PhysicsGravitationalFieldEventData;
  64316. /**
  64317. * Enables the gravitational field.
  64318. */
  64319. enable(): void;
  64320. /**
  64321. * Disables the gravitational field.
  64322. */
  64323. disable(): void;
  64324. /**
  64325. * Disposes the sphere.
  64326. * @param force The force to dispose from the gravitational field event
  64327. */
  64328. dispose(force?: boolean): void;
  64329. private _tick;
  64330. }
  64331. /**
  64332. * Represents a physics updraft event
  64333. */
  64334. class PhysicsUpdraftEvent {
  64335. private _scene;
  64336. private _origin;
  64337. private _options;
  64338. private _physicsEngine;
  64339. private _originTop;
  64340. private _originDirection;
  64341. private _tickCallback;
  64342. private _cylinder;
  64343. private _cylinderPosition;
  64344. private _dataFetched;
  64345. /**
  64346. * Initializes the physics updraft event
  64347. * @param _scene BabylonJS scene
  64348. * @param _origin The origin position of the updraft
  64349. * @param _options The options for the updraft event
  64350. */
  64351. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64352. /**
  64353. * Returns the data related to the updraft event (cylinder).
  64354. * @returns A physics updraft event
  64355. */
  64356. getData(): PhysicsUpdraftEventData;
  64357. /**
  64358. * Enables the updraft.
  64359. */
  64360. enable(): void;
  64361. /**
  64362. * Disables the updraft.
  64363. */
  64364. disable(): void;
  64365. /**
  64366. * Disposes the cylinder.
  64367. * @param force Specifies if the updraft should be disposed by force
  64368. */
  64369. dispose(force?: boolean): void;
  64370. private getImpostorHitData;
  64371. private _tick;
  64372. /*** Helpers ***/
  64373. private _prepareCylinder;
  64374. private _intersectsWithCylinder;
  64375. }
  64376. /**
  64377. * Represents a physics vortex event
  64378. */
  64379. class PhysicsVortexEvent {
  64380. private _scene;
  64381. private _origin;
  64382. private _options;
  64383. private _physicsEngine;
  64384. private _originTop;
  64385. private _tickCallback;
  64386. private _cylinder;
  64387. private _cylinderPosition;
  64388. private _dataFetched;
  64389. /**
  64390. * Initializes the physics vortex event
  64391. * @param _scene The BabylonJS scene
  64392. * @param _origin The origin position of the vortex
  64393. * @param _options The options for the vortex event
  64394. */
  64395. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64396. /**
  64397. * Returns the data related to the vortex event (cylinder).
  64398. * @returns The physics vortex event data
  64399. */
  64400. getData(): PhysicsVortexEventData;
  64401. /**
  64402. * Enables the vortex.
  64403. */
  64404. enable(): void;
  64405. /**
  64406. * Disables the cortex.
  64407. */
  64408. disable(): void;
  64409. /**
  64410. * Disposes the sphere.
  64411. * @param force
  64412. */
  64413. dispose(force?: boolean): void;
  64414. private getImpostorHitData;
  64415. private _tick;
  64416. /*** Helpers ***/
  64417. private _prepareCylinder;
  64418. private _intersectsWithCylinder;
  64419. }
  64420. /**
  64421. * Options fot the radial explosion event
  64422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64423. */
  64424. export class PhysicsRadialExplosionEventOptions {
  64425. /**
  64426. * The radius of the sphere for the radial explosion.
  64427. */
  64428. radius: number;
  64429. /**
  64430. * The strenth of the explosion.
  64431. */
  64432. strength: number;
  64433. /**
  64434. * The strenght of the force in correspondence to the distance of the affected object
  64435. */
  64436. falloff: PhysicsRadialImpulseFalloff;
  64437. /**
  64438. * Sphere options for the radial explosion.
  64439. */
  64440. sphere: {
  64441. segments: number;
  64442. diameter: number;
  64443. };
  64444. /**
  64445. * Sphere options for the radial explosion.
  64446. */
  64447. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64448. }
  64449. /**
  64450. * Options fot the updraft event
  64451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64452. */
  64453. export class PhysicsUpdraftEventOptions {
  64454. /**
  64455. * The radius of the cylinder for the vortex
  64456. */
  64457. radius: number;
  64458. /**
  64459. * The strenth of the updraft.
  64460. */
  64461. strength: number;
  64462. /**
  64463. * The height of the cylinder for the updraft.
  64464. */
  64465. height: number;
  64466. /**
  64467. * The mode for the the updraft.
  64468. */
  64469. updraftMode: PhysicsUpdraftMode;
  64470. }
  64471. /**
  64472. * Options fot the vortex event
  64473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64474. */
  64475. export class PhysicsVortexEventOptions {
  64476. /**
  64477. * The radius of the cylinder for the vortex
  64478. */
  64479. radius: number;
  64480. /**
  64481. * The strenth of the vortex.
  64482. */
  64483. strength: number;
  64484. /**
  64485. * The height of the cylinder for the vortex.
  64486. */
  64487. height: number;
  64488. /**
  64489. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64490. */
  64491. centripetalForceThreshold: number;
  64492. /**
  64493. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64494. */
  64495. centripetalForceMultiplier: number;
  64496. /**
  64497. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64498. */
  64499. centrifugalForceMultiplier: number;
  64500. /**
  64501. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64502. */
  64503. updraftForceMultiplier: number;
  64504. }
  64505. /**
  64506. * The strenght of the force in correspondence to the distance of the affected object
  64507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64508. */
  64509. export enum PhysicsRadialImpulseFalloff {
  64510. /** Defines that impulse is constant in strength across it's whole radius */
  64511. Constant = 0,
  64512. /** Defines that impulse gets weaker if it's further from the origin */
  64513. Linear = 1
  64514. }
  64515. /**
  64516. * The strength of the force in correspondence to the distance of the affected object
  64517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64518. */
  64519. export enum PhysicsUpdraftMode {
  64520. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64521. Center = 0,
  64522. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64523. Perpendicular = 1
  64524. }
  64525. /**
  64526. * Interface for a physics hit data
  64527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64528. */
  64529. export interface PhysicsHitData {
  64530. /**
  64531. * The force applied at the contact point
  64532. */
  64533. force: Vector3;
  64534. /**
  64535. * The contact point
  64536. */
  64537. contactPoint: Vector3;
  64538. /**
  64539. * The distance from the origin to the contact point
  64540. */
  64541. distanceFromOrigin: number;
  64542. }
  64543. /**
  64544. * Interface for radial explosion event data
  64545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64546. */
  64547. export interface PhysicsRadialExplosionEventData {
  64548. /**
  64549. * A sphere used for the radial explosion event
  64550. */
  64551. sphere: Mesh;
  64552. }
  64553. /**
  64554. * Interface for gravitational field event data
  64555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64556. */
  64557. export interface PhysicsGravitationalFieldEventData {
  64558. /**
  64559. * A sphere mesh used for the gravitational field event
  64560. */
  64561. sphere: Mesh;
  64562. }
  64563. /**
  64564. * Interface for updraft event data
  64565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64566. */
  64567. export interface PhysicsUpdraftEventData {
  64568. /**
  64569. * A cylinder used for the updraft event
  64570. */
  64571. cylinder: Mesh;
  64572. }
  64573. /**
  64574. * Interface for vortex event data
  64575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64576. */
  64577. export interface PhysicsVortexEventData {
  64578. /**
  64579. * A cylinder used for the vortex event
  64580. */
  64581. cylinder: Mesh;
  64582. }
  64583. /**
  64584. * Interface for an affected physics impostor
  64585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64586. */
  64587. export interface PhysicsAffectedImpostorWithData {
  64588. /**
  64589. * The impostor affected by the effect
  64590. */
  64591. impostor: PhysicsImpostor;
  64592. /**
  64593. * The data about the hit/horce from the explosion
  64594. */
  64595. hitData: PhysicsHitData;
  64596. }
  64597. }
  64598. declare module BABYLON {
  64599. /** @hidden */
  64600. export var blackAndWhitePixelShader: {
  64601. name: string;
  64602. shader: string;
  64603. };
  64604. }
  64605. declare module BABYLON {
  64606. /**
  64607. * Post process used to render in black and white
  64608. */
  64609. export class BlackAndWhitePostProcess extends PostProcess {
  64610. /**
  64611. * Linear about to convert he result to black and white (default: 1)
  64612. */
  64613. degree: number;
  64614. /**
  64615. * Creates a black and white post process
  64616. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64617. * @param name The name of the effect.
  64618. * @param options The required width/height ratio to downsize to before computing the render pass.
  64619. * @param camera The camera to apply the render pass to.
  64620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64621. * @param engine The engine which the post process will be applied. (default: current engine)
  64622. * @param reusable If the post process can be reused on the same frame. (default: false)
  64623. */
  64624. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64625. }
  64626. }
  64627. declare module BABYLON {
  64628. /**
  64629. * This represents a set of one or more post processes in Babylon.
  64630. * A post process can be used to apply a shader to a texture after it is rendered.
  64631. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64632. */
  64633. export class PostProcessRenderEffect {
  64634. private _postProcesses;
  64635. private _getPostProcesses;
  64636. private _singleInstance;
  64637. private _cameras;
  64638. private _indicesForCamera;
  64639. /**
  64640. * Name of the effect
  64641. * @hidden
  64642. */
  64643. _name: string;
  64644. /**
  64645. * Instantiates a post process render effect.
  64646. * A post process can be used to apply a shader to a texture after it is rendered.
  64647. * @param engine The engine the effect is tied to
  64648. * @param name The name of the effect
  64649. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64650. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64651. */
  64652. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64653. /**
  64654. * Checks if all the post processes in the effect are supported.
  64655. */
  64656. get isSupported(): boolean;
  64657. /**
  64658. * Updates the current state of the effect
  64659. * @hidden
  64660. */
  64661. _update(): void;
  64662. /**
  64663. * Attaches the effect on cameras
  64664. * @param cameras The camera to attach to.
  64665. * @hidden
  64666. */
  64667. _attachCameras(cameras: Camera): void;
  64668. /**
  64669. * Attaches the effect on cameras
  64670. * @param cameras The camera to attach to.
  64671. * @hidden
  64672. */
  64673. _attachCameras(cameras: Camera[]): void;
  64674. /**
  64675. * Detaches the effect on cameras
  64676. * @param cameras The camera to detatch from.
  64677. * @hidden
  64678. */
  64679. _detachCameras(cameras: Camera): void;
  64680. /**
  64681. * Detatches the effect on cameras
  64682. * @param cameras The camera to detatch from.
  64683. * @hidden
  64684. */
  64685. _detachCameras(cameras: Camera[]): void;
  64686. /**
  64687. * Enables the effect on given cameras
  64688. * @param cameras The camera to enable.
  64689. * @hidden
  64690. */
  64691. _enable(cameras: Camera): void;
  64692. /**
  64693. * Enables the effect on given cameras
  64694. * @param cameras The camera to enable.
  64695. * @hidden
  64696. */
  64697. _enable(cameras: Nullable<Camera[]>): void;
  64698. /**
  64699. * Disables the effect on the given cameras
  64700. * @param cameras The camera to disable.
  64701. * @hidden
  64702. */
  64703. _disable(cameras: Camera): void;
  64704. /**
  64705. * Disables the effect on the given cameras
  64706. * @param cameras The camera to disable.
  64707. * @hidden
  64708. */
  64709. _disable(cameras: Nullable<Camera[]>): void;
  64710. /**
  64711. * Gets a list of the post processes contained in the effect.
  64712. * @param camera The camera to get the post processes on.
  64713. * @returns The list of the post processes in the effect.
  64714. */
  64715. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64716. }
  64717. }
  64718. declare module BABYLON {
  64719. /** @hidden */
  64720. export var extractHighlightsPixelShader: {
  64721. name: string;
  64722. shader: string;
  64723. };
  64724. }
  64725. declare module BABYLON {
  64726. /**
  64727. * 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.
  64728. */
  64729. export class ExtractHighlightsPostProcess extends PostProcess {
  64730. /**
  64731. * The luminance threshold, pixels below this value will be set to black.
  64732. */
  64733. threshold: number;
  64734. /** @hidden */
  64735. _exposure: number;
  64736. /**
  64737. * Post process which has the input texture to be used when performing highlight extraction
  64738. * @hidden
  64739. */
  64740. _inputPostProcess: Nullable<PostProcess>;
  64741. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64742. }
  64743. }
  64744. declare module BABYLON {
  64745. /** @hidden */
  64746. export var bloomMergePixelShader: {
  64747. name: string;
  64748. shader: string;
  64749. };
  64750. }
  64751. declare module BABYLON {
  64752. /**
  64753. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64754. */
  64755. export class BloomMergePostProcess extends PostProcess {
  64756. /** Weight of the bloom to be added to the original input. */
  64757. weight: number;
  64758. /**
  64759. * Creates a new instance of @see BloomMergePostProcess
  64760. * @param name The name of the effect.
  64761. * @param originalFromInput Post process which's input will be used for the merge.
  64762. * @param blurred Blurred highlights post process which's output will be used.
  64763. * @param weight Weight of the bloom to be added to the original input.
  64764. * @param options The required width/height ratio to downsize to before computing the render pass.
  64765. * @param camera The camera to apply the render pass to.
  64766. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64767. * @param engine The engine which the post process will be applied. (default: current engine)
  64768. * @param reusable If the post process can be reused on the same frame. (default: false)
  64769. * @param textureType Type of textures used when performing the post process. (default: 0)
  64770. * @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)
  64771. */
  64772. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64773. /** Weight of the bloom to be added to the original input. */
  64774. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64775. }
  64776. }
  64777. declare module BABYLON {
  64778. /**
  64779. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64780. */
  64781. export class BloomEffect extends PostProcessRenderEffect {
  64782. private bloomScale;
  64783. /**
  64784. * @hidden Internal
  64785. */
  64786. _effects: Array<PostProcess>;
  64787. /**
  64788. * @hidden Internal
  64789. */
  64790. _downscale: ExtractHighlightsPostProcess;
  64791. private _blurX;
  64792. private _blurY;
  64793. private _merge;
  64794. /**
  64795. * The luminance threshold to find bright areas of the image to bloom.
  64796. */
  64797. get threshold(): number;
  64798. set threshold(value: number);
  64799. /**
  64800. * The strength of the bloom.
  64801. */
  64802. get weight(): number;
  64803. set weight(value: number);
  64804. /**
  64805. * Specifies the size of the bloom blur kernel, relative to the final output size
  64806. */
  64807. get kernel(): number;
  64808. set kernel(value: number);
  64809. /**
  64810. * Creates a new instance of @see BloomEffect
  64811. * @param scene The scene the effect belongs to.
  64812. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64813. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64814. * @param bloomWeight The the strength of bloom.
  64815. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64816. * @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)
  64817. */
  64818. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64819. /**
  64820. * Disposes each of the internal effects for a given camera.
  64821. * @param camera The camera to dispose the effect on.
  64822. */
  64823. disposeEffects(camera: Camera): void;
  64824. /**
  64825. * @hidden Internal
  64826. */
  64827. _updateEffects(): void;
  64828. /**
  64829. * Internal
  64830. * @returns if all the contained post processes are ready.
  64831. * @hidden
  64832. */
  64833. _isReady(): boolean;
  64834. }
  64835. }
  64836. declare module BABYLON {
  64837. /** @hidden */
  64838. export var chromaticAberrationPixelShader: {
  64839. name: string;
  64840. shader: string;
  64841. };
  64842. }
  64843. declare module BABYLON {
  64844. /**
  64845. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64846. */
  64847. export class ChromaticAberrationPostProcess extends PostProcess {
  64848. /**
  64849. * The amount of seperation of rgb channels (default: 30)
  64850. */
  64851. aberrationAmount: number;
  64852. /**
  64853. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64854. */
  64855. radialIntensity: number;
  64856. /**
  64857. * 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))
  64858. */
  64859. direction: Vector2;
  64860. /**
  64861. * 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))
  64862. */
  64863. centerPosition: Vector2;
  64864. /**
  64865. * Creates a new instance ChromaticAberrationPostProcess
  64866. * @param name The name of the effect.
  64867. * @param screenWidth The width of the screen to apply the effect on.
  64868. * @param screenHeight The height of the screen to apply the effect on.
  64869. * @param options The required width/height ratio to downsize to before computing the render pass.
  64870. * @param camera The camera to apply the render pass to.
  64871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64872. * @param engine The engine which the post process will be applied. (default: current engine)
  64873. * @param reusable If the post process can be reused on the same frame. (default: false)
  64874. * @param textureType Type of textures used when performing the post process. (default: 0)
  64875. * @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)
  64876. */
  64877. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64878. }
  64879. }
  64880. declare module BABYLON {
  64881. /** @hidden */
  64882. export var circleOfConfusionPixelShader: {
  64883. name: string;
  64884. shader: string;
  64885. };
  64886. }
  64887. declare module BABYLON {
  64888. /**
  64889. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64890. */
  64891. export class CircleOfConfusionPostProcess extends PostProcess {
  64892. /**
  64893. * 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.
  64894. */
  64895. lensSize: number;
  64896. /**
  64897. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64898. */
  64899. fStop: number;
  64900. /**
  64901. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64902. */
  64903. focusDistance: number;
  64904. /**
  64905. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64906. */
  64907. focalLength: number;
  64908. private _depthTexture;
  64909. /**
  64910. * Creates a new instance CircleOfConfusionPostProcess
  64911. * @param name The name of the effect.
  64912. * @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.
  64913. * @param options The required width/height ratio to downsize to before computing the render pass.
  64914. * @param camera The camera to apply the render pass to.
  64915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64916. * @param engine The engine which the post process will be applied. (default: current engine)
  64917. * @param reusable If the post process can be reused on the same frame. (default: false)
  64918. * @param textureType Type of textures used when performing the post process. (default: 0)
  64919. * @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)
  64920. */
  64921. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64922. /**
  64923. * 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.
  64924. */
  64925. set depthTexture(value: RenderTargetTexture);
  64926. }
  64927. }
  64928. declare module BABYLON {
  64929. /** @hidden */
  64930. export var colorCorrectionPixelShader: {
  64931. name: string;
  64932. shader: string;
  64933. };
  64934. }
  64935. declare module BABYLON {
  64936. /**
  64937. *
  64938. * This post-process allows the modification of rendered colors by using
  64939. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64940. *
  64941. * The object needs to be provided an url to a texture containing the color
  64942. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64943. * Use an image editing software to tweak the LUT to match your needs.
  64944. *
  64945. * For an example of a color LUT, see here:
  64946. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64947. * For explanations on color grading, see here:
  64948. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64949. *
  64950. */
  64951. export class ColorCorrectionPostProcess extends PostProcess {
  64952. private _colorTableTexture;
  64953. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64954. }
  64955. }
  64956. declare module BABYLON {
  64957. /** @hidden */
  64958. export var convolutionPixelShader: {
  64959. name: string;
  64960. shader: string;
  64961. };
  64962. }
  64963. declare module BABYLON {
  64964. /**
  64965. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64966. * input texture to perform effects such as edge detection or sharpening
  64967. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64968. */
  64969. export class ConvolutionPostProcess extends PostProcess {
  64970. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64971. kernel: number[];
  64972. /**
  64973. * Creates a new instance ConvolutionPostProcess
  64974. * @param name The name of the effect.
  64975. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64976. * @param options The required width/height ratio to downsize to before computing the render pass.
  64977. * @param camera The camera to apply the render pass to.
  64978. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64979. * @param engine The engine which the post process will be applied. (default: current engine)
  64980. * @param reusable If the post process can be reused on the same frame. (default: false)
  64981. * @param textureType Type of textures used when performing the post process. (default: 0)
  64982. */
  64983. constructor(name: string,
  64984. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64985. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64986. /**
  64987. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64988. */
  64989. static EdgeDetect0Kernel: number[];
  64990. /**
  64991. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64992. */
  64993. static EdgeDetect1Kernel: number[];
  64994. /**
  64995. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64996. */
  64997. static EdgeDetect2Kernel: number[];
  64998. /**
  64999. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65000. */
  65001. static SharpenKernel: number[];
  65002. /**
  65003. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65004. */
  65005. static EmbossKernel: number[];
  65006. /**
  65007. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65008. */
  65009. static GaussianKernel: number[];
  65010. }
  65011. }
  65012. declare module BABYLON {
  65013. /**
  65014. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65015. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65016. * based on samples that have a large difference in distance than the center pixel.
  65017. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65018. */
  65019. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65020. direction: Vector2;
  65021. /**
  65022. * Creates a new instance CircleOfConfusionPostProcess
  65023. * @param name The name of the effect.
  65024. * @param scene The scene the effect belongs to.
  65025. * @param direction The direction the blur should be applied.
  65026. * @param kernel The size of the kernel used to blur.
  65027. * @param options The required width/height ratio to downsize to before computing the render pass.
  65028. * @param camera The camera to apply the render pass to.
  65029. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65030. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65032. * @param engine The engine which the post process will be applied. (default: current engine)
  65033. * @param reusable If the post process can be reused on the same frame. (default: false)
  65034. * @param textureType Type of textures used when performing the post process. (default: 0)
  65035. * @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)
  65036. */
  65037. 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);
  65038. }
  65039. }
  65040. declare module BABYLON {
  65041. /** @hidden */
  65042. export var depthOfFieldMergePixelShader: {
  65043. name: string;
  65044. shader: string;
  65045. };
  65046. }
  65047. declare module BABYLON {
  65048. /**
  65049. * Options to be set when merging outputs from the default pipeline.
  65050. */
  65051. export class DepthOfFieldMergePostProcessOptions {
  65052. /**
  65053. * The original image to merge on top of
  65054. */
  65055. originalFromInput: PostProcess;
  65056. /**
  65057. * Parameters to perform the merge of the depth of field effect
  65058. */
  65059. depthOfField?: {
  65060. circleOfConfusion: PostProcess;
  65061. blurSteps: Array<PostProcess>;
  65062. };
  65063. /**
  65064. * Parameters to perform the merge of bloom effect
  65065. */
  65066. bloom?: {
  65067. blurred: PostProcess;
  65068. weight: number;
  65069. };
  65070. }
  65071. /**
  65072. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65073. */
  65074. export class DepthOfFieldMergePostProcess extends PostProcess {
  65075. private blurSteps;
  65076. /**
  65077. * Creates a new instance of DepthOfFieldMergePostProcess
  65078. * @param name The name of the effect.
  65079. * @param originalFromInput Post process which's input will be used for the merge.
  65080. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65081. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65082. * @param options The required width/height ratio to downsize to before computing the render pass.
  65083. * @param camera The camera to apply the render pass to.
  65084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65085. * @param engine The engine which the post process will be applied. (default: current engine)
  65086. * @param reusable If the post process can be reused on the same frame. (default: false)
  65087. * @param textureType Type of textures used when performing the post process. (default: 0)
  65088. * @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)
  65089. */
  65090. 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);
  65091. /**
  65092. * Updates the effect with the current post process compile time values and recompiles the shader.
  65093. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65094. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65095. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65096. * @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
  65097. * @param onCompiled Called when the shader has been compiled.
  65098. * @param onError Called if there is an error when compiling a shader.
  65099. */
  65100. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65101. }
  65102. }
  65103. declare module BABYLON {
  65104. /**
  65105. * Specifies the level of max blur that should be applied when using the depth of field effect
  65106. */
  65107. export enum DepthOfFieldEffectBlurLevel {
  65108. /**
  65109. * Subtle blur
  65110. */
  65111. Low = 0,
  65112. /**
  65113. * Medium blur
  65114. */
  65115. Medium = 1,
  65116. /**
  65117. * Large blur
  65118. */
  65119. High = 2
  65120. }
  65121. /**
  65122. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65123. */
  65124. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65125. private _circleOfConfusion;
  65126. /**
  65127. * @hidden Internal, blurs from high to low
  65128. */
  65129. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65130. private _depthOfFieldBlurY;
  65131. private _dofMerge;
  65132. /**
  65133. * @hidden Internal post processes in depth of field effect
  65134. */
  65135. _effects: Array<PostProcess>;
  65136. /**
  65137. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65138. */
  65139. set focalLength(value: number);
  65140. get focalLength(): number;
  65141. /**
  65142. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65143. */
  65144. set fStop(value: number);
  65145. get fStop(): number;
  65146. /**
  65147. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65148. */
  65149. set focusDistance(value: number);
  65150. get focusDistance(): number;
  65151. /**
  65152. * 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.
  65153. */
  65154. set lensSize(value: number);
  65155. get lensSize(): number;
  65156. /**
  65157. * Creates a new instance DepthOfFieldEffect
  65158. * @param scene The scene the effect belongs to.
  65159. * @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.
  65160. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65161. * @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)
  65162. */
  65163. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65164. /**
  65165. * Get the current class name of the current effet
  65166. * @returns "DepthOfFieldEffect"
  65167. */
  65168. getClassName(): string;
  65169. /**
  65170. * 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.
  65171. */
  65172. set depthTexture(value: RenderTargetTexture);
  65173. /**
  65174. * Disposes each of the internal effects for a given camera.
  65175. * @param camera The camera to dispose the effect on.
  65176. */
  65177. disposeEffects(camera: Camera): void;
  65178. /**
  65179. * @hidden Internal
  65180. */
  65181. _updateEffects(): void;
  65182. /**
  65183. * Internal
  65184. * @returns if all the contained post processes are ready.
  65185. * @hidden
  65186. */
  65187. _isReady(): boolean;
  65188. }
  65189. }
  65190. declare module BABYLON {
  65191. /** @hidden */
  65192. export var displayPassPixelShader: {
  65193. name: string;
  65194. shader: string;
  65195. };
  65196. }
  65197. declare module BABYLON {
  65198. /**
  65199. * DisplayPassPostProcess which produces an output the same as it's input
  65200. */
  65201. export class DisplayPassPostProcess extends PostProcess {
  65202. /**
  65203. * Creates the DisplayPassPostProcess
  65204. * @param name The name of the effect.
  65205. * @param options The required width/height ratio to downsize to before computing the render pass.
  65206. * @param camera The camera to apply the render pass to.
  65207. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65208. * @param engine The engine which the post process will be applied. (default: current engine)
  65209. * @param reusable If the post process can be reused on the same frame. (default: false)
  65210. */
  65211. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65212. }
  65213. }
  65214. declare module BABYLON {
  65215. /** @hidden */
  65216. export var filterPixelShader: {
  65217. name: string;
  65218. shader: string;
  65219. };
  65220. }
  65221. declare module BABYLON {
  65222. /**
  65223. * Applies a kernel filter to the image
  65224. */
  65225. export class FilterPostProcess extends PostProcess {
  65226. /** The matrix to be applied to the image */
  65227. kernelMatrix: Matrix;
  65228. /**
  65229. *
  65230. * @param name The name of the effect.
  65231. * @param kernelMatrix The matrix to be applied to the image
  65232. * @param options The required width/height ratio to downsize to before computing the render pass.
  65233. * @param camera The camera to apply the render pass to.
  65234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65235. * @param engine The engine which the post process will be applied. (default: current engine)
  65236. * @param reusable If the post process can be reused on the same frame. (default: false)
  65237. */
  65238. constructor(name: string,
  65239. /** The matrix to be applied to the image */
  65240. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65241. }
  65242. }
  65243. declare module BABYLON {
  65244. /** @hidden */
  65245. export var fxaaPixelShader: {
  65246. name: string;
  65247. shader: string;
  65248. };
  65249. }
  65250. declare module BABYLON {
  65251. /** @hidden */
  65252. export var fxaaVertexShader: {
  65253. name: string;
  65254. shader: string;
  65255. };
  65256. }
  65257. declare module BABYLON {
  65258. /**
  65259. * Fxaa post process
  65260. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65261. */
  65262. export class FxaaPostProcess extends PostProcess {
  65263. /** @hidden */
  65264. texelWidth: number;
  65265. /** @hidden */
  65266. texelHeight: number;
  65267. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65268. private _getDefines;
  65269. }
  65270. }
  65271. declare module BABYLON {
  65272. /** @hidden */
  65273. export var grainPixelShader: {
  65274. name: string;
  65275. shader: string;
  65276. };
  65277. }
  65278. declare module BABYLON {
  65279. /**
  65280. * The GrainPostProcess adds noise to the image at mid luminance levels
  65281. */
  65282. export class GrainPostProcess extends PostProcess {
  65283. /**
  65284. * The intensity of the grain added (default: 30)
  65285. */
  65286. intensity: number;
  65287. /**
  65288. * If the grain should be randomized on every frame
  65289. */
  65290. animated: boolean;
  65291. /**
  65292. * Creates a new instance of @see GrainPostProcess
  65293. * @param name The name of the effect.
  65294. * @param options The required width/height ratio to downsize to before computing the render pass.
  65295. * @param camera The camera to apply the render pass to.
  65296. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65297. * @param engine The engine which the post process will be applied. (default: current engine)
  65298. * @param reusable If the post process can be reused on the same frame. (default: false)
  65299. * @param textureType Type of textures used when performing the post process. (default: 0)
  65300. * @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)
  65301. */
  65302. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65303. }
  65304. }
  65305. declare module BABYLON {
  65306. /** @hidden */
  65307. export var highlightsPixelShader: {
  65308. name: string;
  65309. shader: string;
  65310. };
  65311. }
  65312. declare module BABYLON {
  65313. /**
  65314. * Extracts highlights from the image
  65315. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65316. */
  65317. export class HighlightsPostProcess extends PostProcess {
  65318. /**
  65319. * Extracts highlights from the image
  65320. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65321. * @param name The name of the effect.
  65322. * @param options The required width/height ratio to downsize to before computing the render pass.
  65323. * @param camera The camera to apply the render pass to.
  65324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65325. * @param engine The engine which the post process will be applied. (default: current engine)
  65326. * @param reusable If the post process can be reused on the same frame. (default: false)
  65327. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65328. */
  65329. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65330. }
  65331. }
  65332. declare module BABYLON {
  65333. /** @hidden */
  65334. export var mrtFragmentDeclaration: {
  65335. name: string;
  65336. shader: string;
  65337. };
  65338. }
  65339. declare module BABYLON {
  65340. /** @hidden */
  65341. export var geometryPixelShader: {
  65342. name: string;
  65343. shader: string;
  65344. };
  65345. }
  65346. declare module BABYLON {
  65347. /** @hidden */
  65348. export var geometryVertexShader: {
  65349. name: string;
  65350. shader: string;
  65351. };
  65352. }
  65353. declare module BABYLON {
  65354. /** @hidden */
  65355. interface ISavedTransformationMatrix {
  65356. world: Matrix;
  65357. viewProjection: Matrix;
  65358. }
  65359. /**
  65360. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65361. */
  65362. export class GeometryBufferRenderer {
  65363. /**
  65364. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65365. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65366. */
  65367. static readonly POSITION_TEXTURE_TYPE: number;
  65368. /**
  65369. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65370. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65371. */
  65372. static readonly VELOCITY_TEXTURE_TYPE: number;
  65373. /**
  65374. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65375. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65376. */
  65377. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65378. /**
  65379. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65380. * in order to compute objects velocities when enableVelocity is set to "true"
  65381. * @hidden
  65382. */
  65383. _previousTransformationMatrices: {
  65384. [index: number]: ISavedTransformationMatrix;
  65385. };
  65386. /**
  65387. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65388. * in order to compute objects velocities when enableVelocity is set to "true"
  65389. * @hidden
  65390. */
  65391. _previousBonesTransformationMatrices: {
  65392. [index: number]: Float32Array;
  65393. };
  65394. /**
  65395. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65396. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65397. */
  65398. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65399. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65400. renderTransparentMeshes: boolean;
  65401. private _scene;
  65402. private _multiRenderTarget;
  65403. private _ratio;
  65404. private _enablePosition;
  65405. private _enableVelocity;
  65406. private _enableReflectivity;
  65407. private _positionIndex;
  65408. private _velocityIndex;
  65409. private _reflectivityIndex;
  65410. protected _effect: Effect;
  65411. protected _cachedDefines: string;
  65412. /**
  65413. * Set the render list (meshes to be rendered) used in the G buffer.
  65414. */
  65415. set renderList(meshes: Mesh[]);
  65416. /**
  65417. * Gets wether or not G buffer are supported by the running hardware.
  65418. * This requires draw buffer supports
  65419. */
  65420. get isSupported(): boolean;
  65421. /**
  65422. * Returns the index of the given texture type in the G-Buffer textures array
  65423. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65424. * @returns the index of the given texture type in the G-Buffer textures array
  65425. */
  65426. getTextureIndex(textureType: number): number;
  65427. /**
  65428. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65429. */
  65430. get enablePosition(): boolean;
  65431. /**
  65432. * Sets whether or not objects positions are enabled for the G buffer.
  65433. */
  65434. set enablePosition(enable: boolean);
  65435. /**
  65436. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65437. */
  65438. get enableVelocity(): boolean;
  65439. /**
  65440. * Sets wether or not objects velocities are enabled for the G buffer.
  65441. */
  65442. set enableVelocity(enable: boolean);
  65443. /**
  65444. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65445. */
  65446. get enableReflectivity(): boolean;
  65447. /**
  65448. * Sets wether or not objects roughness are enabled for the G buffer.
  65449. */
  65450. set enableReflectivity(enable: boolean);
  65451. /**
  65452. * Gets the scene associated with the buffer.
  65453. */
  65454. get scene(): Scene;
  65455. /**
  65456. * Gets the ratio used by the buffer during its creation.
  65457. * How big is the buffer related to the main canvas.
  65458. */
  65459. get ratio(): number;
  65460. /** @hidden */
  65461. static _SceneComponentInitialization: (scene: Scene) => void;
  65462. /**
  65463. * Creates a new G Buffer for the scene
  65464. * @param scene The scene the buffer belongs to
  65465. * @param ratio How big is the buffer related to the main canvas.
  65466. */
  65467. constructor(scene: Scene, ratio?: number);
  65468. /**
  65469. * Checks wether everything is ready to render a submesh to the G buffer.
  65470. * @param subMesh the submesh to check readiness for
  65471. * @param useInstances is the mesh drawn using instance or not
  65472. * @returns true if ready otherwise false
  65473. */
  65474. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65475. /**
  65476. * Gets the current underlying G Buffer.
  65477. * @returns the buffer
  65478. */
  65479. getGBuffer(): MultiRenderTarget;
  65480. /**
  65481. * Gets the number of samples used to render the buffer (anti aliasing).
  65482. */
  65483. get samples(): number;
  65484. /**
  65485. * Sets the number of samples used to render the buffer (anti aliasing).
  65486. */
  65487. set samples(value: number);
  65488. /**
  65489. * Disposes the renderer and frees up associated resources.
  65490. */
  65491. dispose(): void;
  65492. protected _createRenderTargets(): void;
  65493. private _copyBonesTransformationMatrices;
  65494. }
  65495. }
  65496. declare module BABYLON {
  65497. interface Scene {
  65498. /** @hidden (Backing field) */
  65499. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65500. /**
  65501. * Gets or Sets the current geometry buffer associated to the scene.
  65502. */
  65503. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65504. /**
  65505. * Enables a GeometryBufferRender and associates it with the scene
  65506. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65507. * @returns the GeometryBufferRenderer
  65508. */
  65509. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65510. /**
  65511. * Disables the GeometryBufferRender associated with the scene
  65512. */
  65513. disableGeometryBufferRenderer(): void;
  65514. }
  65515. /**
  65516. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65517. * in several rendering techniques.
  65518. */
  65519. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65520. /**
  65521. * The component name helpful to identify the component in the list of scene components.
  65522. */
  65523. readonly name: string;
  65524. /**
  65525. * The scene the component belongs to.
  65526. */
  65527. scene: Scene;
  65528. /**
  65529. * Creates a new instance of the component for the given scene
  65530. * @param scene Defines the scene to register the component in
  65531. */
  65532. constructor(scene: Scene);
  65533. /**
  65534. * Registers the component in a given scene
  65535. */
  65536. register(): void;
  65537. /**
  65538. * Rebuilds the elements related to this component in case of
  65539. * context lost for instance.
  65540. */
  65541. rebuild(): void;
  65542. /**
  65543. * Disposes the component and the associated ressources
  65544. */
  65545. dispose(): void;
  65546. private _gatherRenderTargets;
  65547. }
  65548. }
  65549. declare module BABYLON {
  65550. /** @hidden */
  65551. export var motionBlurPixelShader: {
  65552. name: string;
  65553. shader: string;
  65554. };
  65555. }
  65556. declare module BABYLON {
  65557. /**
  65558. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65559. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65560. * As an example, all you have to do is to create the post-process:
  65561. * var mb = new BABYLON.MotionBlurPostProcess(
  65562. * 'mb', // The name of the effect.
  65563. * scene, // The scene containing the objects to blur according to their velocity.
  65564. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65565. * camera // The camera to apply the render pass to.
  65566. * );
  65567. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65568. */
  65569. export class MotionBlurPostProcess extends PostProcess {
  65570. /**
  65571. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65572. */
  65573. motionStrength: number;
  65574. /**
  65575. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65576. */
  65577. get motionBlurSamples(): number;
  65578. /**
  65579. * Sets the number of iterations to be used for motion blur quality
  65580. */
  65581. set motionBlurSamples(samples: number);
  65582. private _motionBlurSamples;
  65583. private _geometryBufferRenderer;
  65584. /**
  65585. * Creates a new instance MotionBlurPostProcess
  65586. * @param name The name of the effect.
  65587. * @param scene The scene containing the objects to blur according to their velocity.
  65588. * @param options The required width/height ratio to downsize to before computing the render pass.
  65589. * @param camera The camera to apply the render pass to.
  65590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65591. * @param engine The engine which the post process will be applied. (default: current engine)
  65592. * @param reusable If the post process can be reused on the same frame. (default: false)
  65593. * @param textureType Type of textures used when performing the post process. (default: 0)
  65594. * @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)
  65595. */
  65596. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65597. /**
  65598. * Excludes the given skinned mesh from computing bones velocities.
  65599. * 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.
  65600. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65601. */
  65602. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65603. /**
  65604. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65605. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65606. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65607. */
  65608. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65609. /**
  65610. * Disposes the post process.
  65611. * @param camera The camera to dispose the post process on.
  65612. */
  65613. dispose(camera?: Camera): void;
  65614. }
  65615. }
  65616. declare module BABYLON {
  65617. /** @hidden */
  65618. export var refractionPixelShader: {
  65619. name: string;
  65620. shader: string;
  65621. };
  65622. }
  65623. declare module BABYLON {
  65624. /**
  65625. * Post process which applies a refractin texture
  65626. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65627. */
  65628. export class RefractionPostProcess extends PostProcess {
  65629. /** the base color of the refraction (used to taint the rendering) */
  65630. color: Color3;
  65631. /** simulated refraction depth */
  65632. depth: number;
  65633. /** the coefficient of the base color (0 to remove base color tainting) */
  65634. colorLevel: number;
  65635. private _refTexture;
  65636. private _ownRefractionTexture;
  65637. /**
  65638. * Gets or sets the refraction texture
  65639. * Please note that you are responsible for disposing the texture if you set it manually
  65640. */
  65641. get refractionTexture(): Texture;
  65642. set refractionTexture(value: Texture);
  65643. /**
  65644. * Initializes the RefractionPostProcess
  65645. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65646. * @param name The name of the effect.
  65647. * @param refractionTextureUrl Url of the refraction texture to use
  65648. * @param color the base color of the refraction (used to taint the rendering)
  65649. * @param depth simulated refraction depth
  65650. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65651. * @param camera The camera to apply the render pass to.
  65652. * @param options The required width/height ratio to downsize to before computing the render pass.
  65653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65654. * @param engine The engine which the post process will be applied. (default: current engine)
  65655. * @param reusable If the post process can be reused on the same frame. (default: false)
  65656. */
  65657. constructor(name: string, refractionTextureUrl: string,
  65658. /** the base color of the refraction (used to taint the rendering) */
  65659. color: Color3,
  65660. /** simulated refraction depth */
  65661. depth: number,
  65662. /** the coefficient of the base color (0 to remove base color tainting) */
  65663. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65664. /**
  65665. * Disposes of the post process
  65666. * @param camera Camera to dispose post process on
  65667. */
  65668. dispose(camera: Camera): void;
  65669. }
  65670. }
  65671. declare module BABYLON {
  65672. /** @hidden */
  65673. export var sharpenPixelShader: {
  65674. name: string;
  65675. shader: string;
  65676. };
  65677. }
  65678. declare module BABYLON {
  65679. /**
  65680. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65681. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65682. */
  65683. export class SharpenPostProcess extends PostProcess {
  65684. /**
  65685. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65686. */
  65687. colorAmount: number;
  65688. /**
  65689. * How much sharpness should be applied (default: 0.3)
  65690. */
  65691. edgeAmount: number;
  65692. /**
  65693. * Creates a new instance ConvolutionPostProcess
  65694. * @param name The name of the effect.
  65695. * @param options The required width/height ratio to downsize to before computing the render pass.
  65696. * @param camera The camera to apply the render pass to.
  65697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65698. * @param engine The engine which the post process will be applied. (default: current engine)
  65699. * @param reusable If the post process can be reused on the same frame. (default: false)
  65700. * @param textureType Type of textures used when performing the post process. (default: 0)
  65701. * @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)
  65702. */
  65703. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65704. }
  65705. }
  65706. declare module BABYLON {
  65707. /**
  65708. * PostProcessRenderPipeline
  65709. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65710. */
  65711. export class PostProcessRenderPipeline {
  65712. private engine;
  65713. private _renderEffects;
  65714. private _renderEffectsForIsolatedPass;
  65715. /**
  65716. * List of inspectable custom properties (used by the Inspector)
  65717. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65718. */
  65719. inspectableCustomProperties: IInspectable[];
  65720. /**
  65721. * @hidden
  65722. */
  65723. protected _cameras: Camera[];
  65724. /** @hidden */
  65725. _name: string;
  65726. /**
  65727. * Gets pipeline name
  65728. */
  65729. get name(): string;
  65730. /** Gets the list of attached cameras */
  65731. get cameras(): Camera[];
  65732. /**
  65733. * Initializes a PostProcessRenderPipeline
  65734. * @param engine engine to add the pipeline to
  65735. * @param name name of the pipeline
  65736. */
  65737. constructor(engine: Engine, name: string);
  65738. /**
  65739. * Gets the class name
  65740. * @returns "PostProcessRenderPipeline"
  65741. */
  65742. getClassName(): string;
  65743. /**
  65744. * If all the render effects in the pipeline are supported
  65745. */
  65746. get isSupported(): boolean;
  65747. /**
  65748. * Adds an effect to the pipeline
  65749. * @param renderEffect the effect to add
  65750. */
  65751. addEffect(renderEffect: PostProcessRenderEffect): void;
  65752. /** @hidden */
  65753. _rebuild(): void;
  65754. /** @hidden */
  65755. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65756. /** @hidden */
  65757. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65758. /** @hidden */
  65759. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65760. /** @hidden */
  65761. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65762. /** @hidden */
  65763. _attachCameras(cameras: Camera, unique: boolean): void;
  65764. /** @hidden */
  65765. _attachCameras(cameras: Camera[], unique: boolean): void;
  65766. /** @hidden */
  65767. _detachCameras(cameras: Camera): void;
  65768. /** @hidden */
  65769. _detachCameras(cameras: Nullable<Camera[]>): void;
  65770. /** @hidden */
  65771. _update(): void;
  65772. /** @hidden */
  65773. _reset(): void;
  65774. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65775. /**
  65776. * Disposes of the pipeline
  65777. */
  65778. dispose(): void;
  65779. }
  65780. }
  65781. declare module BABYLON {
  65782. /**
  65783. * PostProcessRenderPipelineManager class
  65784. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65785. */
  65786. export class PostProcessRenderPipelineManager {
  65787. private _renderPipelines;
  65788. /**
  65789. * Initializes a PostProcessRenderPipelineManager
  65790. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65791. */
  65792. constructor();
  65793. /**
  65794. * Gets the list of supported render pipelines
  65795. */
  65796. get supportedPipelines(): PostProcessRenderPipeline[];
  65797. /**
  65798. * Adds a pipeline to the manager
  65799. * @param renderPipeline The pipeline to add
  65800. */
  65801. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65802. /**
  65803. * Attaches a camera to the pipeline
  65804. * @param renderPipelineName The name of the pipeline to attach to
  65805. * @param cameras the camera to attach
  65806. * @param unique if the camera can be attached multiple times to the pipeline
  65807. */
  65808. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65809. /**
  65810. * Detaches a camera from the pipeline
  65811. * @param renderPipelineName The name of the pipeline to detach from
  65812. * @param cameras the camera to detach
  65813. */
  65814. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65815. /**
  65816. * Enables an effect by name on a pipeline
  65817. * @param renderPipelineName the name of the pipeline to enable the effect in
  65818. * @param renderEffectName the name of the effect to enable
  65819. * @param cameras the cameras that the effect should be enabled on
  65820. */
  65821. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65822. /**
  65823. * Disables an effect by name on a pipeline
  65824. * @param renderPipelineName the name of the pipeline to disable the effect in
  65825. * @param renderEffectName the name of the effect to disable
  65826. * @param cameras the cameras that the effect should be disabled on
  65827. */
  65828. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65829. /**
  65830. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65831. */
  65832. update(): void;
  65833. /** @hidden */
  65834. _rebuild(): void;
  65835. /**
  65836. * Disposes of the manager and pipelines
  65837. */
  65838. dispose(): void;
  65839. }
  65840. }
  65841. declare module BABYLON {
  65842. interface Scene {
  65843. /** @hidden (Backing field) */
  65844. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65845. /**
  65846. * Gets the postprocess render pipeline manager
  65847. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65848. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65849. */
  65850. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65851. }
  65852. /**
  65853. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65854. */
  65855. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65856. /**
  65857. * The component name helpfull to identify the component in the list of scene components.
  65858. */
  65859. readonly name: string;
  65860. /**
  65861. * The scene the component belongs to.
  65862. */
  65863. scene: Scene;
  65864. /**
  65865. * Creates a new instance of the component for the given scene
  65866. * @param scene Defines the scene to register the component in
  65867. */
  65868. constructor(scene: Scene);
  65869. /**
  65870. * Registers the component in a given scene
  65871. */
  65872. register(): void;
  65873. /**
  65874. * Rebuilds the elements related to this component in case of
  65875. * context lost for instance.
  65876. */
  65877. rebuild(): void;
  65878. /**
  65879. * Disposes the component and the associated ressources
  65880. */
  65881. dispose(): void;
  65882. private _gatherRenderTargets;
  65883. }
  65884. }
  65885. declare module BABYLON {
  65886. /**
  65887. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65888. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65889. */
  65890. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65891. private _scene;
  65892. private _camerasToBeAttached;
  65893. /**
  65894. * ID of the sharpen post process,
  65895. */
  65896. private readonly SharpenPostProcessId;
  65897. /**
  65898. * @ignore
  65899. * ID of the image processing post process;
  65900. */
  65901. readonly ImageProcessingPostProcessId: string;
  65902. /**
  65903. * @ignore
  65904. * ID of the Fast Approximate Anti-Aliasing post process;
  65905. */
  65906. readonly FxaaPostProcessId: string;
  65907. /**
  65908. * ID of the chromatic aberration post process,
  65909. */
  65910. private readonly ChromaticAberrationPostProcessId;
  65911. /**
  65912. * ID of the grain post process
  65913. */
  65914. private readonly GrainPostProcessId;
  65915. /**
  65916. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65917. */
  65918. sharpen: SharpenPostProcess;
  65919. private _sharpenEffect;
  65920. private bloom;
  65921. /**
  65922. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65923. */
  65924. depthOfField: DepthOfFieldEffect;
  65925. /**
  65926. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65927. */
  65928. fxaa: FxaaPostProcess;
  65929. /**
  65930. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65931. */
  65932. imageProcessing: ImageProcessingPostProcess;
  65933. /**
  65934. * Chromatic aberration post process which will shift rgb colors in the image
  65935. */
  65936. chromaticAberration: ChromaticAberrationPostProcess;
  65937. private _chromaticAberrationEffect;
  65938. /**
  65939. * Grain post process which add noise to the image
  65940. */
  65941. grain: GrainPostProcess;
  65942. private _grainEffect;
  65943. /**
  65944. * Glow post process which adds a glow to emissive areas of the image
  65945. */
  65946. private _glowLayer;
  65947. /**
  65948. * Animations which can be used to tweak settings over a period of time
  65949. */
  65950. animations: Animation[];
  65951. private _imageProcessingConfigurationObserver;
  65952. private _sharpenEnabled;
  65953. private _bloomEnabled;
  65954. private _depthOfFieldEnabled;
  65955. private _depthOfFieldBlurLevel;
  65956. private _fxaaEnabled;
  65957. private _imageProcessingEnabled;
  65958. private _defaultPipelineTextureType;
  65959. private _bloomScale;
  65960. private _chromaticAberrationEnabled;
  65961. private _grainEnabled;
  65962. private _buildAllowed;
  65963. /**
  65964. * Gets active scene
  65965. */
  65966. get scene(): Scene;
  65967. /**
  65968. * Enable or disable the sharpen process from the pipeline
  65969. */
  65970. set sharpenEnabled(enabled: boolean);
  65971. get sharpenEnabled(): boolean;
  65972. private _resizeObserver;
  65973. private _hardwareScaleLevel;
  65974. private _bloomKernel;
  65975. /**
  65976. * Specifies the size of the bloom blur kernel, relative to the final output size
  65977. */
  65978. get bloomKernel(): number;
  65979. set bloomKernel(value: number);
  65980. /**
  65981. * Specifies the weight of the bloom in the final rendering
  65982. */
  65983. private _bloomWeight;
  65984. /**
  65985. * Specifies the luma threshold for the area that will be blurred by the bloom
  65986. */
  65987. private _bloomThreshold;
  65988. private _hdr;
  65989. /**
  65990. * The strength of the bloom.
  65991. */
  65992. set bloomWeight(value: number);
  65993. get bloomWeight(): number;
  65994. /**
  65995. * The strength of the bloom.
  65996. */
  65997. set bloomThreshold(value: number);
  65998. get bloomThreshold(): number;
  65999. /**
  66000. * The scale of the bloom, lower value will provide better performance.
  66001. */
  66002. set bloomScale(value: number);
  66003. get bloomScale(): number;
  66004. /**
  66005. * Enable or disable the bloom from the pipeline
  66006. */
  66007. set bloomEnabled(enabled: boolean);
  66008. get bloomEnabled(): boolean;
  66009. private _rebuildBloom;
  66010. /**
  66011. * If the depth of field is enabled.
  66012. */
  66013. get depthOfFieldEnabled(): boolean;
  66014. set depthOfFieldEnabled(enabled: boolean);
  66015. /**
  66016. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66017. */
  66018. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66019. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66020. /**
  66021. * If the anti aliasing is enabled.
  66022. */
  66023. set fxaaEnabled(enabled: boolean);
  66024. get fxaaEnabled(): boolean;
  66025. private _samples;
  66026. /**
  66027. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66028. */
  66029. set samples(sampleCount: number);
  66030. get samples(): number;
  66031. /**
  66032. * If image processing is enabled.
  66033. */
  66034. set imageProcessingEnabled(enabled: boolean);
  66035. get imageProcessingEnabled(): boolean;
  66036. /**
  66037. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66038. */
  66039. set glowLayerEnabled(enabled: boolean);
  66040. get glowLayerEnabled(): boolean;
  66041. /**
  66042. * Gets the glow layer (or null if not defined)
  66043. */
  66044. get glowLayer(): Nullable<GlowLayer>;
  66045. /**
  66046. * Enable or disable the chromaticAberration process from the pipeline
  66047. */
  66048. set chromaticAberrationEnabled(enabled: boolean);
  66049. get chromaticAberrationEnabled(): boolean;
  66050. /**
  66051. * Enable or disable the grain process from the pipeline
  66052. */
  66053. set grainEnabled(enabled: boolean);
  66054. get grainEnabled(): boolean;
  66055. /**
  66056. * @constructor
  66057. * @param name - The rendering pipeline name (default: "")
  66058. * @param hdr - If high dynamic range textures should be used (default: true)
  66059. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66060. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66061. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66062. */
  66063. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66064. /**
  66065. * Get the class name
  66066. * @returns "DefaultRenderingPipeline"
  66067. */
  66068. getClassName(): string;
  66069. /**
  66070. * Force the compilation of the entire pipeline.
  66071. */
  66072. prepare(): void;
  66073. private _hasCleared;
  66074. private _prevPostProcess;
  66075. private _prevPrevPostProcess;
  66076. private _setAutoClearAndTextureSharing;
  66077. private _depthOfFieldSceneObserver;
  66078. private _buildPipeline;
  66079. private _disposePostProcesses;
  66080. /**
  66081. * Adds a camera to the pipeline
  66082. * @param camera the camera to be added
  66083. */
  66084. addCamera(camera: Camera): void;
  66085. /**
  66086. * Removes a camera from the pipeline
  66087. * @param camera the camera to remove
  66088. */
  66089. removeCamera(camera: Camera): void;
  66090. /**
  66091. * Dispose of the pipeline and stop all post processes
  66092. */
  66093. dispose(): void;
  66094. /**
  66095. * Serialize the rendering pipeline (Used when exporting)
  66096. * @returns the serialized object
  66097. */
  66098. serialize(): any;
  66099. /**
  66100. * Parse the serialized pipeline
  66101. * @param source Source pipeline.
  66102. * @param scene The scene to load the pipeline to.
  66103. * @param rootUrl The URL of the serialized pipeline.
  66104. * @returns An instantiated pipeline from the serialized object.
  66105. */
  66106. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66107. }
  66108. }
  66109. declare module BABYLON {
  66110. /** @hidden */
  66111. export var lensHighlightsPixelShader: {
  66112. name: string;
  66113. shader: string;
  66114. };
  66115. }
  66116. declare module BABYLON {
  66117. /** @hidden */
  66118. export var depthOfFieldPixelShader: {
  66119. name: string;
  66120. shader: string;
  66121. };
  66122. }
  66123. declare module BABYLON {
  66124. /**
  66125. * BABYLON.JS Chromatic Aberration GLSL Shader
  66126. * Author: Olivier Guyot
  66127. * Separates very slightly R, G and B colors on the edges of the screen
  66128. * Inspired by Francois Tarlier & Martins Upitis
  66129. */
  66130. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66131. /**
  66132. * @ignore
  66133. * The chromatic aberration PostProcess id in the pipeline
  66134. */
  66135. LensChromaticAberrationEffect: string;
  66136. /**
  66137. * @ignore
  66138. * The highlights enhancing PostProcess id in the pipeline
  66139. */
  66140. HighlightsEnhancingEffect: string;
  66141. /**
  66142. * @ignore
  66143. * The depth-of-field PostProcess id in the pipeline
  66144. */
  66145. LensDepthOfFieldEffect: string;
  66146. private _scene;
  66147. private _depthTexture;
  66148. private _grainTexture;
  66149. private _chromaticAberrationPostProcess;
  66150. private _highlightsPostProcess;
  66151. private _depthOfFieldPostProcess;
  66152. private _edgeBlur;
  66153. private _grainAmount;
  66154. private _chromaticAberration;
  66155. private _distortion;
  66156. private _highlightsGain;
  66157. private _highlightsThreshold;
  66158. private _dofDistance;
  66159. private _dofAperture;
  66160. private _dofDarken;
  66161. private _dofPentagon;
  66162. private _blurNoise;
  66163. /**
  66164. * @constructor
  66165. *
  66166. * Effect parameters are as follow:
  66167. * {
  66168. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66169. * edge_blur: number; // from 0 to x (1 for realism)
  66170. * distortion: number; // from 0 to x (1 for realism)
  66171. * grain_amount: number; // from 0 to 1
  66172. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66173. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66174. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66175. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66176. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66177. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66178. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66179. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66180. * }
  66181. * Note: if an effect parameter is unset, effect is disabled
  66182. *
  66183. * @param name The rendering pipeline name
  66184. * @param parameters - An object containing all parameters (see above)
  66185. * @param scene The scene linked to this pipeline
  66186. * @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)
  66187. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66188. */
  66189. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66190. /**
  66191. * Get the class name
  66192. * @returns "LensRenderingPipeline"
  66193. */
  66194. getClassName(): string;
  66195. /**
  66196. * Gets associated scene
  66197. */
  66198. get scene(): Scene;
  66199. /**
  66200. * Gets or sets the edge blur
  66201. */
  66202. get edgeBlur(): number;
  66203. set edgeBlur(value: number);
  66204. /**
  66205. * Gets or sets the grain amount
  66206. */
  66207. get grainAmount(): number;
  66208. set grainAmount(value: number);
  66209. /**
  66210. * Gets or sets the chromatic aberration amount
  66211. */
  66212. get chromaticAberration(): number;
  66213. set chromaticAberration(value: number);
  66214. /**
  66215. * Gets or sets the depth of field aperture
  66216. */
  66217. get dofAperture(): number;
  66218. set dofAperture(value: number);
  66219. /**
  66220. * Gets or sets the edge distortion
  66221. */
  66222. get edgeDistortion(): number;
  66223. set edgeDistortion(value: number);
  66224. /**
  66225. * Gets or sets the depth of field distortion
  66226. */
  66227. get dofDistortion(): number;
  66228. set dofDistortion(value: number);
  66229. /**
  66230. * Gets or sets the darken out of focus amount
  66231. */
  66232. get darkenOutOfFocus(): number;
  66233. set darkenOutOfFocus(value: number);
  66234. /**
  66235. * Gets or sets a boolean indicating if blur noise is enabled
  66236. */
  66237. get blurNoise(): boolean;
  66238. set blurNoise(value: boolean);
  66239. /**
  66240. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66241. */
  66242. get pentagonBokeh(): boolean;
  66243. set pentagonBokeh(value: boolean);
  66244. /**
  66245. * Gets or sets the highlight grain amount
  66246. */
  66247. get highlightsGain(): number;
  66248. set highlightsGain(value: number);
  66249. /**
  66250. * Gets or sets the highlight threshold
  66251. */
  66252. get highlightsThreshold(): number;
  66253. set highlightsThreshold(value: number);
  66254. /**
  66255. * Sets the amount of blur at the edges
  66256. * @param amount blur amount
  66257. */
  66258. setEdgeBlur(amount: number): void;
  66259. /**
  66260. * Sets edge blur to 0
  66261. */
  66262. disableEdgeBlur(): void;
  66263. /**
  66264. * Sets the amout of grain
  66265. * @param amount Amount of grain
  66266. */
  66267. setGrainAmount(amount: number): void;
  66268. /**
  66269. * Set grain amount to 0
  66270. */
  66271. disableGrain(): void;
  66272. /**
  66273. * Sets the chromatic aberration amount
  66274. * @param amount amount of chromatic aberration
  66275. */
  66276. setChromaticAberration(amount: number): void;
  66277. /**
  66278. * Sets chromatic aberration amount to 0
  66279. */
  66280. disableChromaticAberration(): void;
  66281. /**
  66282. * Sets the EdgeDistortion amount
  66283. * @param amount amount of EdgeDistortion
  66284. */
  66285. setEdgeDistortion(amount: number): void;
  66286. /**
  66287. * Sets edge distortion to 0
  66288. */
  66289. disableEdgeDistortion(): void;
  66290. /**
  66291. * Sets the FocusDistance amount
  66292. * @param amount amount of FocusDistance
  66293. */
  66294. setFocusDistance(amount: number): void;
  66295. /**
  66296. * Disables depth of field
  66297. */
  66298. disableDepthOfField(): void;
  66299. /**
  66300. * Sets the Aperture amount
  66301. * @param amount amount of Aperture
  66302. */
  66303. setAperture(amount: number): void;
  66304. /**
  66305. * Sets the DarkenOutOfFocus amount
  66306. * @param amount amount of DarkenOutOfFocus
  66307. */
  66308. setDarkenOutOfFocus(amount: number): void;
  66309. private _pentagonBokehIsEnabled;
  66310. /**
  66311. * Creates a pentagon bokeh effect
  66312. */
  66313. enablePentagonBokeh(): void;
  66314. /**
  66315. * Disables the pentagon bokeh effect
  66316. */
  66317. disablePentagonBokeh(): void;
  66318. /**
  66319. * Enables noise blur
  66320. */
  66321. enableNoiseBlur(): void;
  66322. /**
  66323. * Disables noise blur
  66324. */
  66325. disableNoiseBlur(): void;
  66326. /**
  66327. * Sets the HighlightsGain amount
  66328. * @param amount amount of HighlightsGain
  66329. */
  66330. setHighlightsGain(amount: number): void;
  66331. /**
  66332. * Sets the HighlightsThreshold amount
  66333. * @param amount amount of HighlightsThreshold
  66334. */
  66335. setHighlightsThreshold(amount: number): void;
  66336. /**
  66337. * Disables highlights
  66338. */
  66339. disableHighlights(): void;
  66340. /**
  66341. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66342. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66343. */
  66344. dispose(disableDepthRender?: boolean): void;
  66345. private _createChromaticAberrationPostProcess;
  66346. private _createHighlightsPostProcess;
  66347. private _createDepthOfFieldPostProcess;
  66348. private _createGrainTexture;
  66349. }
  66350. }
  66351. declare module BABYLON {
  66352. /** @hidden */
  66353. export var ssao2PixelShader: {
  66354. name: string;
  66355. shader: string;
  66356. };
  66357. }
  66358. declare module BABYLON {
  66359. /** @hidden */
  66360. export var ssaoCombinePixelShader: {
  66361. name: string;
  66362. shader: string;
  66363. };
  66364. }
  66365. declare module BABYLON {
  66366. /**
  66367. * Render pipeline to produce ssao effect
  66368. */
  66369. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66370. /**
  66371. * @ignore
  66372. * The PassPostProcess id in the pipeline that contains the original scene color
  66373. */
  66374. SSAOOriginalSceneColorEffect: string;
  66375. /**
  66376. * @ignore
  66377. * The SSAO PostProcess id in the pipeline
  66378. */
  66379. SSAORenderEffect: string;
  66380. /**
  66381. * @ignore
  66382. * The horizontal blur PostProcess id in the pipeline
  66383. */
  66384. SSAOBlurHRenderEffect: string;
  66385. /**
  66386. * @ignore
  66387. * The vertical blur PostProcess id in the pipeline
  66388. */
  66389. SSAOBlurVRenderEffect: string;
  66390. /**
  66391. * @ignore
  66392. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66393. */
  66394. SSAOCombineRenderEffect: string;
  66395. /**
  66396. * The output strength of the SSAO post-process. Default value is 1.0.
  66397. */
  66398. totalStrength: number;
  66399. /**
  66400. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66401. */
  66402. maxZ: number;
  66403. /**
  66404. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66405. */
  66406. minZAspect: number;
  66407. private _samples;
  66408. /**
  66409. * Number of samples used for the SSAO calculations. Default value is 8
  66410. */
  66411. set samples(n: number);
  66412. get samples(): number;
  66413. private _textureSamples;
  66414. /**
  66415. * Number of samples to use for antialiasing
  66416. */
  66417. set textureSamples(n: number);
  66418. get textureSamples(): number;
  66419. /**
  66420. * Ratio object used for SSAO ratio and blur ratio
  66421. */
  66422. private _ratio;
  66423. /**
  66424. * Dynamically generated sphere sampler.
  66425. */
  66426. private _sampleSphere;
  66427. /**
  66428. * Blur filter offsets
  66429. */
  66430. private _samplerOffsets;
  66431. private _expensiveBlur;
  66432. /**
  66433. * If bilateral blur should be used
  66434. */
  66435. set expensiveBlur(b: boolean);
  66436. get expensiveBlur(): boolean;
  66437. /**
  66438. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66439. */
  66440. radius: number;
  66441. /**
  66442. * The base color of the SSAO post-process
  66443. * The final result is "base + ssao" between [0, 1]
  66444. */
  66445. base: number;
  66446. /**
  66447. * Support test.
  66448. */
  66449. static get IsSupported(): boolean;
  66450. private _scene;
  66451. private _depthTexture;
  66452. private _normalTexture;
  66453. private _randomTexture;
  66454. private _originalColorPostProcess;
  66455. private _ssaoPostProcess;
  66456. private _blurHPostProcess;
  66457. private _blurVPostProcess;
  66458. private _ssaoCombinePostProcess;
  66459. /**
  66460. * Gets active scene
  66461. */
  66462. get scene(): Scene;
  66463. /**
  66464. * @constructor
  66465. * @param name The rendering pipeline name
  66466. * @param scene The scene linked to this pipeline
  66467. * @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 }
  66468. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66469. */
  66470. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66471. /**
  66472. * Get the class name
  66473. * @returns "SSAO2RenderingPipeline"
  66474. */
  66475. getClassName(): string;
  66476. /**
  66477. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66478. */
  66479. dispose(disableGeometryBufferRenderer?: boolean): void;
  66480. private _createBlurPostProcess;
  66481. /** @hidden */
  66482. _rebuild(): void;
  66483. private _bits;
  66484. private _radicalInverse_VdC;
  66485. private _hammersley;
  66486. private _hemisphereSample_uniform;
  66487. private _generateHemisphere;
  66488. private _createSSAOPostProcess;
  66489. private _createSSAOCombinePostProcess;
  66490. private _createRandomTexture;
  66491. /**
  66492. * Serialize the rendering pipeline (Used when exporting)
  66493. * @returns the serialized object
  66494. */
  66495. serialize(): any;
  66496. /**
  66497. * Parse the serialized pipeline
  66498. * @param source Source pipeline.
  66499. * @param scene The scene to load the pipeline to.
  66500. * @param rootUrl The URL of the serialized pipeline.
  66501. * @returns An instantiated pipeline from the serialized object.
  66502. */
  66503. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66504. }
  66505. }
  66506. declare module BABYLON {
  66507. /** @hidden */
  66508. export var ssaoPixelShader: {
  66509. name: string;
  66510. shader: string;
  66511. };
  66512. }
  66513. declare module BABYLON {
  66514. /**
  66515. * Render pipeline to produce ssao effect
  66516. */
  66517. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66518. /**
  66519. * @ignore
  66520. * The PassPostProcess id in the pipeline that contains the original scene color
  66521. */
  66522. SSAOOriginalSceneColorEffect: string;
  66523. /**
  66524. * @ignore
  66525. * The SSAO PostProcess id in the pipeline
  66526. */
  66527. SSAORenderEffect: string;
  66528. /**
  66529. * @ignore
  66530. * The horizontal blur PostProcess id in the pipeline
  66531. */
  66532. SSAOBlurHRenderEffect: string;
  66533. /**
  66534. * @ignore
  66535. * The vertical blur PostProcess id in the pipeline
  66536. */
  66537. SSAOBlurVRenderEffect: string;
  66538. /**
  66539. * @ignore
  66540. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66541. */
  66542. SSAOCombineRenderEffect: string;
  66543. /**
  66544. * The output strength of the SSAO post-process. Default value is 1.0.
  66545. */
  66546. totalStrength: number;
  66547. /**
  66548. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66549. */
  66550. radius: number;
  66551. /**
  66552. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66553. * Must not be equal to fallOff and superior to fallOff.
  66554. * Default value is 0.0075
  66555. */
  66556. area: number;
  66557. /**
  66558. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66559. * Must not be equal to area and inferior to area.
  66560. * Default value is 0.000001
  66561. */
  66562. fallOff: number;
  66563. /**
  66564. * The base color of the SSAO post-process
  66565. * The final result is "base + ssao" between [0, 1]
  66566. */
  66567. base: number;
  66568. private _scene;
  66569. private _depthTexture;
  66570. private _randomTexture;
  66571. private _originalColorPostProcess;
  66572. private _ssaoPostProcess;
  66573. private _blurHPostProcess;
  66574. private _blurVPostProcess;
  66575. private _ssaoCombinePostProcess;
  66576. private _firstUpdate;
  66577. /**
  66578. * Gets active scene
  66579. */
  66580. get scene(): Scene;
  66581. /**
  66582. * @constructor
  66583. * @param name - The rendering pipeline name
  66584. * @param scene - The scene linked to this pipeline
  66585. * @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 }
  66586. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66587. */
  66588. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66589. /**
  66590. * Get the class name
  66591. * @returns "SSAORenderingPipeline"
  66592. */
  66593. getClassName(): string;
  66594. /**
  66595. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66596. */
  66597. dispose(disableDepthRender?: boolean): void;
  66598. private _createBlurPostProcess;
  66599. /** @hidden */
  66600. _rebuild(): void;
  66601. private _createSSAOPostProcess;
  66602. private _createSSAOCombinePostProcess;
  66603. private _createRandomTexture;
  66604. }
  66605. }
  66606. declare module BABYLON {
  66607. /** @hidden */
  66608. export var screenSpaceReflectionPixelShader: {
  66609. name: string;
  66610. shader: string;
  66611. };
  66612. }
  66613. declare module BABYLON {
  66614. /**
  66615. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66616. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66617. */
  66618. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66619. /**
  66620. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66621. */
  66622. threshold: number;
  66623. /**
  66624. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66625. */
  66626. strength: number;
  66627. /**
  66628. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66629. */
  66630. reflectionSpecularFalloffExponent: number;
  66631. /**
  66632. * 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]
  66633. */
  66634. step: number;
  66635. /**
  66636. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66637. */
  66638. roughnessFactor: number;
  66639. private _geometryBufferRenderer;
  66640. private _enableSmoothReflections;
  66641. private _reflectionSamples;
  66642. private _smoothSteps;
  66643. /**
  66644. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66645. * @param name The name of the effect.
  66646. * @param scene The scene containing the objects to calculate reflections.
  66647. * @param options The required width/height ratio to downsize to before computing the render pass.
  66648. * @param camera The camera to apply the render pass to.
  66649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66650. * @param engine The engine which the post process will be applied. (default: current engine)
  66651. * @param reusable If the post process can be reused on the same frame. (default: false)
  66652. * @param textureType Type of textures used when performing the post process. (default: 0)
  66653. * @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)
  66654. */
  66655. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66656. /**
  66657. * Gets wether or not smoothing reflections is enabled.
  66658. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66659. */
  66660. get enableSmoothReflections(): boolean;
  66661. /**
  66662. * Sets wether or not smoothing reflections is enabled.
  66663. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66664. */
  66665. set enableSmoothReflections(enabled: boolean);
  66666. /**
  66667. * Gets the number of samples taken while computing reflections. More samples count is high,
  66668. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66669. */
  66670. get reflectionSamples(): number;
  66671. /**
  66672. * Sets the number of samples taken while computing reflections. More samples count is high,
  66673. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66674. */
  66675. set reflectionSamples(samples: number);
  66676. /**
  66677. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66678. * more the post-process will require GPU power and can generate a drop in FPS.
  66679. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66680. */
  66681. get smoothSteps(): number;
  66682. set smoothSteps(steps: number);
  66683. private _updateEffectDefines;
  66684. }
  66685. }
  66686. declare module BABYLON {
  66687. /** @hidden */
  66688. export var standardPixelShader: {
  66689. name: string;
  66690. shader: string;
  66691. };
  66692. }
  66693. declare module BABYLON {
  66694. /**
  66695. * Standard rendering pipeline
  66696. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66697. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66698. */
  66699. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66700. /**
  66701. * Public members
  66702. */
  66703. /**
  66704. * Post-process which contains the original scene color before the pipeline applies all the effects
  66705. */
  66706. originalPostProcess: Nullable<PostProcess>;
  66707. /**
  66708. * Post-process used to down scale an image x4
  66709. */
  66710. downSampleX4PostProcess: Nullable<PostProcess>;
  66711. /**
  66712. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66713. */
  66714. brightPassPostProcess: Nullable<PostProcess>;
  66715. /**
  66716. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66717. */
  66718. blurHPostProcesses: PostProcess[];
  66719. /**
  66720. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66721. */
  66722. blurVPostProcesses: PostProcess[];
  66723. /**
  66724. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66725. */
  66726. textureAdderPostProcess: Nullable<PostProcess>;
  66727. /**
  66728. * Post-process used to create volumetric lighting effect
  66729. */
  66730. volumetricLightPostProcess: Nullable<PostProcess>;
  66731. /**
  66732. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66733. */
  66734. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66735. /**
  66736. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66737. */
  66738. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66739. /**
  66740. * Post-process used to merge the volumetric light effect and the real scene color
  66741. */
  66742. volumetricLightMergePostProces: Nullable<PostProcess>;
  66743. /**
  66744. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66745. */
  66746. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66747. /**
  66748. * Base post-process used to calculate the average luminance of the final image for HDR
  66749. */
  66750. luminancePostProcess: Nullable<PostProcess>;
  66751. /**
  66752. * Post-processes used to create down sample post-processes in order to get
  66753. * the average luminance of the final image for HDR
  66754. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66755. */
  66756. luminanceDownSamplePostProcesses: PostProcess[];
  66757. /**
  66758. * Post-process used to create a HDR effect (light adaptation)
  66759. */
  66760. hdrPostProcess: Nullable<PostProcess>;
  66761. /**
  66762. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66763. */
  66764. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66765. /**
  66766. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66767. */
  66768. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66769. /**
  66770. * Post-process used to merge the final HDR post-process and the real scene color
  66771. */
  66772. hdrFinalPostProcess: Nullable<PostProcess>;
  66773. /**
  66774. * Post-process used to create a lens flare effect
  66775. */
  66776. lensFlarePostProcess: Nullable<PostProcess>;
  66777. /**
  66778. * Post-process that merges the result of the lens flare post-process and the real scene color
  66779. */
  66780. lensFlareComposePostProcess: Nullable<PostProcess>;
  66781. /**
  66782. * Post-process used to create a motion blur effect
  66783. */
  66784. motionBlurPostProcess: Nullable<PostProcess>;
  66785. /**
  66786. * Post-process used to create a depth of field effect
  66787. */
  66788. depthOfFieldPostProcess: Nullable<PostProcess>;
  66789. /**
  66790. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66791. */
  66792. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66793. /**
  66794. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66795. */
  66796. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66797. /**
  66798. * Represents the brightness threshold in order to configure the illuminated surfaces
  66799. */
  66800. brightThreshold: number;
  66801. /**
  66802. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66803. */
  66804. blurWidth: number;
  66805. /**
  66806. * Sets if the blur for highlighted surfaces must be only horizontal
  66807. */
  66808. horizontalBlur: boolean;
  66809. /**
  66810. * Gets the overall exposure used by the pipeline
  66811. */
  66812. get exposure(): number;
  66813. /**
  66814. * Sets the overall exposure used by the pipeline
  66815. */
  66816. set exposure(value: number);
  66817. /**
  66818. * Texture used typically to simulate "dirty" on camera lens
  66819. */
  66820. lensTexture: Nullable<Texture>;
  66821. /**
  66822. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66823. */
  66824. volumetricLightCoefficient: number;
  66825. /**
  66826. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66827. */
  66828. volumetricLightPower: number;
  66829. /**
  66830. * Used the set the blur intensity to smooth the volumetric lights
  66831. */
  66832. volumetricLightBlurScale: number;
  66833. /**
  66834. * Light (spot or directional) used to generate the volumetric lights rays
  66835. * The source light must have a shadow generate so the pipeline can get its
  66836. * depth map
  66837. */
  66838. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66839. /**
  66840. * For eye adaptation, represents the minimum luminance the eye can see
  66841. */
  66842. hdrMinimumLuminance: number;
  66843. /**
  66844. * For eye adaptation, represents the decrease luminance speed
  66845. */
  66846. hdrDecreaseRate: number;
  66847. /**
  66848. * For eye adaptation, represents the increase luminance speed
  66849. */
  66850. hdrIncreaseRate: number;
  66851. /**
  66852. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66853. */
  66854. get hdrAutoExposure(): boolean;
  66855. /**
  66856. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66857. */
  66858. set hdrAutoExposure(value: boolean);
  66859. /**
  66860. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66861. */
  66862. lensColorTexture: Nullable<Texture>;
  66863. /**
  66864. * The overall strengh for the lens flare effect
  66865. */
  66866. lensFlareStrength: number;
  66867. /**
  66868. * Dispersion coefficient for lens flare ghosts
  66869. */
  66870. lensFlareGhostDispersal: number;
  66871. /**
  66872. * Main lens flare halo width
  66873. */
  66874. lensFlareHaloWidth: number;
  66875. /**
  66876. * Based on the lens distortion effect, defines how much the lens flare result
  66877. * is distorted
  66878. */
  66879. lensFlareDistortionStrength: number;
  66880. /**
  66881. * Configures the blur intensity used for for lens flare (halo)
  66882. */
  66883. lensFlareBlurWidth: number;
  66884. /**
  66885. * Lens star texture must be used to simulate rays on the flares and is available
  66886. * in the documentation
  66887. */
  66888. lensStarTexture: Nullable<Texture>;
  66889. /**
  66890. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66891. * flare effect by taking account of the dirt texture
  66892. */
  66893. lensFlareDirtTexture: Nullable<Texture>;
  66894. /**
  66895. * Represents the focal length for the depth of field effect
  66896. */
  66897. depthOfFieldDistance: number;
  66898. /**
  66899. * Represents the blur intensity for the blurred part of the depth of field effect
  66900. */
  66901. depthOfFieldBlurWidth: number;
  66902. /**
  66903. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66904. */
  66905. get motionStrength(): number;
  66906. /**
  66907. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66908. */
  66909. set motionStrength(strength: number);
  66910. /**
  66911. * Gets wether or not the motion blur post-process is object based or screen based.
  66912. */
  66913. get objectBasedMotionBlur(): boolean;
  66914. /**
  66915. * Sets wether or not the motion blur post-process should be object based or screen based
  66916. */
  66917. set objectBasedMotionBlur(value: boolean);
  66918. /**
  66919. * List of animations for the pipeline (IAnimatable implementation)
  66920. */
  66921. animations: Animation[];
  66922. /**
  66923. * Private members
  66924. */
  66925. private _scene;
  66926. private _currentDepthOfFieldSource;
  66927. private _basePostProcess;
  66928. private _fixedExposure;
  66929. private _currentExposure;
  66930. private _hdrAutoExposure;
  66931. private _hdrCurrentLuminance;
  66932. private _motionStrength;
  66933. private _isObjectBasedMotionBlur;
  66934. private _floatTextureType;
  66935. private _camerasToBeAttached;
  66936. private _ratio;
  66937. private _bloomEnabled;
  66938. private _depthOfFieldEnabled;
  66939. private _vlsEnabled;
  66940. private _lensFlareEnabled;
  66941. private _hdrEnabled;
  66942. private _motionBlurEnabled;
  66943. private _fxaaEnabled;
  66944. private _screenSpaceReflectionsEnabled;
  66945. private _motionBlurSamples;
  66946. private _volumetricLightStepsCount;
  66947. private _samples;
  66948. /**
  66949. * @ignore
  66950. * Specifies if the bloom pipeline is enabled
  66951. */
  66952. get BloomEnabled(): boolean;
  66953. set BloomEnabled(enabled: boolean);
  66954. /**
  66955. * @ignore
  66956. * Specifies if the depth of field pipeline is enabed
  66957. */
  66958. get DepthOfFieldEnabled(): boolean;
  66959. set DepthOfFieldEnabled(enabled: boolean);
  66960. /**
  66961. * @ignore
  66962. * Specifies if the lens flare pipeline is enabed
  66963. */
  66964. get LensFlareEnabled(): boolean;
  66965. set LensFlareEnabled(enabled: boolean);
  66966. /**
  66967. * @ignore
  66968. * Specifies if the HDR pipeline is enabled
  66969. */
  66970. get HDREnabled(): boolean;
  66971. set HDREnabled(enabled: boolean);
  66972. /**
  66973. * @ignore
  66974. * Specifies if the volumetric lights scattering effect is enabled
  66975. */
  66976. get VLSEnabled(): boolean;
  66977. set VLSEnabled(enabled: boolean);
  66978. /**
  66979. * @ignore
  66980. * Specifies if the motion blur effect is enabled
  66981. */
  66982. get MotionBlurEnabled(): boolean;
  66983. set MotionBlurEnabled(enabled: boolean);
  66984. /**
  66985. * Specifies if anti-aliasing is enabled
  66986. */
  66987. get fxaaEnabled(): boolean;
  66988. set fxaaEnabled(enabled: boolean);
  66989. /**
  66990. * Specifies if screen space reflections are enabled.
  66991. */
  66992. get screenSpaceReflectionsEnabled(): boolean;
  66993. set screenSpaceReflectionsEnabled(enabled: boolean);
  66994. /**
  66995. * Specifies the number of steps used to calculate the volumetric lights
  66996. * Typically in interval [50, 200]
  66997. */
  66998. get volumetricLightStepsCount(): number;
  66999. set volumetricLightStepsCount(count: number);
  67000. /**
  67001. * Specifies the number of samples used for the motion blur effect
  67002. * Typically in interval [16, 64]
  67003. */
  67004. get motionBlurSamples(): number;
  67005. set motionBlurSamples(samples: number);
  67006. /**
  67007. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67008. */
  67009. get samples(): number;
  67010. set samples(sampleCount: number);
  67011. /**
  67012. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67013. * @constructor
  67014. * @param name The rendering pipeline name
  67015. * @param scene The scene linked to this pipeline
  67016. * @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)
  67017. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67018. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67019. */
  67020. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67021. private _buildPipeline;
  67022. private _createDownSampleX4PostProcess;
  67023. private _createBrightPassPostProcess;
  67024. private _createBlurPostProcesses;
  67025. private _createTextureAdderPostProcess;
  67026. private _createVolumetricLightPostProcess;
  67027. private _createLuminancePostProcesses;
  67028. private _createHdrPostProcess;
  67029. private _createLensFlarePostProcess;
  67030. private _createDepthOfFieldPostProcess;
  67031. private _createMotionBlurPostProcess;
  67032. private _getDepthTexture;
  67033. private _disposePostProcesses;
  67034. /**
  67035. * Dispose of the pipeline and stop all post processes
  67036. */
  67037. dispose(): void;
  67038. /**
  67039. * Serialize the rendering pipeline (Used when exporting)
  67040. * @returns the serialized object
  67041. */
  67042. serialize(): any;
  67043. /**
  67044. * Parse the serialized pipeline
  67045. * @param source Source pipeline.
  67046. * @param scene The scene to load the pipeline to.
  67047. * @param rootUrl The URL of the serialized pipeline.
  67048. * @returns An instantiated pipeline from the serialized object.
  67049. */
  67050. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67051. /**
  67052. * Luminance steps
  67053. */
  67054. static LuminanceSteps: number;
  67055. }
  67056. }
  67057. declare module BABYLON {
  67058. /** @hidden */
  67059. export var tonemapPixelShader: {
  67060. name: string;
  67061. shader: string;
  67062. };
  67063. }
  67064. declare module BABYLON {
  67065. /** Defines operator used for tonemapping */
  67066. export enum TonemappingOperator {
  67067. /** Hable */
  67068. Hable = 0,
  67069. /** Reinhard */
  67070. Reinhard = 1,
  67071. /** HejiDawson */
  67072. HejiDawson = 2,
  67073. /** Photographic */
  67074. Photographic = 3
  67075. }
  67076. /**
  67077. * Defines a post process to apply tone mapping
  67078. */
  67079. export class TonemapPostProcess extends PostProcess {
  67080. private _operator;
  67081. /** Defines the required exposure adjustement */
  67082. exposureAdjustment: number;
  67083. /**
  67084. * Creates a new TonemapPostProcess
  67085. * @param name defines the name of the postprocess
  67086. * @param _operator defines the operator to use
  67087. * @param exposureAdjustment defines the required exposure adjustement
  67088. * @param camera defines the camera to use (can be null)
  67089. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67090. * @param engine defines the hosting engine (can be ignore if camera is set)
  67091. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67092. */
  67093. constructor(name: string, _operator: TonemappingOperator,
  67094. /** Defines the required exposure adjustement */
  67095. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67096. }
  67097. }
  67098. declare module BABYLON {
  67099. /** @hidden */
  67100. export var volumetricLightScatteringPixelShader: {
  67101. name: string;
  67102. shader: string;
  67103. };
  67104. }
  67105. declare module BABYLON {
  67106. /** @hidden */
  67107. export var volumetricLightScatteringPassVertexShader: {
  67108. name: string;
  67109. shader: string;
  67110. };
  67111. }
  67112. declare module BABYLON {
  67113. /** @hidden */
  67114. export var volumetricLightScatteringPassPixelShader: {
  67115. name: string;
  67116. shader: string;
  67117. };
  67118. }
  67119. declare module BABYLON {
  67120. /**
  67121. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67122. */
  67123. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67124. private _volumetricLightScatteringPass;
  67125. private _volumetricLightScatteringRTT;
  67126. private _viewPort;
  67127. private _screenCoordinates;
  67128. private _cachedDefines;
  67129. /**
  67130. * If not undefined, the mesh position is computed from the attached node position
  67131. */
  67132. attachedNode: {
  67133. position: Vector3;
  67134. };
  67135. /**
  67136. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67137. */
  67138. customMeshPosition: Vector3;
  67139. /**
  67140. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67141. */
  67142. useCustomMeshPosition: boolean;
  67143. /**
  67144. * If the post-process should inverse the light scattering direction
  67145. */
  67146. invert: boolean;
  67147. /**
  67148. * The internal mesh used by the post-process
  67149. */
  67150. mesh: Mesh;
  67151. /**
  67152. * @hidden
  67153. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67154. */
  67155. get useDiffuseColor(): boolean;
  67156. set useDiffuseColor(useDiffuseColor: boolean);
  67157. /**
  67158. * Array containing the excluded meshes not rendered in the internal pass
  67159. */
  67160. excludedMeshes: AbstractMesh[];
  67161. /**
  67162. * Controls the overall intensity of the post-process
  67163. */
  67164. exposure: number;
  67165. /**
  67166. * Dissipates each sample's contribution in range [0, 1]
  67167. */
  67168. decay: number;
  67169. /**
  67170. * Controls the overall intensity of each sample
  67171. */
  67172. weight: number;
  67173. /**
  67174. * Controls the density of each sample
  67175. */
  67176. density: number;
  67177. /**
  67178. * @constructor
  67179. * @param name The post-process name
  67180. * @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)
  67181. * @param camera The camera that the post-process will be attached to
  67182. * @param mesh The mesh used to create the light scattering
  67183. * @param samples The post-process quality, default 100
  67184. * @param samplingModeThe post-process filtering mode
  67185. * @param engine The babylon engine
  67186. * @param reusable If the post-process is reusable
  67187. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67188. */
  67189. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67190. /**
  67191. * Returns the string "VolumetricLightScatteringPostProcess"
  67192. * @returns "VolumetricLightScatteringPostProcess"
  67193. */
  67194. getClassName(): string;
  67195. private _isReady;
  67196. /**
  67197. * Sets the new light position for light scattering effect
  67198. * @param position The new custom light position
  67199. */
  67200. setCustomMeshPosition(position: Vector3): void;
  67201. /**
  67202. * Returns the light position for light scattering effect
  67203. * @return Vector3 The custom light position
  67204. */
  67205. getCustomMeshPosition(): Vector3;
  67206. /**
  67207. * Disposes the internal assets and detaches the post-process from the camera
  67208. */
  67209. dispose(camera: Camera): void;
  67210. /**
  67211. * Returns the render target texture used by the post-process
  67212. * @return the render target texture used by the post-process
  67213. */
  67214. getPass(): RenderTargetTexture;
  67215. private _meshExcluded;
  67216. private _createPass;
  67217. private _updateMeshScreenCoordinates;
  67218. /**
  67219. * Creates a default mesh for the Volumeric Light Scattering post-process
  67220. * @param name The mesh name
  67221. * @param scene The scene where to create the mesh
  67222. * @return the default mesh
  67223. */
  67224. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67225. }
  67226. }
  67227. declare module BABYLON {
  67228. interface Scene {
  67229. /** @hidden (Backing field) */
  67230. _boundingBoxRenderer: BoundingBoxRenderer;
  67231. /** @hidden (Backing field) */
  67232. _forceShowBoundingBoxes: boolean;
  67233. /**
  67234. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67235. */
  67236. forceShowBoundingBoxes: boolean;
  67237. /**
  67238. * Gets the bounding box renderer associated with the scene
  67239. * @returns a BoundingBoxRenderer
  67240. */
  67241. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67242. }
  67243. interface AbstractMesh {
  67244. /** @hidden (Backing field) */
  67245. _showBoundingBox: boolean;
  67246. /**
  67247. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67248. */
  67249. showBoundingBox: boolean;
  67250. }
  67251. /**
  67252. * Component responsible of rendering the bounding box of the meshes in a scene.
  67253. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67254. */
  67255. export class BoundingBoxRenderer implements ISceneComponent {
  67256. /**
  67257. * The component name helpfull to identify the component in the list of scene components.
  67258. */
  67259. readonly name: string;
  67260. /**
  67261. * The scene the component belongs to.
  67262. */
  67263. scene: Scene;
  67264. /**
  67265. * Color of the bounding box lines placed in front of an object
  67266. */
  67267. frontColor: Color3;
  67268. /**
  67269. * Color of the bounding box lines placed behind an object
  67270. */
  67271. backColor: Color3;
  67272. /**
  67273. * Defines if the renderer should show the back lines or not
  67274. */
  67275. showBackLines: boolean;
  67276. /**
  67277. * @hidden
  67278. */
  67279. renderList: SmartArray<BoundingBox>;
  67280. private _colorShader;
  67281. private _vertexBuffers;
  67282. private _indexBuffer;
  67283. private _fillIndexBuffer;
  67284. private _fillIndexData;
  67285. /**
  67286. * Instantiates a new bounding box renderer in a scene.
  67287. * @param scene the scene the renderer renders in
  67288. */
  67289. constructor(scene: Scene);
  67290. /**
  67291. * Registers the component in a given scene
  67292. */
  67293. register(): void;
  67294. private _evaluateSubMesh;
  67295. private _activeMesh;
  67296. private _prepareRessources;
  67297. private _createIndexBuffer;
  67298. /**
  67299. * Rebuilds the elements related to this component in case of
  67300. * context lost for instance.
  67301. */
  67302. rebuild(): void;
  67303. /**
  67304. * @hidden
  67305. */
  67306. reset(): void;
  67307. /**
  67308. * Render the bounding boxes of a specific rendering group
  67309. * @param renderingGroupId defines the rendering group to render
  67310. */
  67311. render(renderingGroupId: number): void;
  67312. /**
  67313. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67314. * @param mesh Define the mesh to render the occlusion bounding box for
  67315. */
  67316. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67317. /**
  67318. * Dispose and release the resources attached to this renderer.
  67319. */
  67320. dispose(): void;
  67321. }
  67322. }
  67323. declare module BABYLON {
  67324. interface Scene {
  67325. /** @hidden (Backing field) */
  67326. _depthRenderer: {
  67327. [id: string]: DepthRenderer;
  67328. };
  67329. /**
  67330. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67331. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67332. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67333. * @returns the created depth renderer
  67334. */
  67335. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67336. /**
  67337. * Disables a depth renderer for a given camera
  67338. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67339. */
  67340. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67341. }
  67342. /**
  67343. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67344. * in several rendering techniques.
  67345. */
  67346. export class DepthRendererSceneComponent implements ISceneComponent {
  67347. /**
  67348. * The component name helpfull to identify the component in the list of scene components.
  67349. */
  67350. readonly name: string;
  67351. /**
  67352. * The scene the component belongs to.
  67353. */
  67354. scene: Scene;
  67355. /**
  67356. * Creates a new instance of the component for the given scene
  67357. * @param scene Defines the scene to register the component in
  67358. */
  67359. constructor(scene: Scene);
  67360. /**
  67361. * Registers the component in a given scene
  67362. */
  67363. register(): void;
  67364. /**
  67365. * Rebuilds the elements related to this component in case of
  67366. * context lost for instance.
  67367. */
  67368. rebuild(): void;
  67369. /**
  67370. * Disposes the component and the associated ressources
  67371. */
  67372. dispose(): void;
  67373. private _gatherRenderTargets;
  67374. private _gatherActiveCameraRenderTargets;
  67375. }
  67376. }
  67377. declare module BABYLON {
  67378. /** @hidden */
  67379. export var outlinePixelShader: {
  67380. name: string;
  67381. shader: string;
  67382. };
  67383. }
  67384. declare module BABYLON {
  67385. /** @hidden */
  67386. export var outlineVertexShader: {
  67387. name: string;
  67388. shader: string;
  67389. };
  67390. }
  67391. declare module BABYLON {
  67392. interface Scene {
  67393. /** @hidden */
  67394. _outlineRenderer: OutlineRenderer;
  67395. /**
  67396. * Gets the outline renderer associated with the scene
  67397. * @returns a OutlineRenderer
  67398. */
  67399. getOutlineRenderer(): OutlineRenderer;
  67400. }
  67401. interface AbstractMesh {
  67402. /** @hidden (Backing field) */
  67403. _renderOutline: boolean;
  67404. /**
  67405. * Gets or sets a boolean indicating if the outline must be rendered as well
  67406. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67407. */
  67408. renderOutline: boolean;
  67409. /** @hidden (Backing field) */
  67410. _renderOverlay: boolean;
  67411. /**
  67412. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67413. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67414. */
  67415. renderOverlay: boolean;
  67416. }
  67417. /**
  67418. * This class is responsible to draw bothe outline/overlay of meshes.
  67419. * It should not be used directly but through the available method on mesh.
  67420. */
  67421. export class OutlineRenderer implements ISceneComponent {
  67422. /**
  67423. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67424. */
  67425. private static _StencilReference;
  67426. /**
  67427. * The name of the component. Each component must have a unique name.
  67428. */
  67429. name: string;
  67430. /**
  67431. * The scene the component belongs to.
  67432. */
  67433. scene: Scene;
  67434. /**
  67435. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67436. */
  67437. zOffset: number;
  67438. private _engine;
  67439. private _effect;
  67440. private _cachedDefines;
  67441. private _savedDepthWrite;
  67442. /**
  67443. * Instantiates a new outline renderer. (There could be only one per scene).
  67444. * @param scene Defines the scene it belongs to
  67445. */
  67446. constructor(scene: Scene);
  67447. /**
  67448. * Register the component to one instance of a scene.
  67449. */
  67450. register(): void;
  67451. /**
  67452. * Rebuilds the elements related to this component in case of
  67453. * context lost for instance.
  67454. */
  67455. rebuild(): void;
  67456. /**
  67457. * Disposes the component and the associated ressources.
  67458. */
  67459. dispose(): void;
  67460. /**
  67461. * Renders the outline in the canvas.
  67462. * @param subMesh Defines the sumesh to render
  67463. * @param batch Defines the batch of meshes in case of instances
  67464. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67465. */
  67466. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67467. /**
  67468. * Returns whether or not the outline renderer is ready for a given submesh.
  67469. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67470. * @param subMesh Defines the submesh to check readyness for
  67471. * @param useInstances Defines wheter wee are trying to render instances or not
  67472. * @returns true if ready otherwise false
  67473. */
  67474. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67475. private _beforeRenderingMesh;
  67476. private _afterRenderingMesh;
  67477. }
  67478. }
  67479. declare module BABYLON {
  67480. /**
  67481. * Defines the basic options interface of a Sprite Frame Source Size.
  67482. */
  67483. export interface ISpriteJSONSpriteSourceSize {
  67484. /**
  67485. * number of the original width of the Frame
  67486. */
  67487. w: number;
  67488. /**
  67489. * number of the original height of the Frame
  67490. */
  67491. h: number;
  67492. }
  67493. /**
  67494. * Defines the basic options interface of a Sprite Frame Data.
  67495. */
  67496. export interface ISpriteJSONSpriteFrameData {
  67497. /**
  67498. * number of the x offset of the Frame
  67499. */
  67500. x: number;
  67501. /**
  67502. * number of the y offset of the Frame
  67503. */
  67504. y: number;
  67505. /**
  67506. * number of the width of the Frame
  67507. */
  67508. w: number;
  67509. /**
  67510. * number of the height of the Frame
  67511. */
  67512. h: number;
  67513. }
  67514. /**
  67515. * Defines the basic options interface of a JSON Sprite.
  67516. */
  67517. export interface ISpriteJSONSprite {
  67518. /**
  67519. * string name of the Frame
  67520. */
  67521. filename: string;
  67522. /**
  67523. * ISpriteJSONSpriteFrame basic object of the frame data
  67524. */
  67525. frame: ISpriteJSONSpriteFrameData;
  67526. /**
  67527. * boolean to flag is the frame was rotated.
  67528. */
  67529. rotated: boolean;
  67530. /**
  67531. * boolean to flag is the frame was trimmed.
  67532. */
  67533. trimmed: boolean;
  67534. /**
  67535. * ISpriteJSONSpriteFrame basic object of the source data
  67536. */
  67537. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67538. /**
  67539. * ISpriteJSONSpriteFrame basic object of the source data
  67540. */
  67541. sourceSize: ISpriteJSONSpriteSourceSize;
  67542. }
  67543. /**
  67544. * Defines the basic options interface of a JSON atlas.
  67545. */
  67546. export interface ISpriteJSONAtlas {
  67547. /**
  67548. * Array of objects that contain the frame data.
  67549. */
  67550. frames: Array<ISpriteJSONSprite>;
  67551. /**
  67552. * object basic object containing the sprite meta data.
  67553. */
  67554. meta?: object;
  67555. }
  67556. }
  67557. declare module BABYLON {
  67558. /** @hidden */
  67559. export var spriteMapPixelShader: {
  67560. name: string;
  67561. shader: string;
  67562. };
  67563. }
  67564. declare module BABYLON {
  67565. /** @hidden */
  67566. export var spriteMapVertexShader: {
  67567. name: string;
  67568. shader: string;
  67569. };
  67570. }
  67571. declare module BABYLON {
  67572. /**
  67573. * Defines the basic options interface of a SpriteMap
  67574. */
  67575. export interface ISpriteMapOptions {
  67576. /**
  67577. * Vector2 of the number of cells in the grid.
  67578. */
  67579. stageSize?: Vector2;
  67580. /**
  67581. * Vector2 of the size of the output plane in World Units.
  67582. */
  67583. outputSize?: Vector2;
  67584. /**
  67585. * Vector3 of the position of the output plane in World Units.
  67586. */
  67587. outputPosition?: Vector3;
  67588. /**
  67589. * Vector3 of the rotation of the output plane.
  67590. */
  67591. outputRotation?: Vector3;
  67592. /**
  67593. * number of layers that the system will reserve in resources.
  67594. */
  67595. layerCount?: number;
  67596. /**
  67597. * number of max animation frames a single cell will reserve in resources.
  67598. */
  67599. maxAnimationFrames?: number;
  67600. /**
  67601. * number cell index of the base tile when the system compiles.
  67602. */
  67603. baseTile?: number;
  67604. /**
  67605. * boolean flip the sprite after its been repositioned by the framing data.
  67606. */
  67607. flipU?: boolean;
  67608. /**
  67609. * Vector3 scalar of the global RGB values of the SpriteMap.
  67610. */
  67611. colorMultiply?: Vector3;
  67612. }
  67613. /**
  67614. * Defines the IDisposable interface in order to be cleanable from resources.
  67615. */
  67616. export interface ISpriteMap extends IDisposable {
  67617. /**
  67618. * String name of the SpriteMap.
  67619. */
  67620. name: string;
  67621. /**
  67622. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67623. */
  67624. atlasJSON: ISpriteJSONAtlas;
  67625. /**
  67626. * Texture of the SpriteMap.
  67627. */
  67628. spriteSheet: Texture;
  67629. /**
  67630. * The parameters to initialize the SpriteMap with.
  67631. */
  67632. options: ISpriteMapOptions;
  67633. }
  67634. /**
  67635. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67636. */
  67637. export class SpriteMap implements ISpriteMap {
  67638. /** The Name of the spriteMap */
  67639. name: string;
  67640. /** The JSON file with the frame and meta data */
  67641. atlasJSON: ISpriteJSONAtlas;
  67642. /** The systems Sprite Sheet Texture */
  67643. spriteSheet: Texture;
  67644. /** Arguments passed with the Constructor */
  67645. options: ISpriteMapOptions;
  67646. /** Public Sprite Storage array, parsed from atlasJSON */
  67647. sprites: Array<ISpriteJSONSprite>;
  67648. /** Returns the Number of Sprites in the System */
  67649. get spriteCount(): number;
  67650. /** Returns the Position of Output Plane*/
  67651. get position(): Vector3;
  67652. /** Returns the Position of Output Plane*/
  67653. set position(v: Vector3);
  67654. /** Returns the Rotation of Output Plane*/
  67655. get rotation(): Vector3;
  67656. /** Returns the Rotation of Output Plane*/
  67657. set rotation(v: Vector3);
  67658. /** Sets the AnimationMap*/
  67659. get animationMap(): RawTexture;
  67660. /** Sets the AnimationMap*/
  67661. set animationMap(v: RawTexture);
  67662. /** Scene that the SpriteMap was created in */
  67663. private _scene;
  67664. /** Texture Buffer of Float32 that holds tile frame data*/
  67665. private _frameMap;
  67666. /** Texture Buffers of Float32 that holds tileMap data*/
  67667. private _tileMaps;
  67668. /** Texture Buffer of Float32 that holds Animation Data*/
  67669. private _animationMap;
  67670. /** Custom ShaderMaterial Central to the System*/
  67671. private _material;
  67672. /** Custom ShaderMaterial Central to the System*/
  67673. private _output;
  67674. /** Systems Time Ticker*/
  67675. private _time;
  67676. /**
  67677. * Creates a new SpriteMap
  67678. * @param name defines the SpriteMaps Name
  67679. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67680. * @param spriteSheet is the Texture that the Sprites are on.
  67681. * @param options a basic deployment configuration
  67682. * @param scene The Scene that the map is deployed on
  67683. */
  67684. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67685. /**
  67686. * Returns tileID location
  67687. * @returns Vector2 the cell position ID
  67688. */
  67689. getTileID(): Vector2;
  67690. /**
  67691. * Gets the UV location of the mouse over the SpriteMap.
  67692. * @returns Vector2 the UV position of the mouse interaction
  67693. */
  67694. getMousePosition(): Vector2;
  67695. /**
  67696. * Creates the "frame" texture Buffer
  67697. * -------------------------------------
  67698. * Structure of frames
  67699. * "filename": "Falling-Water-2.png",
  67700. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67701. * "rotated": true,
  67702. * "trimmed": true,
  67703. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67704. * "sourceSize": {"w":32,"h":32}
  67705. * @returns RawTexture of the frameMap
  67706. */
  67707. private _createFrameBuffer;
  67708. /**
  67709. * Creates the tileMap texture Buffer
  67710. * @param buffer normally and array of numbers, or a false to generate from scratch
  67711. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67712. * @returns RawTexture of the tileMap
  67713. */
  67714. private _createTileBuffer;
  67715. /**
  67716. * Modifies the data of the tileMaps
  67717. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67718. * @param pos is the iVector2 Coordinates of the Tile
  67719. * @param tile The SpriteIndex of the new Tile
  67720. */
  67721. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67722. /**
  67723. * Creates the animationMap texture Buffer
  67724. * @param buffer normally and array of numbers, or a false to generate from scratch
  67725. * @returns RawTexture of the animationMap
  67726. */
  67727. private _createTileAnimationBuffer;
  67728. /**
  67729. * Modifies the data of the animationMap
  67730. * @param cellID is the Index of the Sprite
  67731. * @param _frame is the target Animation frame
  67732. * @param toCell is the Target Index of the next frame of the animation
  67733. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67734. * @param speed is a global scalar of the time variable on the map.
  67735. */
  67736. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67737. /**
  67738. * Exports the .tilemaps file
  67739. */
  67740. saveTileMaps(): void;
  67741. /**
  67742. * Imports the .tilemaps file
  67743. * @param url of the .tilemaps file
  67744. */
  67745. loadTileMaps(url: string): void;
  67746. /**
  67747. * Release associated resources
  67748. */
  67749. dispose(): void;
  67750. }
  67751. }
  67752. declare module BABYLON {
  67753. /**
  67754. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67755. * @see http://doc.babylonjs.com/babylon101/sprites
  67756. */
  67757. export class SpritePackedManager extends SpriteManager {
  67758. /** defines the packed manager's name */
  67759. name: string;
  67760. /**
  67761. * Creates a new sprite manager from a packed sprite sheet
  67762. * @param name defines the manager's name
  67763. * @param imgUrl defines the sprite sheet url
  67764. * @param capacity defines the maximum allowed number of sprites
  67765. * @param scene defines the hosting scene
  67766. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67767. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67768. * @param samplingMode defines the smapling mode to use with spritesheet
  67769. * @param fromPacked set to true; do not alter
  67770. */
  67771. constructor(
  67772. /** defines the packed manager's name */
  67773. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67774. }
  67775. }
  67776. declare module BABYLON {
  67777. /**
  67778. * Defines the list of states available for a task inside a AssetsManager
  67779. */
  67780. export enum AssetTaskState {
  67781. /**
  67782. * Initialization
  67783. */
  67784. INIT = 0,
  67785. /**
  67786. * Running
  67787. */
  67788. RUNNING = 1,
  67789. /**
  67790. * Done
  67791. */
  67792. DONE = 2,
  67793. /**
  67794. * Error
  67795. */
  67796. ERROR = 3
  67797. }
  67798. /**
  67799. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67800. */
  67801. export abstract class AbstractAssetTask {
  67802. /**
  67803. * Task name
  67804. */ name: string;
  67805. /**
  67806. * Callback called when the task is successful
  67807. */
  67808. onSuccess: (task: any) => void;
  67809. /**
  67810. * Callback called when the task is not successful
  67811. */
  67812. onError: (task: any, message?: string, exception?: any) => void;
  67813. /**
  67814. * Creates a new AssetsManager
  67815. * @param name defines the name of the task
  67816. */
  67817. constructor(
  67818. /**
  67819. * Task name
  67820. */ name: string);
  67821. private _isCompleted;
  67822. private _taskState;
  67823. private _errorObject;
  67824. /**
  67825. * Get if the task is completed
  67826. */
  67827. get isCompleted(): boolean;
  67828. /**
  67829. * Gets the current state of the task
  67830. */
  67831. get taskState(): AssetTaskState;
  67832. /**
  67833. * Gets the current error object (if task is in error)
  67834. */
  67835. get errorObject(): {
  67836. message?: string;
  67837. exception?: any;
  67838. };
  67839. /**
  67840. * Internal only
  67841. * @hidden
  67842. */
  67843. _setErrorObject(message?: string, exception?: any): void;
  67844. /**
  67845. * Execute the current task
  67846. * @param scene defines the scene where you want your assets to be loaded
  67847. * @param onSuccess is a callback called when the task is successfully executed
  67848. * @param onError is a callback called if an error occurs
  67849. */
  67850. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67851. /**
  67852. * Execute the current task
  67853. * @param scene defines the scene where you want your assets to be loaded
  67854. * @param onSuccess is a callback called when the task is successfully executed
  67855. * @param onError is a callback called if an error occurs
  67856. */
  67857. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67858. /**
  67859. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67860. * This can be used with failed tasks that have the reason for failure fixed.
  67861. */
  67862. reset(): void;
  67863. private onErrorCallback;
  67864. private onDoneCallback;
  67865. }
  67866. /**
  67867. * Define the interface used by progress events raised during assets loading
  67868. */
  67869. export interface IAssetsProgressEvent {
  67870. /**
  67871. * Defines the number of remaining tasks to process
  67872. */
  67873. remainingCount: number;
  67874. /**
  67875. * Defines the total number of tasks
  67876. */
  67877. totalCount: number;
  67878. /**
  67879. * Defines the task that was just processed
  67880. */
  67881. task: AbstractAssetTask;
  67882. }
  67883. /**
  67884. * Class used to share progress information about assets loading
  67885. */
  67886. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67887. /**
  67888. * Defines the number of remaining tasks to process
  67889. */
  67890. remainingCount: number;
  67891. /**
  67892. * Defines the total number of tasks
  67893. */
  67894. totalCount: number;
  67895. /**
  67896. * Defines the task that was just processed
  67897. */
  67898. task: AbstractAssetTask;
  67899. /**
  67900. * Creates a AssetsProgressEvent
  67901. * @param remainingCount defines the number of remaining tasks to process
  67902. * @param totalCount defines the total number of tasks
  67903. * @param task defines the task that was just processed
  67904. */
  67905. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67906. }
  67907. /**
  67908. * Define a task used by AssetsManager to load meshes
  67909. */
  67910. export class MeshAssetTask extends AbstractAssetTask {
  67911. /**
  67912. * Defines the name of the task
  67913. */
  67914. name: string;
  67915. /**
  67916. * Defines the list of mesh's names you want to load
  67917. */
  67918. meshesNames: any;
  67919. /**
  67920. * Defines the root url to use as a base to load your meshes and associated resources
  67921. */
  67922. rootUrl: string;
  67923. /**
  67924. * Defines the filename of the scene to load from
  67925. */
  67926. sceneFilename: string;
  67927. /**
  67928. * Gets the list of loaded meshes
  67929. */
  67930. loadedMeshes: Array<AbstractMesh>;
  67931. /**
  67932. * Gets the list of loaded particle systems
  67933. */
  67934. loadedParticleSystems: Array<IParticleSystem>;
  67935. /**
  67936. * Gets the list of loaded skeletons
  67937. */
  67938. loadedSkeletons: Array<Skeleton>;
  67939. /**
  67940. * Gets the list of loaded animation groups
  67941. */
  67942. loadedAnimationGroups: Array<AnimationGroup>;
  67943. /**
  67944. * Callback called when the task is successful
  67945. */
  67946. onSuccess: (task: MeshAssetTask) => void;
  67947. /**
  67948. * Callback called when the task is successful
  67949. */
  67950. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67951. /**
  67952. * Creates a new MeshAssetTask
  67953. * @param name defines the name of the task
  67954. * @param meshesNames defines the list of mesh's names you want to load
  67955. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67956. * @param sceneFilename defines the filename of the scene to load from
  67957. */
  67958. constructor(
  67959. /**
  67960. * Defines the name of the task
  67961. */
  67962. name: string,
  67963. /**
  67964. * Defines the list of mesh's names you want to load
  67965. */
  67966. meshesNames: any,
  67967. /**
  67968. * Defines the root url to use as a base to load your meshes and associated resources
  67969. */
  67970. rootUrl: string,
  67971. /**
  67972. * Defines the filename of the scene to load from
  67973. */
  67974. sceneFilename: string);
  67975. /**
  67976. * Execute the current task
  67977. * @param scene defines the scene where you want your assets to be loaded
  67978. * @param onSuccess is a callback called when the task is successfully executed
  67979. * @param onError is a callback called if an error occurs
  67980. */
  67981. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67982. }
  67983. /**
  67984. * Define a task used by AssetsManager to load text content
  67985. */
  67986. export class TextFileAssetTask extends AbstractAssetTask {
  67987. /**
  67988. * Defines the name of the task
  67989. */
  67990. name: string;
  67991. /**
  67992. * Defines the location of the file to load
  67993. */
  67994. url: string;
  67995. /**
  67996. * Gets the loaded text string
  67997. */
  67998. text: string;
  67999. /**
  68000. * Callback called when the task is successful
  68001. */
  68002. onSuccess: (task: TextFileAssetTask) => void;
  68003. /**
  68004. * Callback called when the task is successful
  68005. */
  68006. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68007. /**
  68008. * Creates a new TextFileAssetTask object
  68009. * @param name defines the name of the task
  68010. * @param url defines the location of the file to load
  68011. */
  68012. constructor(
  68013. /**
  68014. * Defines the name of the task
  68015. */
  68016. name: string,
  68017. /**
  68018. * Defines the location of the file to load
  68019. */
  68020. url: string);
  68021. /**
  68022. * Execute the current task
  68023. * @param scene defines the scene where you want your assets to be loaded
  68024. * @param onSuccess is a callback called when the task is successfully executed
  68025. * @param onError is a callback called if an error occurs
  68026. */
  68027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68028. }
  68029. /**
  68030. * Define a task used by AssetsManager to load binary data
  68031. */
  68032. export class BinaryFileAssetTask extends AbstractAssetTask {
  68033. /**
  68034. * Defines the name of the task
  68035. */
  68036. name: string;
  68037. /**
  68038. * Defines the location of the file to load
  68039. */
  68040. url: string;
  68041. /**
  68042. * Gets the lodaded data (as an array buffer)
  68043. */
  68044. data: ArrayBuffer;
  68045. /**
  68046. * Callback called when the task is successful
  68047. */
  68048. onSuccess: (task: BinaryFileAssetTask) => void;
  68049. /**
  68050. * Callback called when the task is successful
  68051. */
  68052. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68053. /**
  68054. * Creates a new BinaryFileAssetTask object
  68055. * @param name defines the name of the new task
  68056. * @param url defines the location of the file to load
  68057. */
  68058. constructor(
  68059. /**
  68060. * Defines the name of the task
  68061. */
  68062. name: string,
  68063. /**
  68064. * Defines the location of the file to load
  68065. */
  68066. url: string);
  68067. /**
  68068. * Execute the current task
  68069. * @param scene defines the scene where you want your assets to be loaded
  68070. * @param onSuccess is a callback called when the task is successfully executed
  68071. * @param onError is a callback called if an error occurs
  68072. */
  68073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68074. }
  68075. /**
  68076. * Define a task used by AssetsManager to load images
  68077. */
  68078. export class ImageAssetTask extends AbstractAssetTask {
  68079. /**
  68080. * Defines the name of the task
  68081. */
  68082. name: string;
  68083. /**
  68084. * Defines the location of the image to load
  68085. */
  68086. url: string;
  68087. /**
  68088. * Gets the loaded images
  68089. */
  68090. image: HTMLImageElement;
  68091. /**
  68092. * Callback called when the task is successful
  68093. */
  68094. onSuccess: (task: ImageAssetTask) => void;
  68095. /**
  68096. * Callback called when the task is successful
  68097. */
  68098. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68099. /**
  68100. * Creates a new ImageAssetTask
  68101. * @param name defines the name of the task
  68102. * @param url defines the location of the image to load
  68103. */
  68104. constructor(
  68105. /**
  68106. * Defines the name of the task
  68107. */
  68108. name: string,
  68109. /**
  68110. * Defines the location of the image to load
  68111. */
  68112. url: string);
  68113. /**
  68114. * Execute the current task
  68115. * @param scene defines the scene where you want your assets to be loaded
  68116. * @param onSuccess is a callback called when the task is successfully executed
  68117. * @param onError is a callback called if an error occurs
  68118. */
  68119. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68120. }
  68121. /**
  68122. * Defines the interface used by texture loading tasks
  68123. */
  68124. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68125. /**
  68126. * Gets the loaded texture
  68127. */
  68128. texture: TEX;
  68129. }
  68130. /**
  68131. * Define a task used by AssetsManager to load 2D textures
  68132. */
  68133. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68134. /**
  68135. * Defines the name of the task
  68136. */
  68137. name: string;
  68138. /**
  68139. * Defines the location of the file to load
  68140. */
  68141. url: string;
  68142. /**
  68143. * Defines if mipmap should not be generated (default is false)
  68144. */
  68145. noMipmap?: boolean | undefined;
  68146. /**
  68147. * Defines if texture must be inverted on Y axis (default is true)
  68148. */
  68149. invertY: boolean;
  68150. /**
  68151. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68152. */
  68153. samplingMode: number;
  68154. /**
  68155. * Gets the loaded texture
  68156. */
  68157. texture: Texture;
  68158. /**
  68159. * Callback called when the task is successful
  68160. */
  68161. onSuccess: (task: TextureAssetTask) => void;
  68162. /**
  68163. * Callback called when the task is successful
  68164. */
  68165. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68166. /**
  68167. * Creates a new TextureAssetTask object
  68168. * @param name defines the name of the task
  68169. * @param url defines the location of the file to load
  68170. * @param noMipmap defines if mipmap should not be generated (default is false)
  68171. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68172. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68173. */
  68174. constructor(
  68175. /**
  68176. * Defines the name of the task
  68177. */
  68178. name: string,
  68179. /**
  68180. * Defines the location of the file to load
  68181. */
  68182. url: string,
  68183. /**
  68184. * Defines if mipmap should not be generated (default is false)
  68185. */
  68186. noMipmap?: boolean | undefined,
  68187. /**
  68188. * Defines if texture must be inverted on Y axis (default is true)
  68189. */
  68190. invertY?: boolean,
  68191. /**
  68192. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68193. */
  68194. samplingMode?: number);
  68195. /**
  68196. * Execute the current task
  68197. * @param scene defines the scene where you want your assets to be loaded
  68198. * @param onSuccess is a callback called when the task is successfully executed
  68199. * @param onError is a callback called if an error occurs
  68200. */
  68201. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68202. }
  68203. /**
  68204. * Define a task used by AssetsManager to load cube textures
  68205. */
  68206. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68207. /**
  68208. * Defines the name of the task
  68209. */
  68210. name: string;
  68211. /**
  68212. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68213. */
  68214. url: string;
  68215. /**
  68216. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68217. */
  68218. extensions?: string[] | undefined;
  68219. /**
  68220. * Defines if mipmaps should not be generated (default is false)
  68221. */
  68222. noMipmap?: boolean | undefined;
  68223. /**
  68224. * Defines the explicit list of files (undefined by default)
  68225. */
  68226. files?: string[] | undefined;
  68227. /**
  68228. * Gets the loaded texture
  68229. */
  68230. texture: CubeTexture;
  68231. /**
  68232. * Callback called when the task is successful
  68233. */
  68234. onSuccess: (task: CubeTextureAssetTask) => void;
  68235. /**
  68236. * Callback called when the task is successful
  68237. */
  68238. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68239. /**
  68240. * Creates a new CubeTextureAssetTask
  68241. * @param name defines the name of the task
  68242. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68243. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68244. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68245. * @param files defines the explicit list of files (undefined by default)
  68246. */
  68247. constructor(
  68248. /**
  68249. * Defines the name of the task
  68250. */
  68251. name: string,
  68252. /**
  68253. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68254. */
  68255. url: string,
  68256. /**
  68257. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68258. */
  68259. extensions?: string[] | undefined,
  68260. /**
  68261. * Defines if mipmaps should not be generated (default is false)
  68262. */
  68263. noMipmap?: boolean | undefined,
  68264. /**
  68265. * Defines the explicit list of files (undefined by default)
  68266. */
  68267. files?: string[] | undefined);
  68268. /**
  68269. * Execute the current task
  68270. * @param scene defines the scene where you want your assets to be loaded
  68271. * @param onSuccess is a callback called when the task is successfully executed
  68272. * @param onError is a callback called if an error occurs
  68273. */
  68274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68275. }
  68276. /**
  68277. * Define a task used by AssetsManager to load HDR cube textures
  68278. */
  68279. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68280. /**
  68281. * Defines the name of the task
  68282. */
  68283. name: string;
  68284. /**
  68285. * Defines the location of the file to load
  68286. */
  68287. url: string;
  68288. /**
  68289. * Defines the desired size (the more it increases the longer the generation will be)
  68290. */
  68291. size: number;
  68292. /**
  68293. * Defines if mipmaps should not be generated (default is false)
  68294. */
  68295. noMipmap: boolean;
  68296. /**
  68297. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68298. */
  68299. generateHarmonics: boolean;
  68300. /**
  68301. * 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)
  68302. */
  68303. gammaSpace: boolean;
  68304. /**
  68305. * Internal Use Only
  68306. */
  68307. reserved: boolean;
  68308. /**
  68309. * Gets the loaded texture
  68310. */
  68311. texture: HDRCubeTexture;
  68312. /**
  68313. * Callback called when the task is successful
  68314. */
  68315. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68316. /**
  68317. * Callback called when the task is successful
  68318. */
  68319. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68320. /**
  68321. * Creates a new HDRCubeTextureAssetTask object
  68322. * @param name defines the name of the task
  68323. * @param url defines the location of the file to load
  68324. * @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.
  68325. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68326. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68327. * @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)
  68328. * @param reserved Internal use only
  68329. */
  68330. constructor(
  68331. /**
  68332. * Defines the name of the task
  68333. */
  68334. name: string,
  68335. /**
  68336. * Defines the location of the file to load
  68337. */
  68338. url: string,
  68339. /**
  68340. * Defines the desired size (the more it increases the longer the generation will be)
  68341. */
  68342. size: number,
  68343. /**
  68344. * Defines if mipmaps should not be generated (default is false)
  68345. */
  68346. noMipmap?: boolean,
  68347. /**
  68348. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68349. */
  68350. generateHarmonics?: boolean,
  68351. /**
  68352. * 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)
  68353. */
  68354. gammaSpace?: boolean,
  68355. /**
  68356. * Internal Use Only
  68357. */
  68358. reserved?: boolean);
  68359. /**
  68360. * Execute the current task
  68361. * @param scene defines the scene where you want your assets to be loaded
  68362. * @param onSuccess is a callback called when the task is successfully executed
  68363. * @param onError is a callback called if an error occurs
  68364. */
  68365. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68366. }
  68367. /**
  68368. * Define a task used by AssetsManager to load Equirectangular cube textures
  68369. */
  68370. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68371. /**
  68372. * Defines the name of the task
  68373. */
  68374. name: string;
  68375. /**
  68376. * Defines the location of the file to load
  68377. */
  68378. url: string;
  68379. /**
  68380. * Defines the desired size (the more it increases the longer the generation will be)
  68381. */
  68382. size: number;
  68383. /**
  68384. * Defines if mipmaps should not be generated (default is false)
  68385. */
  68386. noMipmap: boolean;
  68387. /**
  68388. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68389. * but the standard material would require them in Gamma space) (default is true)
  68390. */
  68391. gammaSpace: boolean;
  68392. /**
  68393. * Gets the loaded texture
  68394. */
  68395. texture: EquiRectangularCubeTexture;
  68396. /**
  68397. * Callback called when the task is successful
  68398. */
  68399. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68400. /**
  68401. * Callback called when the task is successful
  68402. */
  68403. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68404. /**
  68405. * Creates a new EquiRectangularCubeTextureAssetTask object
  68406. * @param name defines the name of the task
  68407. * @param url defines the location of the file to load
  68408. * @param size defines the desired size (the more it increases the longer the generation will be)
  68409. * If the size is omitted this implies you are using a preprocessed cubemap.
  68410. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68411. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68412. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68413. * (default is true)
  68414. */
  68415. constructor(
  68416. /**
  68417. * Defines the name of the task
  68418. */
  68419. name: string,
  68420. /**
  68421. * Defines the location of the file to load
  68422. */
  68423. url: string,
  68424. /**
  68425. * Defines the desired size (the more it increases the longer the generation will be)
  68426. */
  68427. size: number,
  68428. /**
  68429. * Defines if mipmaps should not be generated (default is false)
  68430. */
  68431. noMipmap?: boolean,
  68432. /**
  68433. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68434. * but the standard material would require them in Gamma space) (default is true)
  68435. */
  68436. gammaSpace?: boolean);
  68437. /**
  68438. * Execute the current task
  68439. * @param scene defines the scene where you want your assets to be loaded
  68440. * @param onSuccess is a callback called when the task is successfully executed
  68441. * @param onError is a callback called if an error occurs
  68442. */
  68443. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68444. }
  68445. /**
  68446. * This class can be used to easily import assets into a scene
  68447. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68448. */
  68449. export class AssetsManager {
  68450. private _scene;
  68451. private _isLoading;
  68452. protected _tasks: AbstractAssetTask[];
  68453. protected _waitingTasksCount: number;
  68454. protected _totalTasksCount: number;
  68455. /**
  68456. * Callback called when all tasks are processed
  68457. */
  68458. onFinish: (tasks: AbstractAssetTask[]) => void;
  68459. /**
  68460. * Callback called when a task is successful
  68461. */
  68462. onTaskSuccess: (task: AbstractAssetTask) => void;
  68463. /**
  68464. * Callback called when a task had an error
  68465. */
  68466. onTaskError: (task: AbstractAssetTask) => void;
  68467. /**
  68468. * Callback called when a task is done (whatever the result is)
  68469. */
  68470. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68471. /**
  68472. * Observable called when all tasks are processed
  68473. */
  68474. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68475. /**
  68476. * Observable called when a task had an error
  68477. */
  68478. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68479. /**
  68480. * Observable called when all tasks were executed
  68481. */
  68482. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68483. /**
  68484. * Observable called when a task is done (whatever the result is)
  68485. */
  68486. onProgressObservable: Observable<IAssetsProgressEvent>;
  68487. /**
  68488. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68489. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68490. */
  68491. useDefaultLoadingScreen: boolean;
  68492. /**
  68493. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68494. * when all assets have been downloaded.
  68495. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68496. */
  68497. autoHideLoadingUI: boolean;
  68498. /**
  68499. * Creates a new AssetsManager
  68500. * @param scene defines the scene to work on
  68501. */
  68502. constructor(scene: Scene);
  68503. /**
  68504. * Add a MeshAssetTask to the list of active tasks
  68505. * @param taskName defines the name of the new task
  68506. * @param meshesNames defines the name of meshes to load
  68507. * @param rootUrl defines the root url to use to locate files
  68508. * @param sceneFilename defines the filename of the scene file
  68509. * @returns a new MeshAssetTask object
  68510. */
  68511. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68512. /**
  68513. * Add a TextFileAssetTask to the list of active tasks
  68514. * @param taskName defines the name of the new task
  68515. * @param url defines the url of the file to load
  68516. * @returns a new TextFileAssetTask object
  68517. */
  68518. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68519. /**
  68520. * Add a BinaryFileAssetTask to the list of active tasks
  68521. * @param taskName defines the name of the new task
  68522. * @param url defines the url of the file to load
  68523. * @returns a new BinaryFileAssetTask object
  68524. */
  68525. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68526. /**
  68527. * Add a ImageAssetTask to the list of active tasks
  68528. * @param taskName defines the name of the new task
  68529. * @param url defines the url of the file to load
  68530. * @returns a new ImageAssetTask object
  68531. */
  68532. addImageTask(taskName: string, url: string): ImageAssetTask;
  68533. /**
  68534. * Add a TextureAssetTask to the list of active tasks
  68535. * @param taskName defines the name of the new task
  68536. * @param url defines the url of the file to load
  68537. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68538. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68539. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68540. * @returns a new TextureAssetTask object
  68541. */
  68542. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68543. /**
  68544. * Add a CubeTextureAssetTask to the list of active tasks
  68545. * @param taskName defines the name of the new task
  68546. * @param url defines the url of the file to load
  68547. * @param extensions defines the extension to use to load the cube map (can be null)
  68548. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68549. * @param files defines the list of files to load (can be null)
  68550. * @returns a new CubeTextureAssetTask object
  68551. */
  68552. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68553. /**
  68554. *
  68555. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68556. * @param taskName defines the name of the new task
  68557. * @param url defines the url of the file to load
  68558. * @param size defines the size you want for the cubemap (can be null)
  68559. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68560. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68561. * @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)
  68562. * @param reserved Internal use only
  68563. * @returns a new HDRCubeTextureAssetTask object
  68564. */
  68565. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68566. /**
  68567. *
  68568. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68569. * @param taskName defines the name of the new task
  68570. * @param url defines the url of the file to load
  68571. * @param size defines the size you want for the cubemap (can be null)
  68572. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68573. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68574. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68575. * @returns a new EquiRectangularCubeTextureAssetTask object
  68576. */
  68577. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68578. /**
  68579. * Remove a task from the assets manager.
  68580. * @param task the task to remove
  68581. */
  68582. removeTask(task: AbstractAssetTask): void;
  68583. private _decreaseWaitingTasksCount;
  68584. private _runTask;
  68585. /**
  68586. * Reset the AssetsManager and remove all tasks
  68587. * @return the current instance of the AssetsManager
  68588. */
  68589. reset(): AssetsManager;
  68590. /**
  68591. * Start the loading process
  68592. * @return the current instance of the AssetsManager
  68593. */
  68594. load(): AssetsManager;
  68595. /**
  68596. * Start the loading process as an async operation
  68597. * @return a promise returning the list of failed tasks
  68598. */
  68599. loadAsync(): Promise<void>;
  68600. }
  68601. }
  68602. declare module BABYLON {
  68603. /**
  68604. * Wrapper class for promise with external resolve and reject.
  68605. */
  68606. export class Deferred<T> {
  68607. /**
  68608. * The promise associated with this deferred object.
  68609. */
  68610. readonly promise: Promise<T>;
  68611. private _resolve;
  68612. private _reject;
  68613. /**
  68614. * The resolve method of the promise associated with this deferred object.
  68615. */
  68616. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68617. /**
  68618. * The reject method of the promise associated with this deferred object.
  68619. */
  68620. get reject(): (reason?: any) => void;
  68621. /**
  68622. * Constructor for this deferred object.
  68623. */
  68624. constructor();
  68625. }
  68626. }
  68627. declare module BABYLON {
  68628. /**
  68629. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68630. */
  68631. export class MeshExploder {
  68632. private _centerMesh;
  68633. private _meshes;
  68634. private _meshesOrigins;
  68635. private _toCenterVectors;
  68636. private _scaledDirection;
  68637. private _newPosition;
  68638. private _centerPosition;
  68639. /**
  68640. * Explodes meshes from a center mesh.
  68641. * @param meshes The meshes to explode.
  68642. * @param centerMesh The mesh to be center of explosion.
  68643. */
  68644. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68645. private _setCenterMesh;
  68646. /**
  68647. * Get class name
  68648. * @returns "MeshExploder"
  68649. */
  68650. getClassName(): string;
  68651. /**
  68652. * "Exploded meshes"
  68653. * @returns Array of meshes with the centerMesh at index 0.
  68654. */
  68655. getMeshes(): Array<Mesh>;
  68656. /**
  68657. * Explodes meshes giving a specific direction
  68658. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68659. */
  68660. explode(direction?: number): void;
  68661. }
  68662. }
  68663. declare module BABYLON {
  68664. /**
  68665. * Class used to help managing file picking and drag'n'drop
  68666. */
  68667. export class FilesInput {
  68668. /**
  68669. * List of files ready to be loaded
  68670. */
  68671. static get FilesToLoad(): {
  68672. [key: string]: File;
  68673. };
  68674. /**
  68675. * Callback called when a file is processed
  68676. */
  68677. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68678. private _engine;
  68679. private _currentScene;
  68680. private _sceneLoadedCallback;
  68681. private _progressCallback;
  68682. private _additionalRenderLoopLogicCallback;
  68683. private _textureLoadingCallback;
  68684. private _startingProcessingFilesCallback;
  68685. private _onReloadCallback;
  68686. private _errorCallback;
  68687. private _elementToMonitor;
  68688. private _sceneFileToLoad;
  68689. private _filesToLoad;
  68690. /**
  68691. * Creates a new FilesInput
  68692. * @param engine defines the rendering engine
  68693. * @param scene defines the hosting scene
  68694. * @param sceneLoadedCallback callback called when scene is loaded
  68695. * @param progressCallback callback called to track progress
  68696. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68697. * @param textureLoadingCallback callback called when a texture is loading
  68698. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68699. * @param onReloadCallback callback called when a reload is requested
  68700. * @param errorCallback callback call if an error occurs
  68701. */
  68702. 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);
  68703. private _dragEnterHandler;
  68704. private _dragOverHandler;
  68705. private _dropHandler;
  68706. /**
  68707. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68708. * @param elementToMonitor defines the DOM element to track
  68709. */
  68710. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68711. /**
  68712. * Release all associated resources
  68713. */
  68714. dispose(): void;
  68715. private renderFunction;
  68716. private drag;
  68717. private drop;
  68718. private _traverseFolder;
  68719. private _processFiles;
  68720. /**
  68721. * Load files from a drop event
  68722. * @param event defines the drop event to use as source
  68723. */
  68724. loadFiles(event: any): void;
  68725. private _processReload;
  68726. /**
  68727. * Reload the current scene from the loaded files
  68728. */
  68729. reload(): void;
  68730. }
  68731. }
  68732. declare module BABYLON {
  68733. /**
  68734. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68735. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68736. */
  68737. export class SceneOptimization {
  68738. /**
  68739. * Defines the priority of this optimization (0 by default which means first in the list)
  68740. */
  68741. priority: number;
  68742. /**
  68743. * Gets a string describing the action executed by the current optimization
  68744. * @returns description string
  68745. */
  68746. getDescription(): string;
  68747. /**
  68748. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68749. * @param scene defines the current scene where to apply this optimization
  68750. * @param optimizer defines the current optimizer
  68751. * @returns true if everything that can be done was applied
  68752. */
  68753. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68754. /**
  68755. * Creates the SceneOptimization object
  68756. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68757. * @param desc defines the description associated with the optimization
  68758. */
  68759. constructor(
  68760. /**
  68761. * Defines the priority of this optimization (0 by default which means first in the list)
  68762. */
  68763. priority?: number);
  68764. }
  68765. /**
  68766. * Defines an optimization used to reduce the size of render target textures
  68767. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68768. */
  68769. export class TextureOptimization extends SceneOptimization {
  68770. /**
  68771. * Defines the priority of this optimization (0 by default which means first in the list)
  68772. */
  68773. priority: number;
  68774. /**
  68775. * 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
  68776. */
  68777. maximumSize: number;
  68778. /**
  68779. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68780. */
  68781. step: number;
  68782. /**
  68783. * Gets a string describing the action executed by the current optimization
  68784. * @returns description string
  68785. */
  68786. getDescription(): string;
  68787. /**
  68788. * Creates the TextureOptimization object
  68789. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68790. * @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
  68791. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68792. */
  68793. constructor(
  68794. /**
  68795. * Defines the priority of this optimization (0 by default which means first in the list)
  68796. */
  68797. priority?: number,
  68798. /**
  68799. * 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
  68800. */
  68801. maximumSize?: number,
  68802. /**
  68803. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68804. */
  68805. step?: number);
  68806. /**
  68807. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68808. * @param scene defines the current scene where to apply this optimization
  68809. * @param optimizer defines the current optimizer
  68810. * @returns true if everything that can be done was applied
  68811. */
  68812. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68813. }
  68814. /**
  68815. * Defines an optimization used to increase or decrease the rendering resolution
  68816. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68817. */
  68818. export class HardwareScalingOptimization extends SceneOptimization {
  68819. /**
  68820. * Defines the priority of this optimization (0 by default which means first in the list)
  68821. */
  68822. priority: number;
  68823. /**
  68824. * Defines the maximum scale to use (2 by default)
  68825. */
  68826. maximumScale: number;
  68827. /**
  68828. * Defines the step to use between two passes (0.5 by default)
  68829. */
  68830. step: number;
  68831. private _currentScale;
  68832. private _directionOffset;
  68833. /**
  68834. * Gets a string describing the action executed by the current optimization
  68835. * @return description string
  68836. */
  68837. getDescription(): string;
  68838. /**
  68839. * Creates the HardwareScalingOptimization object
  68840. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68841. * @param maximumScale defines the maximum scale to use (2 by default)
  68842. * @param step defines the step to use between two passes (0.5 by default)
  68843. */
  68844. constructor(
  68845. /**
  68846. * Defines the priority of this optimization (0 by default which means first in the list)
  68847. */
  68848. priority?: number,
  68849. /**
  68850. * Defines the maximum scale to use (2 by default)
  68851. */
  68852. maximumScale?: number,
  68853. /**
  68854. * Defines the step to use between two passes (0.5 by default)
  68855. */
  68856. step?: number);
  68857. /**
  68858. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68859. * @param scene defines the current scene where to apply this optimization
  68860. * @param optimizer defines the current optimizer
  68861. * @returns true if everything that can be done was applied
  68862. */
  68863. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68864. }
  68865. /**
  68866. * Defines an optimization used to remove shadows
  68867. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68868. */
  68869. export class ShadowsOptimization extends SceneOptimization {
  68870. /**
  68871. * Gets a string describing the action executed by the current optimization
  68872. * @return description string
  68873. */
  68874. getDescription(): string;
  68875. /**
  68876. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68877. * @param scene defines the current scene where to apply this optimization
  68878. * @param optimizer defines the current optimizer
  68879. * @returns true if everything that can be done was applied
  68880. */
  68881. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68882. }
  68883. /**
  68884. * Defines an optimization used to turn post-processes off
  68885. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68886. */
  68887. export class PostProcessesOptimization extends SceneOptimization {
  68888. /**
  68889. * Gets a string describing the action executed by the current optimization
  68890. * @return description string
  68891. */
  68892. getDescription(): string;
  68893. /**
  68894. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68895. * @param scene defines the current scene where to apply this optimization
  68896. * @param optimizer defines the current optimizer
  68897. * @returns true if everything that can be done was applied
  68898. */
  68899. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68900. }
  68901. /**
  68902. * Defines an optimization used to turn lens flares off
  68903. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68904. */
  68905. export class LensFlaresOptimization extends SceneOptimization {
  68906. /**
  68907. * Gets a string describing the action executed by the current optimization
  68908. * @return description string
  68909. */
  68910. getDescription(): string;
  68911. /**
  68912. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68913. * @param scene defines the current scene where to apply this optimization
  68914. * @param optimizer defines the current optimizer
  68915. * @returns true if everything that can be done was applied
  68916. */
  68917. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68918. }
  68919. /**
  68920. * Defines an optimization based on user defined callback.
  68921. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68922. */
  68923. export class CustomOptimization extends SceneOptimization {
  68924. /**
  68925. * Callback called to apply the custom optimization.
  68926. */
  68927. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68928. /**
  68929. * Callback called to get custom description
  68930. */
  68931. onGetDescription: () => string;
  68932. /**
  68933. * Gets a string describing the action executed by the current optimization
  68934. * @returns description string
  68935. */
  68936. getDescription(): string;
  68937. /**
  68938. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68939. * @param scene defines the current scene where to apply this optimization
  68940. * @param optimizer defines the current optimizer
  68941. * @returns true if everything that can be done was applied
  68942. */
  68943. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68944. }
  68945. /**
  68946. * Defines an optimization used to turn particles off
  68947. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68948. */
  68949. export class ParticlesOptimization extends SceneOptimization {
  68950. /**
  68951. * Gets a string describing the action executed by the current optimization
  68952. * @return description string
  68953. */
  68954. getDescription(): string;
  68955. /**
  68956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68957. * @param scene defines the current scene where to apply this optimization
  68958. * @param optimizer defines the current optimizer
  68959. * @returns true if everything that can be done was applied
  68960. */
  68961. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68962. }
  68963. /**
  68964. * Defines an optimization used to turn render targets off
  68965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68966. */
  68967. export class RenderTargetsOptimization extends SceneOptimization {
  68968. /**
  68969. * Gets a string describing the action executed by the current optimization
  68970. * @return description string
  68971. */
  68972. getDescription(): string;
  68973. /**
  68974. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68975. * @param scene defines the current scene where to apply this optimization
  68976. * @param optimizer defines the current optimizer
  68977. * @returns true if everything that can be done was applied
  68978. */
  68979. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68980. }
  68981. /**
  68982. * Defines an optimization used to merge meshes with compatible materials
  68983. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68984. */
  68985. export class MergeMeshesOptimization extends SceneOptimization {
  68986. private static _UpdateSelectionTree;
  68987. /**
  68988. * Gets or sets a boolean which defines if optimization octree has to be updated
  68989. */
  68990. static get UpdateSelectionTree(): boolean;
  68991. /**
  68992. * Gets or sets a boolean which defines if optimization octree has to be updated
  68993. */
  68994. static set UpdateSelectionTree(value: boolean);
  68995. /**
  68996. * Gets a string describing the action executed by the current optimization
  68997. * @return description string
  68998. */
  68999. getDescription(): string;
  69000. private _canBeMerged;
  69001. /**
  69002. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69003. * @param scene defines the current scene where to apply this optimization
  69004. * @param optimizer defines the current optimizer
  69005. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69006. * @returns true if everything that can be done was applied
  69007. */
  69008. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69009. }
  69010. /**
  69011. * Defines a list of options used by SceneOptimizer
  69012. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69013. */
  69014. export class SceneOptimizerOptions {
  69015. /**
  69016. * Defines the target frame rate to reach (60 by default)
  69017. */
  69018. targetFrameRate: number;
  69019. /**
  69020. * Defines the interval between two checkes (2000ms by default)
  69021. */
  69022. trackerDuration: number;
  69023. /**
  69024. * Gets the list of optimizations to apply
  69025. */
  69026. optimizations: SceneOptimization[];
  69027. /**
  69028. * Creates a new list of options used by SceneOptimizer
  69029. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69030. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69031. */
  69032. constructor(
  69033. /**
  69034. * Defines the target frame rate to reach (60 by default)
  69035. */
  69036. targetFrameRate?: number,
  69037. /**
  69038. * Defines the interval between two checkes (2000ms by default)
  69039. */
  69040. trackerDuration?: number);
  69041. /**
  69042. * Add a new optimization
  69043. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69044. * @returns the current SceneOptimizerOptions
  69045. */
  69046. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69047. /**
  69048. * Add a new custom optimization
  69049. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69050. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69051. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69052. * @returns the current SceneOptimizerOptions
  69053. */
  69054. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69055. /**
  69056. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69057. * @param targetFrameRate defines the target frame rate (60 by default)
  69058. * @returns a SceneOptimizerOptions object
  69059. */
  69060. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69061. /**
  69062. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69063. * @param targetFrameRate defines the target frame rate (60 by default)
  69064. * @returns a SceneOptimizerOptions object
  69065. */
  69066. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69067. /**
  69068. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69069. * @param targetFrameRate defines the target frame rate (60 by default)
  69070. * @returns a SceneOptimizerOptions object
  69071. */
  69072. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69073. }
  69074. /**
  69075. * Class used to run optimizations in order to reach a target frame rate
  69076. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69077. */
  69078. export class SceneOptimizer implements IDisposable {
  69079. private _isRunning;
  69080. private _options;
  69081. private _scene;
  69082. private _currentPriorityLevel;
  69083. private _targetFrameRate;
  69084. private _trackerDuration;
  69085. private _currentFrameRate;
  69086. private _sceneDisposeObserver;
  69087. private _improvementMode;
  69088. /**
  69089. * Defines an observable called when the optimizer reaches the target frame rate
  69090. */
  69091. onSuccessObservable: Observable<SceneOptimizer>;
  69092. /**
  69093. * Defines an observable called when the optimizer enables an optimization
  69094. */
  69095. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69096. /**
  69097. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69098. */
  69099. onFailureObservable: Observable<SceneOptimizer>;
  69100. /**
  69101. * Gets a boolean indicating if the optimizer is in improvement mode
  69102. */
  69103. get isInImprovementMode(): boolean;
  69104. /**
  69105. * Gets the current priority level (0 at start)
  69106. */
  69107. get currentPriorityLevel(): number;
  69108. /**
  69109. * Gets the current frame rate checked by the SceneOptimizer
  69110. */
  69111. get currentFrameRate(): number;
  69112. /**
  69113. * Gets or sets the current target frame rate (60 by default)
  69114. */
  69115. get targetFrameRate(): number;
  69116. /**
  69117. * Gets or sets the current target frame rate (60 by default)
  69118. */
  69119. set targetFrameRate(value: number);
  69120. /**
  69121. * Gets or sets the current interval between two checks (every 2000ms by default)
  69122. */
  69123. get trackerDuration(): number;
  69124. /**
  69125. * Gets or sets the current interval between two checks (every 2000ms by default)
  69126. */
  69127. set trackerDuration(value: number);
  69128. /**
  69129. * Gets the list of active optimizations
  69130. */
  69131. get optimizations(): SceneOptimization[];
  69132. /**
  69133. * Creates a new SceneOptimizer
  69134. * @param scene defines the scene to work on
  69135. * @param options defines the options to use with the SceneOptimizer
  69136. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69137. * @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)
  69138. */
  69139. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69140. /**
  69141. * Stops the current optimizer
  69142. */
  69143. stop(): void;
  69144. /**
  69145. * Reset the optimizer to initial step (current priority level = 0)
  69146. */
  69147. reset(): void;
  69148. /**
  69149. * Start the optimizer. By default it will try to reach a specific framerate
  69150. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69151. */
  69152. start(): void;
  69153. private _checkCurrentState;
  69154. /**
  69155. * Release all resources
  69156. */
  69157. dispose(): void;
  69158. /**
  69159. * Helper function to create a SceneOptimizer with one single line of code
  69160. * @param scene defines the scene to work on
  69161. * @param options defines the options to use with the SceneOptimizer
  69162. * @param onSuccess defines a callback to call on success
  69163. * @param onFailure defines a callback to call on failure
  69164. * @returns the new SceneOptimizer object
  69165. */
  69166. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69167. }
  69168. }
  69169. declare module BABYLON {
  69170. /**
  69171. * Class used to serialize a scene into a string
  69172. */
  69173. export class SceneSerializer {
  69174. /**
  69175. * Clear cache used by a previous serialization
  69176. */
  69177. static ClearCache(): void;
  69178. /**
  69179. * Serialize a scene into a JSON compatible object
  69180. * @param scene defines the scene to serialize
  69181. * @returns a JSON compatible object
  69182. */
  69183. static Serialize(scene: Scene): any;
  69184. /**
  69185. * Serialize a mesh into a JSON compatible object
  69186. * @param toSerialize defines the mesh to serialize
  69187. * @param withParents defines if parents must be serialized as well
  69188. * @param withChildren defines if children must be serialized as well
  69189. * @returns a JSON compatible object
  69190. */
  69191. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69192. }
  69193. }
  69194. declare module BABYLON {
  69195. /**
  69196. * Class used to host texture specific utilities
  69197. */
  69198. export class TextureTools {
  69199. /**
  69200. * Uses the GPU to create a copy texture rescaled at a given size
  69201. * @param texture Texture to copy from
  69202. * @param width defines the desired width
  69203. * @param height defines the desired height
  69204. * @param useBilinearMode defines if bilinear mode has to be used
  69205. * @return the generated texture
  69206. */
  69207. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69208. }
  69209. }
  69210. declare module BABYLON {
  69211. /**
  69212. * This represents the different options available for the video capture.
  69213. */
  69214. export interface VideoRecorderOptions {
  69215. /** Defines the mime type of the video. */
  69216. mimeType: string;
  69217. /** Defines the FPS the video should be recorded at. */
  69218. fps: number;
  69219. /** Defines the chunk size for the recording data. */
  69220. recordChunckSize: number;
  69221. /** The audio tracks to attach to the recording. */
  69222. audioTracks?: MediaStreamTrack[];
  69223. }
  69224. /**
  69225. * This can help with recording videos from BabylonJS.
  69226. * This is based on the available WebRTC functionalities of the browser.
  69227. *
  69228. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69229. */
  69230. export class VideoRecorder {
  69231. private static readonly _defaultOptions;
  69232. /**
  69233. * Returns whether or not the VideoRecorder is available in your browser.
  69234. * @param engine Defines the Babylon Engine.
  69235. * @returns true if supported otherwise false.
  69236. */
  69237. static IsSupported(engine: Engine): boolean;
  69238. private readonly _options;
  69239. private _canvas;
  69240. private _mediaRecorder;
  69241. private _recordedChunks;
  69242. private _fileName;
  69243. private _resolve;
  69244. private _reject;
  69245. /**
  69246. * True when a recording is already in progress.
  69247. */
  69248. get isRecording(): boolean;
  69249. /**
  69250. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69251. * @param engine Defines the BabylonJS Engine you wish to record.
  69252. * @param options Defines options that can be used to customize the capture.
  69253. */
  69254. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69255. /**
  69256. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69257. */
  69258. stopRecording(): void;
  69259. /**
  69260. * Starts recording the canvas for a max duration specified in parameters.
  69261. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69262. * If null no automatic download will start and you can rely on the promise to get the data back.
  69263. * @param maxDuration Defines the maximum recording time in seconds.
  69264. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69265. * @return A promise callback at the end of the recording with the video data in Blob.
  69266. */
  69267. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69268. /**
  69269. * Releases internal resources used during the recording.
  69270. */
  69271. dispose(): void;
  69272. private _handleDataAvailable;
  69273. private _handleError;
  69274. private _handleStop;
  69275. }
  69276. }
  69277. declare module BABYLON {
  69278. /**
  69279. * Class containing a set of static utilities functions for screenshots
  69280. */
  69281. export class ScreenshotTools {
  69282. /**
  69283. * Captures a screenshot of the current rendering
  69284. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69285. * @param engine defines the rendering engine
  69286. * @param camera defines the source camera
  69287. * @param size This parameter can be set to a single number or to an object with the
  69288. * following (optional) properties: precision, width, height. If a single number is passed,
  69289. * it will be used for both width and height. If an object is passed, the screenshot size
  69290. * will be derived from the parameters. The precision property is a multiplier allowing
  69291. * rendering at a higher or lower resolution
  69292. * @param successCallback defines the callback receives a single parameter which contains the
  69293. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69294. * src parameter of an <img> to display it
  69295. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69296. * Check your browser for supported MIME types
  69297. */
  69298. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69299. /**
  69300. * Captures a screenshot of the current rendering
  69301. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69302. * @param engine defines the rendering engine
  69303. * @param camera defines the source camera
  69304. * @param size This parameter can be set to a single number or to an object with the
  69305. * following (optional) properties: precision, width, height. If a single number is passed,
  69306. * it will be used for both width and height. If an object is passed, the screenshot size
  69307. * will be derived from the parameters. The precision property is a multiplier allowing
  69308. * rendering at a higher or lower resolution
  69309. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69310. * Check your browser for supported MIME types
  69311. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69312. * to the src parameter of an <img> to display it
  69313. */
  69314. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69315. /**
  69316. * Generates an image screenshot from the specified camera.
  69317. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69318. * @param engine The engine to use for rendering
  69319. * @param camera The camera to use for rendering
  69320. * @param size This parameter can be set to a single number or to an object with the
  69321. * following (optional) properties: precision, width, height. If a single number is passed,
  69322. * it will be used for both width and height. If an object is passed, the screenshot size
  69323. * will be derived from the parameters. The precision property is a multiplier allowing
  69324. * rendering at a higher or lower resolution
  69325. * @param successCallback The callback receives a single parameter which contains the
  69326. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69327. * src parameter of an <img> to display it
  69328. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69329. * Check your browser for supported MIME types
  69330. * @param samples Texture samples (default: 1)
  69331. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69332. * @param fileName A name for for the downloaded file.
  69333. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69334. */
  69335. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69336. /**
  69337. * Generates an image screenshot from the specified camera.
  69338. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69339. * @param engine The engine to use for rendering
  69340. * @param camera The camera to use for rendering
  69341. * @param size This parameter can be set to a single number or to an object with the
  69342. * following (optional) properties: precision, width, height. If a single number is passed,
  69343. * it will be used for both width and height. If an object is passed, the screenshot size
  69344. * will be derived from the parameters. The precision property is a multiplier allowing
  69345. * rendering at a higher or lower resolution
  69346. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69347. * Check your browser for supported MIME types
  69348. * @param samples Texture samples (default: 1)
  69349. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69350. * @param fileName A name for for the downloaded file.
  69351. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69352. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69353. * to the src parameter of an <img> to display it
  69354. */
  69355. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69356. /**
  69357. * Gets height and width for screenshot size
  69358. * @private
  69359. */
  69360. private static _getScreenshotSize;
  69361. }
  69362. }
  69363. declare module BABYLON {
  69364. /**
  69365. * Interface for a data buffer
  69366. */
  69367. export interface IDataBuffer {
  69368. /**
  69369. * Reads bytes from the data buffer.
  69370. * @param byteOffset The byte offset to read
  69371. * @param byteLength The byte length to read
  69372. * @returns A promise that resolves when the bytes are read
  69373. */
  69374. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69375. /**
  69376. * The byte length of the buffer.
  69377. */
  69378. readonly byteLength: number;
  69379. }
  69380. /**
  69381. * Utility class for reading from a data buffer
  69382. */
  69383. export class DataReader {
  69384. /**
  69385. * The data buffer associated with this data reader.
  69386. */
  69387. readonly buffer: IDataBuffer;
  69388. /**
  69389. * The current byte offset from the beginning of the data buffer.
  69390. */
  69391. byteOffset: number;
  69392. private _dataView;
  69393. private _dataByteOffset;
  69394. /**
  69395. * Constructor
  69396. * @param buffer The buffer to read
  69397. */
  69398. constructor(buffer: IDataBuffer);
  69399. /**
  69400. * Loads the given byte length.
  69401. * @param byteLength The byte length to load
  69402. * @returns A promise that resolves when the load is complete
  69403. */
  69404. loadAsync(byteLength: number): Promise<void>;
  69405. /**
  69406. * Read a unsigned 32-bit integer from the currently loaded data range.
  69407. * @returns The 32-bit integer read
  69408. */
  69409. readUint32(): number;
  69410. /**
  69411. * Read a byte array from the currently loaded data range.
  69412. * @param byteLength The byte length to read
  69413. * @returns The byte array read
  69414. */
  69415. readUint8Array(byteLength: number): Uint8Array;
  69416. /**
  69417. * Read a string from the currently loaded data range.
  69418. * @param byteLength The byte length to read
  69419. * @returns The string read
  69420. */
  69421. readString(byteLength: number): string;
  69422. /**
  69423. * Skips the given byte length the currently loaded data range.
  69424. * @param byteLength The byte length to skip
  69425. */
  69426. skipBytes(byteLength: number): void;
  69427. }
  69428. }
  69429. declare module BABYLON {
  69430. /**
  69431. * Class for storing data to local storage if available or in-memory storage otherwise
  69432. */
  69433. export class DataStorage {
  69434. private static _Storage;
  69435. private static _GetStorage;
  69436. /**
  69437. * Reads a string from the data storage
  69438. * @param key The key to read
  69439. * @param defaultValue The value if the key doesn't exist
  69440. * @returns The string value
  69441. */
  69442. static ReadString(key: string, defaultValue: string): string;
  69443. /**
  69444. * Writes a string to the data storage
  69445. * @param key The key to write
  69446. * @param value The value to write
  69447. */
  69448. static WriteString(key: string, value: string): void;
  69449. /**
  69450. * Reads a boolean from the data storage
  69451. * @param key The key to read
  69452. * @param defaultValue The value if the key doesn't exist
  69453. * @returns The boolean value
  69454. */
  69455. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69456. /**
  69457. * Writes a boolean to the data storage
  69458. * @param key The key to write
  69459. * @param value The value to write
  69460. */
  69461. static WriteBoolean(key: string, value: boolean): void;
  69462. /**
  69463. * Reads a number from the data storage
  69464. * @param key The key to read
  69465. * @param defaultValue The value if the key doesn't exist
  69466. * @returns The number value
  69467. */
  69468. static ReadNumber(key: string, defaultValue: number): number;
  69469. /**
  69470. * Writes a number to the data storage
  69471. * @param key The key to write
  69472. * @param value The value to write
  69473. */
  69474. static WriteNumber(key: string, value: number): void;
  69475. }
  69476. }
  69477. declare module BABYLON {
  69478. /**
  69479. * Options used for hit testing
  69480. */
  69481. export interface IWebXRLegacyHitTestOptions {
  69482. /**
  69483. * Only test when user interacted with the scene. Default - hit test every frame
  69484. */
  69485. testOnPointerDownOnly?: boolean;
  69486. /**
  69487. * The node to use to transform the local results to world coordinates
  69488. */
  69489. worldParentNode?: TransformNode;
  69490. }
  69491. /**
  69492. * Interface defining the babylon result of raycasting/hit-test
  69493. */
  69494. export interface IWebXRLegacyHitResult {
  69495. /**
  69496. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69497. */
  69498. transformationMatrix: Matrix;
  69499. /**
  69500. * The native hit test result
  69501. */
  69502. xrHitResult: XRHitResult | XRHitTestResult;
  69503. }
  69504. /**
  69505. * The currently-working hit-test module.
  69506. * Hit test (or Ray-casting) is used to interact with the real world.
  69507. * For further information read here - https://github.com/immersive-web/hit-test
  69508. */
  69509. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69510. /**
  69511. * options to use when constructing this feature
  69512. */
  69513. readonly options: IWebXRLegacyHitTestOptions;
  69514. private _direction;
  69515. private _mat;
  69516. private _onSelectEnabled;
  69517. private _origin;
  69518. /**
  69519. * The module's name
  69520. */
  69521. static readonly Name: string;
  69522. /**
  69523. * The (Babylon) version of this module.
  69524. * This is an integer representing the implementation version.
  69525. * This number does not correspond to the WebXR specs version
  69526. */
  69527. static readonly Version: number;
  69528. /**
  69529. * Populated with the last native XR Hit Results
  69530. */
  69531. lastNativeXRHitResults: XRHitResult[];
  69532. /**
  69533. * Triggered when new babylon (transformed) hit test results are available
  69534. */
  69535. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69536. /**
  69537. * Creates a new instance of the (legacy version) hit test feature
  69538. * @param _xrSessionManager an instance of WebXRSessionManager
  69539. * @param options options to use when constructing this feature
  69540. */
  69541. constructor(_xrSessionManager: WebXRSessionManager,
  69542. /**
  69543. * options to use when constructing this feature
  69544. */
  69545. options?: IWebXRLegacyHitTestOptions);
  69546. /**
  69547. * execute a hit test with an XR Ray
  69548. *
  69549. * @param xrSession a native xrSession that will execute this hit test
  69550. * @param xrRay the ray (position and direction) to use for ray-casting
  69551. * @param referenceSpace native XR reference space to use for the hit-test
  69552. * @param filter filter function that will filter the results
  69553. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69554. */
  69555. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69556. /**
  69557. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69558. * @param event the (select) event to use to select with
  69559. * @param referenceSpace the reference space to use for this hit test
  69560. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69561. */
  69562. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69563. /**
  69564. * attach this feature
  69565. * Will usually be called by the features manager
  69566. *
  69567. * @returns true if successful.
  69568. */
  69569. attach(): boolean;
  69570. /**
  69571. * detach this feature.
  69572. * Will usually be called by the features manager
  69573. *
  69574. * @returns true if successful.
  69575. */
  69576. detach(): boolean;
  69577. /**
  69578. * Dispose this feature and all of the resources attached
  69579. */
  69580. dispose(): void;
  69581. protected _onXRFrame(frame: XRFrame): void;
  69582. private _onHitTestResults;
  69583. private _onSelect;
  69584. }
  69585. }
  69586. declare module BABYLON {
  69587. /**
  69588. * Options used in the plane detector module
  69589. */
  69590. export interface IWebXRPlaneDetectorOptions {
  69591. /**
  69592. * The node to use to transform the local results to world coordinates
  69593. */
  69594. worldParentNode?: TransformNode;
  69595. }
  69596. /**
  69597. * A babylon interface for a WebXR plane.
  69598. * A Plane is actually a polygon, built from N points in space
  69599. *
  69600. * Supported in chrome 79, not supported in canary 81 ATM
  69601. */
  69602. export interface IWebXRPlane {
  69603. /**
  69604. * a babylon-assigned ID for this polygon
  69605. */
  69606. id: number;
  69607. /**
  69608. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69609. */
  69610. polygonDefinition: Array<Vector3>;
  69611. /**
  69612. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69613. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69614. */
  69615. transformationMatrix: Matrix;
  69616. /**
  69617. * the native xr-plane object
  69618. */
  69619. xrPlane: XRPlane;
  69620. }
  69621. /**
  69622. * The plane detector is used to detect planes in the real world when in AR
  69623. * For more information see https://github.com/immersive-web/real-world-geometry/
  69624. */
  69625. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69626. private _options;
  69627. private _detectedPlanes;
  69628. private _enabled;
  69629. private _lastFrameDetected;
  69630. /**
  69631. * The module's name
  69632. */
  69633. static readonly Name: string;
  69634. /**
  69635. * The (Babylon) version of this module.
  69636. * This is an integer representing the implementation version.
  69637. * This number does not correspond to the WebXR specs version
  69638. */
  69639. static readonly Version: number;
  69640. /**
  69641. * Observers registered here will be executed when a new plane was added to the session
  69642. */
  69643. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69644. /**
  69645. * Observers registered here will be executed when a plane is no longer detected in the session
  69646. */
  69647. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69648. /**
  69649. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69650. * This can execute N times every frame
  69651. */
  69652. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69653. /**
  69654. * construct a new Plane Detector
  69655. * @param _xrSessionManager an instance of xr Session manager
  69656. * @param _options configuration to use when constructing this feature
  69657. */
  69658. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69659. /**
  69660. * Dispose this feature and all of the resources attached
  69661. */
  69662. dispose(): void;
  69663. protected _onXRFrame(frame: XRFrame): void;
  69664. private _init;
  69665. private _updatePlaneWithXRPlane;
  69666. /**
  69667. * avoiding using Array.find for global support.
  69668. * @param xrPlane the plane to find in the array
  69669. */
  69670. private findIndexInPlaneArray;
  69671. }
  69672. }
  69673. declare module BABYLON {
  69674. /**
  69675. * Configuration options of the anchor system
  69676. */
  69677. export interface IWebXRAnchorSystemOptions {
  69678. /**
  69679. * Should a new anchor be added every time a select event is triggered
  69680. */
  69681. addAnchorOnSelect?: boolean;
  69682. /**
  69683. * should the anchor system use plane detection.
  69684. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69685. */
  69686. usePlaneDetection?: boolean;
  69687. /**
  69688. * a node that will be used to convert local to world coordinates
  69689. */
  69690. worldParentNode?: TransformNode;
  69691. }
  69692. /**
  69693. * A babylon container for an XR Anchor
  69694. */
  69695. export interface IWebXRAnchor {
  69696. /**
  69697. * A babylon-assigned ID for this anchor
  69698. */
  69699. id: number;
  69700. /**
  69701. * Transformation matrix to apply to an object attached to this anchor
  69702. */
  69703. transformationMatrix: Matrix;
  69704. /**
  69705. * The native anchor object
  69706. */
  69707. xrAnchor: XRAnchor;
  69708. }
  69709. /**
  69710. * An implementation of the anchor system of WebXR.
  69711. * Note that the current documented implementation is not available in any browser. Future implementations
  69712. * will use the frame to create an anchor and not the session or a detected plane
  69713. * For further information see https://github.com/immersive-web/anchors/
  69714. */
  69715. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69716. private _options;
  69717. private _enabled;
  69718. private _hitTestModule;
  69719. private _lastFrameDetected;
  69720. private _onSelect;
  69721. private _planeDetector;
  69722. private _trackedAnchors;
  69723. /**
  69724. * The module's name
  69725. */
  69726. static readonly Name: string;
  69727. /**
  69728. * The (Babylon) version of this module.
  69729. * This is an integer representing the implementation version.
  69730. * This number does not correspond to the WebXR specs version
  69731. */
  69732. static readonly Version: number;
  69733. /**
  69734. * Observers registered here will be executed when a new anchor was added to the session
  69735. */
  69736. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69737. /**
  69738. * Observers registered here will be executed when an anchor was removed from the session
  69739. */
  69740. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69741. /**
  69742. * Observers registered here will be executed when an existing anchor updates
  69743. * This can execute N times every frame
  69744. */
  69745. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69746. /**
  69747. * constructs a new anchor system
  69748. * @param _xrSessionManager an instance of WebXRSessionManager
  69749. * @param _options configuration object for this feature
  69750. */
  69751. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69752. /**
  69753. * Add anchor at a specific XR point.
  69754. *
  69755. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69756. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69757. * @returns a promise the fulfills when the anchor was created
  69758. */
  69759. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69760. /**
  69761. * attach this feature
  69762. * Will usually be called by the features manager
  69763. *
  69764. * @returns true if successful.
  69765. */
  69766. attach(): boolean;
  69767. /**
  69768. * detach this feature.
  69769. * Will usually be called by the features manager
  69770. *
  69771. * @returns true if successful.
  69772. */
  69773. detach(): boolean;
  69774. /**
  69775. * Dispose this feature and all of the resources attached
  69776. */
  69777. dispose(): void;
  69778. /**
  69779. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69780. * @param hitTestModule the hit-test module to use.
  69781. */
  69782. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69783. /**
  69784. * set the plane detector to use in order to create anchors from frames
  69785. * @param planeDetector the plane-detector module to use
  69786. * @param enable enable plane-anchors. default is true
  69787. */
  69788. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69789. protected _onXRFrame(frame: XRFrame): void;
  69790. /**
  69791. * avoiding using Array.find for global support.
  69792. * @param xrAnchor the plane to find in the array
  69793. */
  69794. private _findIndexInAnchorArray;
  69795. private _updateAnchorWithXRFrame;
  69796. }
  69797. }
  69798. declare module BABYLON {
  69799. /**
  69800. * Options interface for the background remover plugin
  69801. */
  69802. export interface IWebXRBackgroundRemoverOptions {
  69803. /**
  69804. * Further background meshes to disable when entering AR
  69805. */
  69806. backgroundMeshes?: AbstractMesh[];
  69807. /**
  69808. * flags to configure the removal of the environment helper.
  69809. * If not set, the entire background will be removed. If set, flags should be set as well.
  69810. */
  69811. environmentHelperRemovalFlags?: {
  69812. /**
  69813. * Should the skybox be removed (default false)
  69814. */
  69815. skyBox?: boolean;
  69816. /**
  69817. * Should the ground be removed (default false)
  69818. */
  69819. ground?: boolean;
  69820. };
  69821. /**
  69822. * don't disable the environment helper
  69823. */
  69824. ignoreEnvironmentHelper?: boolean;
  69825. }
  69826. /**
  69827. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69828. */
  69829. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69830. /**
  69831. * read-only options to be used in this module
  69832. */
  69833. readonly options: IWebXRBackgroundRemoverOptions;
  69834. /**
  69835. * The module's name
  69836. */
  69837. static readonly Name: string;
  69838. /**
  69839. * The (Babylon) version of this module.
  69840. * This is an integer representing the implementation version.
  69841. * This number does not correspond to the WebXR specs version
  69842. */
  69843. static readonly Version: number;
  69844. /**
  69845. * registered observers will be triggered when the background state changes
  69846. */
  69847. onBackgroundStateChangedObservable: Observable<boolean>;
  69848. /**
  69849. * constructs a new background remover module
  69850. * @param _xrSessionManager the session manager for this module
  69851. * @param options read-only options to be used in this module
  69852. */
  69853. constructor(_xrSessionManager: WebXRSessionManager,
  69854. /**
  69855. * read-only options to be used in this module
  69856. */
  69857. options?: IWebXRBackgroundRemoverOptions);
  69858. /**
  69859. * attach this feature
  69860. * Will usually be called by the features manager
  69861. *
  69862. * @returns true if successful.
  69863. */
  69864. attach(): boolean;
  69865. /**
  69866. * detach this feature.
  69867. * Will usually be called by the features manager
  69868. *
  69869. * @returns true if successful.
  69870. */
  69871. detach(): boolean;
  69872. /**
  69873. * Dispose this feature and all of the resources attached
  69874. */
  69875. dispose(): void;
  69876. protected _onXRFrame(_xrFrame: XRFrame): void;
  69877. private _setBackgroundState;
  69878. }
  69879. }
  69880. declare module BABYLON {
  69881. /**
  69882. * Options for the controller physics feature
  69883. */
  69884. export class IWebXRControllerPhysicsOptions {
  69885. /**
  69886. * Should the headset get its own impostor
  69887. */
  69888. enableHeadsetImpostor?: boolean;
  69889. /**
  69890. * Optional parameters for the headset impostor
  69891. */
  69892. headsetImpostorParams?: {
  69893. /**
  69894. * The type of impostor to create. Default is sphere
  69895. */
  69896. impostorType: number;
  69897. /**
  69898. * the size of the impostor. Defaults to 10cm
  69899. */
  69900. impostorSize?: number | {
  69901. width: number;
  69902. height: number;
  69903. depth: number;
  69904. };
  69905. /**
  69906. * Friction definitions
  69907. */
  69908. friction?: number;
  69909. /**
  69910. * Restitution
  69911. */
  69912. restitution?: number;
  69913. };
  69914. /**
  69915. * The physics properties of the future impostors
  69916. */
  69917. physicsProperties?: {
  69918. /**
  69919. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69920. * Note that this requires a physics engine that supports mesh impostors!
  69921. */
  69922. useControllerMesh?: boolean;
  69923. /**
  69924. * The type of impostor to create. Default is sphere
  69925. */
  69926. impostorType?: number;
  69927. /**
  69928. * the size of the impostor. Defaults to 10cm
  69929. */
  69930. impostorSize?: number | {
  69931. width: number;
  69932. height: number;
  69933. depth: number;
  69934. };
  69935. /**
  69936. * Friction definitions
  69937. */
  69938. friction?: number;
  69939. /**
  69940. * Restitution
  69941. */
  69942. restitution?: number;
  69943. };
  69944. /**
  69945. * the xr input to use with this pointer selection
  69946. */
  69947. xrInput: WebXRInput;
  69948. }
  69949. /**
  69950. * Add physics impostor to your webxr controllers,
  69951. * including naive calculation of their linear and angular velocity
  69952. */
  69953. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69954. private readonly _options;
  69955. private _attachController;
  69956. private _controllers;
  69957. private _debugMode;
  69958. private _delta;
  69959. private _headsetImpostor?;
  69960. private _headsetMesh?;
  69961. private _lastTimestamp;
  69962. private _tmpQuaternion;
  69963. private _tmpVector;
  69964. /**
  69965. * The module's name
  69966. */
  69967. static readonly Name: string;
  69968. /**
  69969. * The (Babylon) version of this module.
  69970. * This is an integer representing the implementation version.
  69971. * This number does not correspond to the webxr specs version
  69972. */
  69973. static readonly Version: number;
  69974. /**
  69975. * Construct a new Controller Physics Feature
  69976. * @param _xrSessionManager the corresponding xr session manager
  69977. * @param _options options to create this feature with
  69978. */
  69979. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69980. /**
  69981. * @hidden
  69982. * enable debugging - will show console outputs and the impostor mesh
  69983. */
  69984. _enablePhysicsDebug(): void;
  69985. /**
  69986. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69987. * @param xrController the controller to add
  69988. */
  69989. addController(xrController: WebXRInputSource): void;
  69990. /**
  69991. * attach this feature
  69992. * Will usually be called by the features manager
  69993. *
  69994. * @returns true if successful.
  69995. */
  69996. attach(): boolean;
  69997. /**
  69998. * detach this feature.
  69999. * Will usually be called by the features manager
  70000. *
  70001. * @returns true if successful.
  70002. */
  70003. detach(): boolean;
  70004. /**
  70005. * Get the headset impostor, if enabled
  70006. * @returns the impostor
  70007. */
  70008. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70009. /**
  70010. * Get the physics impostor of a specific controller.
  70011. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70012. * @param controller the controller or the controller id of which to get the impostor
  70013. * @returns the impostor or null
  70014. */
  70015. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70016. /**
  70017. * Update the physics properties provided in the constructor
  70018. * @param newProperties the new properties object
  70019. */
  70020. setPhysicsProperties(newProperties: {
  70021. impostorType?: number;
  70022. impostorSize?: number | {
  70023. width: number;
  70024. height: number;
  70025. depth: number;
  70026. };
  70027. friction?: number;
  70028. restitution?: number;
  70029. }): void;
  70030. protected _onXRFrame(_xrFrame: any): void;
  70031. private _detachController;
  70032. }
  70033. }
  70034. declare module BABYLON {
  70035. /**
  70036. * Options used for hit testing (version 2)
  70037. */
  70038. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70039. /**
  70040. * Do not create a permanent hit test. Will usually be used when only
  70041. * transient inputs are needed.
  70042. */
  70043. disablePermanentHitTest?: boolean;
  70044. /**
  70045. * Enable transient (for example touch-based) hit test inspections
  70046. */
  70047. enableTransientHitTest?: boolean;
  70048. /**
  70049. * Offset ray for the permanent hit test
  70050. */
  70051. offsetRay?: Vector3;
  70052. /**
  70053. * Offset ray for the transient hit test
  70054. */
  70055. transientOffsetRay?: Vector3;
  70056. /**
  70057. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70058. */
  70059. useReferenceSpace?: boolean;
  70060. }
  70061. /**
  70062. * Interface defining the babylon result of hit-test
  70063. */
  70064. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70065. /**
  70066. * The input source that generated this hit test (if transient)
  70067. */
  70068. inputSource?: XRInputSource;
  70069. /**
  70070. * Is this a transient hit test
  70071. */
  70072. isTransient?: boolean;
  70073. /**
  70074. * Position of the hit test result
  70075. */
  70076. position: Vector3;
  70077. /**
  70078. * Rotation of the hit test result
  70079. */
  70080. rotationQuaternion: Quaternion;
  70081. }
  70082. /**
  70083. * The currently-working hit-test module.
  70084. * Hit test (or Ray-casting) is used to interact with the real world.
  70085. * For further information read here - https://github.com/immersive-web/hit-test
  70086. *
  70087. * Tested on chrome (mobile) 80.
  70088. */
  70089. export class WebXRHitTest extends WebXRAbstractFeature {
  70090. /**
  70091. * options to use when constructing this feature
  70092. */
  70093. readonly options: IWebXRHitTestOptions;
  70094. private _tmpMat;
  70095. private _tmpPos;
  70096. private _tmpQuat;
  70097. private _transientXrHitTestSource;
  70098. private _xrHitTestSource;
  70099. private initHitTestSource;
  70100. /**
  70101. * The module's name
  70102. */
  70103. static readonly Name: string;
  70104. /**
  70105. * The (Babylon) version of this module.
  70106. * This is an integer representing the implementation version.
  70107. * This number does not correspond to the WebXR specs version
  70108. */
  70109. static readonly Version: number;
  70110. /**
  70111. * When set to true, each hit test will have its own position/rotation objects
  70112. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70113. * the developers will clone them or copy them as they see fit.
  70114. */
  70115. autoCloneTransformation: boolean;
  70116. /**
  70117. * Populated with the last native XR Hit Results
  70118. */
  70119. lastNativeXRHitResults: XRHitResult[];
  70120. /**
  70121. * Triggered when new babylon (transformed) hit test results are available
  70122. */
  70123. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70124. /**
  70125. * Use this to temporarily pause hit test checks.
  70126. */
  70127. paused: boolean;
  70128. /**
  70129. * Creates a new instance of the hit test feature
  70130. * @param _xrSessionManager an instance of WebXRSessionManager
  70131. * @param options options to use when constructing this feature
  70132. */
  70133. constructor(_xrSessionManager: WebXRSessionManager,
  70134. /**
  70135. * options to use when constructing this feature
  70136. */
  70137. options?: IWebXRHitTestOptions);
  70138. /**
  70139. * attach this feature
  70140. * Will usually be called by the features manager
  70141. *
  70142. * @returns true if successful.
  70143. */
  70144. attach(): boolean;
  70145. /**
  70146. * detach this feature.
  70147. * Will usually be called by the features manager
  70148. *
  70149. * @returns true if successful.
  70150. */
  70151. detach(): boolean;
  70152. /**
  70153. * Dispose this feature and all of the resources attached
  70154. */
  70155. dispose(): void;
  70156. protected _onXRFrame(frame: XRFrame): void;
  70157. private _processWebXRHitTestResult;
  70158. }
  70159. }
  70160. declare module BABYLON {
  70161. /**
  70162. * The motion controller class for all microsoft mixed reality controllers
  70163. */
  70164. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70165. protected readonly _mapping: {
  70166. defaultButton: {
  70167. valueNodeName: string;
  70168. unpressedNodeName: string;
  70169. pressedNodeName: string;
  70170. };
  70171. defaultAxis: {
  70172. valueNodeName: string;
  70173. minNodeName: string;
  70174. maxNodeName: string;
  70175. };
  70176. buttons: {
  70177. "xr-standard-trigger": {
  70178. rootNodeName: string;
  70179. componentProperty: string;
  70180. states: string[];
  70181. };
  70182. "xr-standard-squeeze": {
  70183. rootNodeName: string;
  70184. componentProperty: string;
  70185. states: string[];
  70186. };
  70187. "xr-standard-touchpad": {
  70188. rootNodeName: string;
  70189. labelAnchorNodeName: string;
  70190. touchPointNodeName: string;
  70191. };
  70192. "xr-standard-thumbstick": {
  70193. rootNodeName: string;
  70194. componentProperty: string;
  70195. states: string[];
  70196. };
  70197. };
  70198. axes: {
  70199. "xr-standard-touchpad": {
  70200. "x-axis": {
  70201. rootNodeName: string;
  70202. };
  70203. "y-axis": {
  70204. rootNodeName: string;
  70205. };
  70206. };
  70207. "xr-standard-thumbstick": {
  70208. "x-axis": {
  70209. rootNodeName: string;
  70210. };
  70211. "y-axis": {
  70212. rootNodeName: string;
  70213. };
  70214. };
  70215. };
  70216. };
  70217. /**
  70218. * The base url used to load the left and right controller models
  70219. */
  70220. static MODEL_BASE_URL: string;
  70221. /**
  70222. * The name of the left controller model file
  70223. */
  70224. static MODEL_LEFT_FILENAME: string;
  70225. /**
  70226. * The name of the right controller model file
  70227. */
  70228. static MODEL_RIGHT_FILENAME: string;
  70229. profileId: string;
  70230. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70231. protected _getFilenameAndPath(): {
  70232. filename: string;
  70233. path: string;
  70234. };
  70235. protected _getModelLoadingConstraints(): boolean;
  70236. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70237. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70238. protected _updateModel(): void;
  70239. }
  70240. }
  70241. declare module BABYLON {
  70242. /**
  70243. * The motion controller class for oculus touch (quest, rift).
  70244. * This class supports legacy mapping as well the standard xr mapping
  70245. */
  70246. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70247. private _forceLegacyControllers;
  70248. private _modelRootNode;
  70249. /**
  70250. * The base url used to load the left and right controller models
  70251. */
  70252. static MODEL_BASE_URL: string;
  70253. /**
  70254. * The name of the left controller model file
  70255. */
  70256. static MODEL_LEFT_FILENAME: string;
  70257. /**
  70258. * The name of the right controller model file
  70259. */
  70260. static MODEL_RIGHT_FILENAME: string;
  70261. /**
  70262. * Base Url for the Quest controller model.
  70263. */
  70264. static QUEST_MODEL_BASE_URL: string;
  70265. profileId: string;
  70266. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70267. protected _getFilenameAndPath(): {
  70268. filename: string;
  70269. path: string;
  70270. };
  70271. protected _getModelLoadingConstraints(): boolean;
  70272. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70273. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70274. protected _updateModel(): void;
  70275. /**
  70276. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70277. * between the touch and touch 2.
  70278. */
  70279. private _isQuest;
  70280. }
  70281. }
  70282. declare module BABYLON {
  70283. /**
  70284. * The motion controller class for the standard HTC-Vive controllers
  70285. */
  70286. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70287. private _modelRootNode;
  70288. /**
  70289. * The base url used to load the left and right controller models
  70290. */
  70291. static MODEL_BASE_URL: string;
  70292. /**
  70293. * File name for the controller model.
  70294. */
  70295. static MODEL_FILENAME: string;
  70296. profileId: string;
  70297. /**
  70298. * Create a new Vive motion controller object
  70299. * @param scene the scene to use to create this controller
  70300. * @param gamepadObject the corresponding gamepad object
  70301. * @param handness the handness of the controller
  70302. */
  70303. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70304. protected _getFilenameAndPath(): {
  70305. filename: string;
  70306. path: string;
  70307. };
  70308. protected _getModelLoadingConstraints(): boolean;
  70309. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70310. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70311. protected _updateModel(): void;
  70312. }
  70313. }
  70314. declare module BABYLON {
  70315. /**
  70316. * A cursor which tracks a point on a path
  70317. */
  70318. export class PathCursor {
  70319. private path;
  70320. /**
  70321. * Stores path cursor callbacks for when an onchange event is triggered
  70322. */
  70323. private _onchange;
  70324. /**
  70325. * The value of the path cursor
  70326. */
  70327. value: number;
  70328. /**
  70329. * The animation array of the path cursor
  70330. */
  70331. animations: Animation[];
  70332. /**
  70333. * Initializes the path cursor
  70334. * @param path The path to track
  70335. */
  70336. constructor(path: Path2);
  70337. /**
  70338. * Gets the cursor point on the path
  70339. * @returns A point on the path cursor at the cursor location
  70340. */
  70341. getPoint(): Vector3;
  70342. /**
  70343. * Moves the cursor ahead by the step amount
  70344. * @param step The amount to move the cursor forward
  70345. * @returns This path cursor
  70346. */
  70347. moveAhead(step?: number): PathCursor;
  70348. /**
  70349. * Moves the cursor behind by the step amount
  70350. * @param step The amount to move the cursor back
  70351. * @returns This path cursor
  70352. */
  70353. moveBack(step?: number): PathCursor;
  70354. /**
  70355. * Moves the cursor by the step amount
  70356. * If the step amount is greater than one, an exception is thrown
  70357. * @param step The amount to move the cursor
  70358. * @returns This path cursor
  70359. */
  70360. move(step: number): PathCursor;
  70361. /**
  70362. * Ensures that the value is limited between zero and one
  70363. * @returns This path cursor
  70364. */
  70365. private ensureLimits;
  70366. /**
  70367. * Runs onchange callbacks on change (used by the animation engine)
  70368. * @returns This path cursor
  70369. */
  70370. private raiseOnChange;
  70371. /**
  70372. * Executes a function on change
  70373. * @param f A path cursor onchange callback
  70374. * @returns This path cursor
  70375. */
  70376. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70377. }
  70378. }
  70379. declare module BABYLON {
  70380. /** @hidden */
  70381. export var blurPixelShader: {
  70382. name: string;
  70383. shader: string;
  70384. };
  70385. }
  70386. declare module BABYLON {
  70387. /** @hidden */
  70388. export var pointCloudVertexDeclaration: {
  70389. name: string;
  70390. shader: string;
  70391. };
  70392. }
  70393. // Mixins
  70394. interface Window {
  70395. mozIndexedDB: IDBFactory;
  70396. webkitIndexedDB: IDBFactory;
  70397. msIndexedDB: IDBFactory;
  70398. webkitURL: typeof URL;
  70399. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70400. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70401. WebGLRenderingContext: WebGLRenderingContext;
  70402. MSGesture: MSGesture;
  70403. CANNON: any;
  70404. AudioContext: AudioContext;
  70405. webkitAudioContext: AudioContext;
  70406. PointerEvent: any;
  70407. Math: Math;
  70408. Uint8Array: Uint8ArrayConstructor;
  70409. Float32Array: Float32ArrayConstructor;
  70410. mozURL: typeof URL;
  70411. msURL: typeof URL;
  70412. VRFrameData: any; // WebVR, from specs 1.1
  70413. DracoDecoderModule: any;
  70414. setImmediate(handler: (...args: any[]) => void): number;
  70415. }
  70416. interface HTMLCanvasElement {
  70417. requestPointerLock(): void;
  70418. msRequestPointerLock?(): void;
  70419. mozRequestPointerLock?(): void;
  70420. webkitRequestPointerLock?(): void;
  70421. /** Track wether a record is in progress */
  70422. isRecording: boolean;
  70423. /** Capture Stream method defined by some browsers */
  70424. captureStream(fps?: number): MediaStream;
  70425. }
  70426. interface CanvasRenderingContext2D {
  70427. msImageSmoothingEnabled: boolean;
  70428. }
  70429. interface MouseEvent {
  70430. mozMovementX: number;
  70431. mozMovementY: number;
  70432. webkitMovementX: number;
  70433. webkitMovementY: number;
  70434. msMovementX: number;
  70435. msMovementY: number;
  70436. }
  70437. interface Navigator {
  70438. mozGetVRDevices: (any: any) => any;
  70439. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70440. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70441. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70442. webkitGetGamepads(): Gamepad[];
  70443. msGetGamepads(): Gamepad[];
  70444. webkitGamepads(): Gamepad[];
  70445. }
  70446. interface HTMLVideoElement {
  70447. mozSrcObject: any;
  70448. }
  70449. interface Math {
  70450. fround(x: number): number;
  70451. imul(a: number, b: number): number;
  70452. }
  70453. interface WebGLRenderingContext {
  70454. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70455. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70456. vertexAttribDivisor(index: number, divisor: number): void;
  70457. createVertexArray(): any;
  70458. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70459. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70460. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70461. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70462. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70463. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70464. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70465. // Queries
  70466. createQuery(): WebGLQuery;
  70467. deleteQuery(query: WebGLQuery): void;
  70468. beginQuery(target: number, query: WebGLQuery): void;
  70469. endQuery(target: number): void;
  70470. getQueryParameter(query: WebGLQuery, pname: number): any;
  70471. getQuery(target: number, pname: number): any;
  70472. MAX_SAMPLES: number;
  70473. RGBA8: number;
  70474. READ_FRAMEBUFFER: number;
  70475. DRAW_FRAMEBUFFER: number;
  70476. UNIFORM_BUFFER: number;
  70477. HALF_FLOAT_OES: number;
  70478. RGBA16F: number;
  70479. RGBA32F: number;
  70480. R32F: number;
  70481. RG32F: number;
  70482. RGB32F: number;
  70483. R16F: number;
  70484. RG16F: number;
  70485. RGB16F: number;
  70486. RED: number;
  70487. RG: number;
  70488. R8: number;
  70489. RG8: number;
  70490. UNSIGNED_INT_24_8: number;
  70491. DEPTH24_STENCIL8: number;
  70492. MIN: number;
  70493. MAX: number;
  70494. /* Multiple Render Targets */
  70495. drawBuffers(buffers: number[]): void;
  70496. readBuffer(src: number): void;
  70497. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70498. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70499. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70500. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70501. // Occlusion Query
  70502. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70503. ANY_SAMPLES_PASSED: number;
  70504. QUERY_RESULT_AVAILABLE: number;
  70505. QUERY_RESULT: number;
  70506. }
  70507. interface WebGLProgram {
  70508. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70509. }
  70510. interface EXT_disjoint_timer_query {
  70511. QUERY_COUNTER_BITS_EXT: number;
  70512. TIME_ELAPSED_EXT: number;
  70513. TIMESTAMP_EXT: number;
  70514. GPU_DISJOINT_EXT: number;
  70515. QUERY_RESULT_EXT: number;
  70516. QUERY_RESULT_AVAILABLE_EXT: number;
  70517. queryCounterEXT(query: WebGLQuery, target: number): void;
  70518. createQueryEXT(): WebGLQuery;
  70519. beginQueryEXT(target: number, query: WebGLQuery): void;
  70520. endQueryEXT(target: number): void;
  70521. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70522. deleteQueryEXT(query: WebGLQuery): void;
  70523. }
  70524. interface WebGLUniformLocation {
  70525. _currentState: any;
  70526. }
  70527. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70528. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70529. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70530. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70531. interface WebGLRenderingContext {
  70532. readonly RASTERIZER_DISCARD: number;
  70533. readonly DEPTH_COMPONENT24: number;
  70534. readonly TEXTURE_3D: number;
  70535. readonly TEXTURE_2D_ARRAY: number;
  70536. readonly TEXTURE_COMPARE_FUNC: number;
  70537. readonly TEXTURE_COMPARE_MODE: number;
  70538. readonly COMPARE_REF_TO_TEXTURE: number;
  70539. readonly TEXTURE_WRAP_R: number;
  70540. readonly HALF_FLOAT: number;
  70541. readonly RGB8: number;
  70542. readonly RED_INTEGER: number;
  70543. readonly RG_INTEGER: number;
  70544. readonly RGB_INTEGER: number;
  70545. readonly RGBA_INTEGER: number;
  70546. readonly R8_SNORM: number;
  70547. readonly RG8_SNORM: number;
  70548. readonly RGB8_SNORM: number;
  70549. readonly RGBA8_SNORM: number;
  70550. readonly R8I: number;
  70551. readonly RG8I: number;
  70552. readonly RGB8I: number;
  70553. readonly RGBA8I: number;
  70554. readonly R8UI: number;
  70555. readonly RG8UI: number;
  70556. readonly RGB8UI: number;
  70557. readonly RGBA8UI: number;
  70558. readonly R16I: number;
  70559. readonly RG16I: number;
  70560. readonly RGB16I: number;
  70561. readonly RGBA16I: number;
  70562. readonly R16UI: number;
  70563. readonly RG16UI: number;
  70564. readonly RGB16UI: number;
  70565. readonly RGBA16UI: number;
  70566. readonly R32I: number;
  70567. readonly RG32I: number;
  70568. readonly RGB32I: number;
  70569. readonly RGBA32I: number;
  70570. readonly R32UI: number;
  70571. readonly RG32UI: number;
  70572. readonly RGB32UI: number;
  70573. readonly RGBA32UI: number;
  70574. readonly RGB10_A2UI: number;
  70575. readonly R11F_G11F_B10F: number;
  70576. readonly RGB9_E5: number;
  70577. readonly RGB10_A2: number;
  70578. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70579. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70580. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70581. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70582. readonly DEPTH_COMPONENT32F: number;
  70583. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70584. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70585. 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;
  70586. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70587. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70588. readonly TRANSFORM_FEEDBACK: number;
  70589. readonly INTERLEAVED_ATTRIBS: number;
  70590. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70591. createTransformFeedback(): WebGLTransformFeedback;
  70592. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70593. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70594. beginTransformFeedback(primitiveMode: number): void;
  70595. endTransformFeedback(): void;
  70596. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70597. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70598. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70599. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70600. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70601. }
  70602. interface ImageBitmap {
  70603. readonly width: number;
  70604. readonly height: number;
  70605. close(): void;
  70606. }
  70607. interface WebGLQuery extends WebGLObject {
  70608. }
  70609. declare var WebGLQuery: {
  70610. prototype: WebGLQuery;
  70611. new(): WebGLQuery;
  70612. };
  70613. interface WebGLSampler extends WebGLObject {
  70614. }
  70615. declare var WebGLSampler: {
  70616. prototype: WebGLSampler;
  70617. new(): WebGLSampler;
  70618. };
  70619. interface WebGLSync extends WebGLObject {
  70620. }
  70621. declare var WebGLSync: {
  70622. prototype: WebGLSync;
  70623. new(): WebGLSync;
  70624. };
  70625. interface WebGLTransformFeedback extends WebGLObject {
  70626. }
  70627. declare var WebGLTransformFeedback: {
  70628. prototype: WebGLTransformFeedback;
  70629. new(): WebGLTransformFeedback;
  70630. };
  70631. interface WebGLVertexArrayObject extends WebGLObject {
  70632. }
  70633. declare var WebGLVertexArrayObject: {
  70634. prototype: WebGLVertexArrayObject;
  70635. new(): WebGLVertexArrayObject;
  70636. };
  70637. // Type definitions for WebVR API
  70638. // Project: https://w3c.github.io/webvr/
  70639. // Definitions by: six a <https://github.com/lostfictions>
  70640. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70641. interface VRDisplay extends EventTarget {
  70642. /**
  70643. * Dictionary of capabilities describing the VRDisplay.
  70644. */
  70645. readonly capabilities: VRDisplayCapabilities;
  70646. /**
  70647. * z-depth defining the far plane of the eye view frustum
  70648. * enables mapping of values in the render target depth
  70649. * attachment to scene coordinates. Initially set to 10000.0.
  70650. */
  70651. depthFar: number;
  70652. /**
  70653. * z-depth defining the near plane of the eye view frustum
  70654. * enables mapping of values in the render target depth
  70655. * attachment to scene coordinates. Initially set to 0.01.
  70656. */
  70657. depthNear: number;
  70658. /**
  70659. * An identifier for this distinct VRDisplay. Used as an
  70660. * association point in the Gamepad API.
  70661. */
  70662. readonly displayId: number;
  70663. /**
  70664. * A display name, a user-readable name identifying it.
  70665. */
  70666. readonly displayName: string;
  70667. readonly isConnected: boolean;
  70668. readonly isPresenting: boolean;
  70669. /**
  70670. * If this VRDisplay supports room-scale experiences, the optional
  70671. * stage attribute contains details on the room-scale parameters.
  70672. */
  70673. readonly stageParameters: VRStageParameters | null;
  70674. /**
  70675. * Passing the value returned by `requestAnimationFrame` to
  70676. * `cancelAnimationFrame` will unregister the callback.
  70677. * @param handle Define the hanle of the request to cancel
  70678. */
  70679. cancelAnimationFrame(handle: number): void;
  70680. /**
  70681. * Stops presenting to the VRDisplay.
  70682. * @returns a promise to know when it stopped
  70683. */
  70684. exitPresent(): Promise<void>;
  70685. /**
  70686. * Return the current VREyeParameters for the given eye.
  70687. * @param whichEye Define the eye we want the parameter for
  70688. * @returns the eye parameters
  70689. */
  70690. getEyeParameters(whichEye: string): VREyeParameters;
  70691. /**
  70692. * Populates the passed VRFrameData with the information required to render
  70693. * the current frame.
  70694. * @param frameData Define the data structure to populate
  70695. * @returns true if ok otherwise false
  70696. */
  70697. getFrameData(frameData: VRFrameData): boolean;
  70698. /**
  70699. * Get the layers currently being presented.
  70700. * @returns the list of VR layers
  70701. */
  70702. getLayers(): VRLayer[];
  70703. /**
  70704. * Return a VRPose containing the future predicted pose of the VRDisplay
  70705. * when the current frame will be presented. The value returned will not
  70706. * change until JavaScript has returned control to the browser.
  70707. *
  70708. * The VRPose will contain the position, orientation, velocity,
  70709. * and acceleration of each of these properties.
  70710. * @returns the pose object
  70711. */
  70712. getPose(): VRPose;
  70713. /**
  70714. * Return the current instantaneous pose of the VRDisplay, with no
  70715. * prediction applied.
  70716. * @returns the current instantaneous pose
  70717. */
  70718. getImmediatePose(): VRPose;
  70719. /**
  70720. * The callback passed to `requestAnimationFrame` will be called
  70721. * any time a new frame should be rendered. When the VRDisplay is
  70722. * presenting the callback will be called at the native refresh
  70723. * rate of the HMD. When not presenting this function acts
  70724. * identically to how window.requestAnimationFrame acts. Content should
  70725. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70726. * asynchronously from other displays and at differing refresh rates.
  70727. * @param callback Define the eaction to run next frame
  70728. * @returns the request handle it
  70729. */
  70730. requestAnimationFrame(callback: FrameRequestCallback): number;
  70731. /**
  70732. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70733. * Repeat calls while already presenting will update the VRLayers being displayed.
  70734. * @param layers Define the list of layer to present
  70735. * @returns a promise to know when the request has been fulfilled
  70736. */
  70737. requestPresent(layers: VRLayer[]): Promise<void>;
  70738. /**
  70739. * Reset the pose for this display, treating its current position and
  70740. * orientation as the "origin/zero" values. VRPose.position,
  70741. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70742. * updated when calling resetPose(). This should be called in only
  70743. * sitting-space experiences.
  70744. */
  70745. resetPose(): void;
  70746. /**
  70747. * The VRLayer provided to the VRDisplay will be captured and presented
  70748. * in the HMD. Calling this function has the same effect on the source
  70749. * canvas as any other operation that uses its source image, and canvases
  70750. * created without preserveDrawingBuffer set to true will be cleared.
  70751. * @param pose Define the pose to submit
  70752. */
  70753. submitFrame(pose?: VRPose): void;
  70754. }
  70755. declare var VRDisplay: {
  70756. prototype: VRDisplay;
  70757. new(): VRDisplay;
  70758. };
  70759. interface VRLayer {
  70760. leftBounds?: number[] | Float32Array | null;
  70761. rightBounds?: number[] | Float32Array | null;
  70762. source?: HTMLCanvasElement | null;
  70763. }
  70764. interface VRDisplayCapabilities {
  70765. readonly canPresent: boolean;
  70766. readonly hasExternalDisplay: boolean;
  70767. readonly hasOrientation: boolean;
  70768. readonly hasPosition: boolean;
  70769. readonly maxLayers: number;
  70770. }
  70771. interface VREyeParameters {
  70772. /** @deprecated */
  70773. readonly fieldOfView: VRFieldOfView;
  70774. readonly offset: Float32Array;
  70775. readonly renderHeight: number;
  70776. readonly renderWidth: number;
  70777. }
  70778. interface VRFieldOfView {
  70779. readonly downDegrees: number;
  70780. readonly leftDegrees: number;
  70781. readonly rightDegrees: number;
  70782. readonly upDegrees: number;
  70783. }
  70784. interface VRFrameData {
  70785. readonly leftProjectionMatrix: Float32Array;
  70786. readonly leftViewMatrix: Float32Array;
  70787. readonly pose: VRPose;
  70788. readonly rightProjectionMatrix: Float32Array;
  70789. readonly rightViewMatrix: Float32Array;
  70790. readonly timestamp: number;
  70791. }
  70792. interface VRPose {
  70793. readonly angularAcceleration: Float32Array | null;
  70794. readonly angularVelocity: Float32Array | null;
  70795. readonly linearAcceleration: Float32Array | null;
  70796. readonly linearVelocity: Float32Array | null;
  70797. readonly orientation: Float32Array | null;
  70798. readonly position: Float32Array | null;
  70799. readonly timestamp: number;
  70800. }
  70801. interface VRStageParameters {
  70802. sittingToStandingTransform?: Float32Array;
  70803. sizeX?: number;
  70804. sizeY?: number;
  70805. }
  70806. interface Navigator {
  70807. getVRDisplays(): Promise<VRDisplay[]>;
  70808. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70809. }
  70810. interface Window {
  70811. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70812. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70813. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70814. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70815. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70816. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70817. }
  70818. interface Gamepad {
  70819. readonly displayId: number;
  70820. }
  70821. type XRSessionMode =
  70822. | "inline"
  70823. | "immersive-vr"
  70824. | "immersive-ar";
  70825. type XRReferenceSpaceType =
  70826. | "viewer"
  70827. | "local"
  70828. | "local-floor"
  70829. | "bounded-floor"
  70830. | "unbounded";
  70831. type XREnvironmentBlendMode =
  70832. | "opaque"
  70833. | "additive"
  70834. | "alpha-blend";
  70835. type XRVisibilityState =
  70836. | "visible"
  70837. | "visible-blurred"
  70838. | "hidden";
  70839. type XRHandedness =
  70840. | "none"
  70841. | "left"
  70842. | "right";
  70843. type XRTargetRayMode =
  70844. | "gaze"
  70845. | "tracked-pointer"
  70846. | "screen";
  70847. type XREye =
  70848. | "none"
  70849. | "left"
  70850. | "right";
  70851. interface XRSpace extends EventTarget {
  70852. }
  70853. interface XRRenderState {
  70854. depthNear?: number;
  70855. depthFar?: number;
  70856. inlineVerticalFieldOfView?: number;
  70857. baseLayer?: XRWebGLLayer;
  70858. }
  70859. interface XRInputSource {
  70860. handedness: XRHandedness;
  70861. targetRayMode: XRTargetRayMode;
  70862. targetRaySpace: XRSpace;
  70863. gripSpace: XRSpace | undefined;
  70864. gamepad: Gamepad | undefined;
  70865. profiles: Array<string>;
  70866. }
  70867. interface XRSessionInit {
  70868. optionalFeatures?: XRReferenceSpaceType[];
  70869. requiredFeatures?: XRReferenceSpaceType[];
  70870. }
  70871. interface XRSession extends XRAnchorCreator {
  70872. addEventListener: Function;
  70873. removeEventListener: Function;
  70874. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70875. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70876. requestAnimationFrame: Function;
  70877. end(): Promise<void>;
  70878. renderState: XRRenderState;
  70879. inputSources: Array<XRInputSource>;
  70880. // hit test
  70881. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  70882. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  70883. // legacy AR hit test
  70884. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70885. // legacy plane detection
  70886. updateWorldTrackingState(options: {
  70887. planeDetectionState?: { enabled: boolean; }
  70888. }): void;
  70889. }
  70890. interface XRReferenceSpace extends XRSpace {
  70891. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70892. onreset: any;
  70893. }
  70894. type XRPlaneSet = Set<XRPlane>;
  70895. type XRAnchorSet = Set<XRAnchor>;
  70896. interface XRFrame {
  70897. session: XRSession;
  70898. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70899. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70900. // AR
  70901. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  70902. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  70903. // Anchors
  70904. trackedAnchors?: XRAnchorSet;
  70905. // Planes
  70906. worldInformation: {
  70907. detectedPlanes?: XRPlaneSet;
  70908. };
  70909. }
  70910. interface XRViewerPose extends XRPose {
  70911. views: Array<XRView>;
  70912. }
  70913. interface XRPose {
  70914. transform: XRRigidTransform;
  70915. emulatedPosition: boolean;
  70916. }
  70917. interface XRWebGLLayerOptions {
  70918. antialias?: boolean;
  70919. depth?: boolean;
  70920. stencil?: boolean;
  70921. alpha?: boolean;
  70922. multiview?: boolean;
  70923. framebufferScaleFactor?: number;
  70924. }
  70925. declare var XRWebGLLayer: {
  70926. prototype: XRWebGLLayer;
  70927. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70928. };
  70929. interface XRWebGLLayer {
  70930. framebuffer: WebGLFramebuffer;
  70931. framebufferWidth: number;
  70932. framebufferHeight: number;
  70933. getViewport: Function;
  70934. }
  70935. declare class XRRigidTransform {
  70936. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70937. position: DOMPointReadOnly;
  70938. orientation: DOMPointReadOnly;
  70939. matrix: Float32Array;
  70940. inverse: XRRigidTransform;
  70941. }
  70942. interface XRView {
  70943. eye: XREye;
  70944. projectionMatrix: Float32Array;
  70945. transform: XRRigidTransform;
  70946. }
  70947. interface XRInputSourceChangeEvent {
  70948. session: XRSession;
  70949. removed: Array<XRInputSource>;
  70950. added: Array<XRInputSource>;
  70951. }
  70952. interface XRInputSourceEvent extends Event {
  70953. readonly frame: XRFrame;
  70954. readonly inputSource: XRInputSource;
  70955. }
  70956. // Experimental(er) features
  70957. declare class XRRay {
  70958. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70959. origin: DOMPointReadOnly;
  70960. direction: DOMPointReadOnly;
  70961. matrix: Float32Array;
  70962. }
  70963. declare enum XRHitTestTrackableType {
  70964. "point",
  70965. "plane"
  70966. }
  70967. interface XRHitResult {
  70968. hitMatrix: Float32Array;
  70969. }
  70970. interface XRTransientInputHitTestResult {
  70971. readonly inputSource: XRInputSource;
  70972. readonly results: Array<XRHitTestResult>;
  70973. }
  70974. interface XRHitTestResult {
  70975. getPose(baseSpace: XRSpace): XRPose | undefined;
  70976. }
  70977. interface XRHitTestSource {
  70978. cancel(): void;
  70979. }
  70980. interface XRTransientInputHitTestSource {
  70981. cancel(): void;
  70982. }
  70983. interface XRHitTestOptionsInit {
  70984. space: XRSpace;
  70985. entityTypes?: Array<XRHitTestTrackableType>;
  70986. offsetRay?: XRRay;
  70987. }
  70988. interface XRTransientInputHitTestOptionsInit {
  70989. profile: string;
  70990. entityTypes?: Array<XRHitTestTrackableType>;
  70991. offsetRay?: XRRay;
  70992. }
  70993. interface XRAnchor {
  70994. // remove?
  70995. id?: string;
  70996. anchorSpace: XRSpace;
  70997. lastChangedTime: number;
  70998. detach(): void;
  70999. }
  71000. interface XRPlane extends XRAnchorCreator {
  71001. orientation: "Horizontal" | "Vertical";
  71002. planeSpace: XRSpace;
  71003. polygon: Array<DOMPointReadOnly>;
  71004. lastChangedTime: number;
  71005. }
  71006. interface XRAnchorCreator {
  71007. // AR Anchors
  71008. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71009. }
  71010. /**
  71011. * @ignore
  71012. */
  71013. declare module BABYLON.GLTF2.Exporter {
  71014. }
  71015. /**
  71016. * @ignore
  71017. */
  71018. declare module BABYLON.GLTF1 {
  71019. }
  71020. declare module BABYLON.GUI {
  71021. /**
  71022. * Class used to specific a value and its associated unit
  71023. */
  71024. export class ValueAndUnit {
  71025. /** defines the unit to store */
  71026. unit: number;
  71027. /** defines a boolean indicating if the value can be negative */
  71028. negativeValueAllowed: boolean;
  71029. private _value;
  71030. private _originalUnit;
  71031. /**
  71032. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71033. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71034. */
  71035. ignoreAdaptiveScaling: boolean;
  71036. /**
  71037. * Creates a new ValueAndUnit
  71038. * @param value defines the value to store
  71039. * @param unit defines the unit to store
  71040. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71041. */
  71042. constructor(value: number,
  71043. /** defines the unit to store */
  71044. unit?: number,
  71045. /** defines a boolean indicating if the value can be negative */
  71046. negativeValueAllowed?: boolean);
  71047. /** Gets a boolean indicating if the value is a percentage */
  71048. get isPercentage(): boolean;
  71049. /** Gets a boolean indicating if the value is store as pixel */
  71050. get isPixel(): boolean;
  71051. /** Gets direct internal value */
  71052. get internalValue(): number;
  71053. /**
  71054. * Gets value as pixel
  71055. * @param host defines the root host
  71056. * @param refValue defines the reference value for percentages
  71057. * @returns the value as pixel
  71058. */
  71059. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71060. /**
  71061. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71062. * @param value defines the value to store
  71063. * @param unit defines the unit to store
  71064. * @returns the current ValueAndUnit
  71065. */
  71066. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71067. /**
  71068. * Gets the value accordingly to its unit
  71069. * @param host defines the root host
  71070. * @returns the value
  71071. */
  71072. getValue(host: AdvancedDynamicTexture): number;
  71073. /**
  71074. * Gets a string representation of the value
  71075. * @param host defines the root host
  71076. * @param decimals defines an optional number of decimals to display
  71077. * @returns a string
  71078. */
  71079. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71080. /**
  71081. * Store a value parsed from a string
  71082. * @param source defines the source string
  71083. * @returns true if the value was successfully parsed
  71084. */
  71085. fromString(source: string | number): boolean;
  71086. private static _Regex;
  71087. private static _UNITMODE_PERCENTAGE;
  71088. private static _UNITMODE_PIXEL;
  71089. /** UNITMODE_PERCENTAGE */
  71090. static get UNITMODE_PERCENTAGE(): number;
  71091. /** UNITMODE_PIXEL */
  71092. static get UNITMODE_PIXEL(): number;
  71093. }
  71094. }
  71095. declare module BABYLON.GUI {
  71096. /**
  71097. * Define a style used by control to automatically setup properties based on a template.
  71098. * Only support font related properties so far
  71099. */
  71100. export class Style implements BABYLON.IDisposable {
  71101. private _fontFamily;
  71102. private _fontStyle;
  71103. private _fontWeight;
  71104. /** @hidden */
  71105. _host: AdvancedDynamicTexture;
  71106. /** @hidden */
  71107. _fontSize: ValueAndUnit;
  71108. /**
  71109. * BABYLON.Observable raised when the style values are changed
  71110. */
  71111. onChangedObservable: BABYLON.Observable<Style>;
  71112. /**
  71113. * Creates a new style object
  71114. * @param host defines the AdvancedDynamicTexture which hosts this style
  71115. */
  71116. constructor(host: AdvancedDynamicTexture);
  71117. /**
  71118. * Gets or sets the font size
  71119. */
  71120. get fontSize(): string | number;
  71121. set fontSize(value: string | number);
  71122. /**
  71123. * Gets or sets the font family
  71124. */
  71125. get fontFamily(): string;
  71126. set fontFamily(value: string);
  71127. /**
  71128. * Gets or sets the font style
  71129. */
  71130. get fontStyle(): string;
  71131. set fontStyle(value: string);
  71132. /** Gets or sets font weight */
  71133. get fontWeight(): string;
  71134. set fontWeight(value: string);
  71135. /** Dispose all associated resources */
  71136. dispose(): void;
  71137. }
  71138. }
  71139. declare module BABYLON.GUI {
  71140. /**
  71141. * Class used to transport BABYLON.Vector2 information for pointer events
  71142. */
  71143. export class Vector2WithInfo extends BABYLON.Vector2 {
  71144. /** defines the current mouse button index */
  71145. buttonIndex: number;
  71146. /**
  71147. * Creates a new Vector2WithInfo
  71148. * @param source defines the vector2 data to transport
  71149. * @param buttonIndex defines the current mouse button index
  71150. */
  71151. constructor(source: BABYLON.Vector2,
  71152. /** defines the current mouse button index */
  71153. buttonIndex?: number);
  71154. }
  71155. /** Class used to provide 2D matrix features */
  71156. export class Matrix2D {
  71157. /** Gets the internal array of 6 floats used to store matrix data */
  71158. m: Float32Array;
  71159. /**
  71160. * Creates a new matrix
  71161. * @param m00 defines value for (0, 0)
  71162. * @param m01 defines value for (0, 1)
  71163. * @param m10 defines value for (1, 0)
  71164. * @param m11 defines value for (1, 1)
  71165. * @param m20 defines value for (2, 0)
  71166. * @param m21 defines value for (2, 1)
  71167. */
  71168. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71169. /**
  71170. * Fills the matrix from direct values
  71171. * @param m00 defines value for (0, 0)
  71172. * @param m01 defines value for (0, 1)
  71173. * @param m10 defines value for (1, 0)
  71174. * @param m11 defines value for (1, 1)
  71175. * @param m20 defines value for (2, 0)
  71176. * @param m21 defines value for (2, 1)
  71177. * @returns the current modified matrix
  71178. */
  71179. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71180. /**
  71181. * Gets matrix determinant
  71182. * @returns the determinant
  71183. */
  71184. determinant(): number;
  71185. /**
  71186. * Inverses the matrix and stores it in a target matrix
  71187. * @param result defines the target matrix
  71188. * @returns the current matrix
  71189. */
  71190. invertToRef(result: Matrix2D): Matrix2D;
  71191. /**
  71192. * Multiplies the current matrix with another one
  71193. * @param other defines the second operand
  71194. * @param result defines the target matrix
  71195. * @returns the current matrix
  71196. */
  71197. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71198. /**
  71199. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71200. * @param x defines the x coordinate to transform
  71201. * @param y defines the x coordinate to transform
  71202. * @param result defines the target vector2
  71203. * @returns the current matrix
  71204. */
  71205. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71206. /**
  71207. * Creates an identity matrix
  71208. * @returns a new matrix
  71209. */
  71210. static Identity(): Matrix2D;
  71211. /**
  71212. * Creates a translation matrix and stores it in a target matrix
  71213. * @param x defines the x coordinate of the translation
  71214. * @param y defines the y coordinate of the translation
  71215. * @param result defines the target matrix
  71216. */
  71217. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71218. /**
  71219. * Creates a scaling matrix and stores it in a target matrix
  71220. * @param x defines the x coordinate of the scaling
  71221. * @param y defines the y coordinate of the scaling
  71222. * @param result defines the target matrix
  71223. */
  71224. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71225. /**
  71226. * Creates a rotation matrix and stores it in a target matrix
  71227. * @param angle defines the rotation angle
  71228. * @param result defines the target matrix
  71229. */
  71230. static RotationToRef(angle: number, result: Matrix2D): void;
  71231. private static _TempPreTranslationMatrix;
  71232. private static _TempPostTranslationMatrix;
  71233. private static _TempRotationMatrix;
  71234. private static _TempScalingMatrix;
  71235. private static _TempCompose0;
  71236. private static _TempCompose1;
  71237. private static _TempCompose2;
  71238. /**
  71239. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71240. * @param tx defines the x coordinate of the translation
  71241. * @param ty defines the y coordinate of the translation
  71242. * @param angle defines the rotation angle
  71243. * @param scaleX defines the x coordinate of the scaling
  71244. * @param scaleY defines the y coordinate of the scaling
  71245. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71246. * @param result defines the target matrix
  71247. */
  71248. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71249. }
  71250. }
  71251. declare module BABYLON.GUI {
  71252. /**
  71253. * Class used to store 2D control sizes
  71254. */
  71255. export class Measure {
  71256. /** defines left coordinate */
  71257. left: number;
  71258. /** defines top coordinate */
  71259. top: number;
  71260. /** defines width dimension */
  71261. width: number;
  71262. /** defines height dimension */
  71263. height: number;
  71264. /**
  71265. * Creates a new measure
  71266. * @param left defines left coordinate
  71267. * @param top defines top coordinate
  71268. * @param width defines width dimension
  71269. * @param height defines height dimension
  71270. */
  71271. constructor(
  71272. /** defines left coordinate */
  71273. left: number,
  71274. /** defines top coordinate */
  71275. top: number,
  71276. /** defines width dimension */
  71277. width: number,
  71278. /** defines height dimension */
  71279. height: number);
  71280. /**
  71281. * Copy from another measure
  71282. * @param other defines the other measure to copy from
  71283. */
  71284. copyFrom(other: Measure): void;
  71285. /**
  71286. * Copy from a group of 4 floats
  71287. * @param left defines left coordinate
  71288. * @param top defines top coordinate
  71289. * @param width defines width dimension
  71290. * @param height defines height dimension
  71291. */
  71292. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71293. /**
  71294. * Computes the axis aligned bounding box measure for two given measures
  71295. * @param a Input measure
  71296. * @param b Input measure
  71297. * @param result the resulting bounding measure
  71298. */
  71299. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71300. /**
  71301. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71302. * @param transform the matrix to transform the measure before computing the AABB
  71303. * @param result the resulting AABB
  71304. */
  71305. transformToRef(transform: Matrix2D, result: Measure): void;
  71306. /**
  71307. * Check equality between this measure and another one
  71308. * @param other defines the other measures
  71309. * @returns true if both measures are equals
  71310. */
  71311. isEqualsTo(other: Measure): boolean;
  71312. /**
  71313. * Creates an empty measure
  71314. * @returns a new measure
  71315. */
  71316. static Empty(): Measure;
  71317. }
  71318. }
  71319. declare module BABYLON.GUI {
  71320. /**
  71321. * Interface used to define a control that can receive focus
  71322. */
  71323. export interface IFocusableControl {
  71324. /**
  71325. * Function called when the control receives the focus
  71326. */
  71327. onFocus(): void;
  71328. /**
  71329. * Function called when the control loses the focus
  71330. */
  71331. onBlur(): void;
  71332. /**
  71333. * Function called to let the control handle keyboard events
  71334. * @param evt defines the current keyboard event
  71335. */
  71336. processKeyboard(evt: KeyboardEvent): void;
  71337. /**
  71338. * Function called to get the list of controls that should not steal the focus from this control
  71339. * @returns an array of controls
  71340. */
  71341. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71342. }
  71343. /**
  71344. * Class used to create texture to support 2D GUI elements
  71345. * @see http://doc.babylonjs.com/how_to/gui
  71346. */
  71347. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71348. private _isDirty;
  71349. private _renderObserver;
  71350. private _resizeObserver;
  71351. private _preKeyboardObserver;
  71352. private _pointerMoveObserver;
  71353. private _pointerObserver;
  71354. private _canvasPointerOutObserver;
  71355. private _background;
  71356. /** @hidden */
  71357. _rootContainer: Container;
  71358. /** @hidden */
  71359. _lastPickedControl: Control;
  71360. /** @hidden */
  71361. _lastControlOver: {
  71362. [pointerId: number]: Control;
  71363. };
  71364. /** @hidden */
  71365. _lastControlDown: {
  71366. [pointerId: number]: Control;
  71367. };
  71368. /** @hidden */
  71369. _capturingControl: {
  71370. [pointerId: number]: Control;
  71371. };
  71372. /** @hidden */
  71373. _shouldBlockPointer: boolean;
  71374. /** @hidden */
  71375. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71376. /** @hidden */
  71377. _linkedControls: Control[];
  71378. private _isFullscreen;
  71379. private _fullscreenViewport;
  71380. private _idealWidth;
  71381. private _idealHeight;
  71382. private _useSmallestIdeal;
  71383. private _renderAtIdealSize;
  71384. private _focusedControl;
  71385. private _blockNextFocusCheck;
  71386. private _renderScale;
  71387. private _rootElement;
  71388. private _cursorChanged;
  71389. private _defaultMousePointerId;
  71390. /** @hidden */
  71391. _numLayoutCalls: number;
  71392. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71393. get numLayoutCalls(): number;
  71394. /** @hidden */
  71395. _numRenderCalls: number;
  71396. /** Gets the number of render calls made the last time the ADT has been rendered */
  71397. get numRenderCalls(): number;
  71398. /**
  71399. * Define type to string to ensure compatibility across browsers
  71400. * Safari doesn't support DataTransfer constructor
  71401. */
  71402. private _clipboardData;
  71403. /**
  71404. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71405. */
  71406. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71407. /**
  71408. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71409. */
  71410. onControlPickedObservable: BABYLON.Observable<Control>;
  71411. /**
  71412. * BABYLON.Observable event triggered before layout is evaluated
  71413. */
  71414. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71415. /**
  71416. * BABYLON.Observable event triggered after the layout was evaluated
  71417. */
  71418. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71419. /**
  71420. * BABYLON.Observable event triggered before the texture is rendered
  71421. */
  71422. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71423. /**
  71424. * BABYLON.Observable event triggered after the texture was rendered
  71425. */
  71426. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71427. /**
  71428. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71429. */
  71430. premulAlpha: boolean;
  71431. /**
  71432. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71433. * Useful when you want more antialiasing
  71434. */
  71435. get renderScale(): number;
  71436. set renderScale(value: number);
  71437. /** Gets or sets the background color */
  71438. get background(): string;
  71439. set background(value: string);
  71440. /**
  71441. * Gets or sets the ideal width used to design controls.
  71442. * The GUI will then rescale everything accordingly
  71443. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71444. */
  71445. get idealWidth(): number;
  71446. set idealWidth(value: number);
  71447. /**
  71448. * Gets or sets the ideal height used to design controls.
  71449. * The GUI will then rescale everything accordingly
  71450. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71451. */
  71452. get idealHeight(): number;
  71453. set idealHeight(value: number);
  71454. /**
  71455. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71456. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71457. */
  71458. get useSmallestIdeal(): boolean;
  71459. set useSmallestIdeal(value: boolean);
  71460. /**
  71461. * Gets or sets a boolean indicating if adaptive scaling must be used
  71462. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71463. */
  71464. get renderAtIdealSize(): boolean;
  71465. set renderAtIdealSize(value: boolean);
  71466. /**
  71467. * Gets the ratio used when in "ideal mode"
  71468. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71469. * */
  71470. get idealRatio(): number;
  71471. /**
  71472. * Gets the underlying layer used to render the texture when in fullscreen mode
  71473. */
  71474. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71475. /**
  71476. * Gets the root container control
  71477. */
  71478. get rootContainer(): Container;
  71479. /**
  71480. * Returns an array containing the root container.
  71481. * This is mostly used to let the Inspector introspects the ADT
  71482. * @returns an array containing the rootContainer
  71483. */
  71484. getChildren(): Array<Container>;
  71485. /**
  71486. * Will return all controls that are inside this texture
  71487. * @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
  71488. * @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
  71489. * @return all child controls
  71490. */
  71491. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71492. /**
  71493. * Gets or sets the current focused control
  71494. */
  71495. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71496. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71497. /**
  71498. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71499. */
  71500. get isForeground(): boolean;
  71501. set isForeground(value: boolean);
  71502. /**
  71503. * Gets or set information about clipboardData
  71504. */
  71505. get clipboardData(): string;
  71506. set clipboardData(value: string);
  71507. /**
  71508. * Creates a new AdvancedDynamicTexture
  71509. * @param name defines the name of the texture
  71510. * @param width defines the width of the texture
  71511. * @param height defines the height of the texture
  71512. * @param scene defines the hosting scene
  71513. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71514. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71515. */
  71516. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71517. /**
  71518. * Get the current class name of the texture useful for serialization or dynamic coding.
  71519. * @returns "AdvancedDynamicTexture"
  71520. */
  71521. getClassName(): string;
  71522. /**
  71523. * Function used to execute a function on all controls
  71524. * @param func defines the function to execute
  71525. * @param container defines the container where controls belong. If null the root container will be used
  71526. */
  71527. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71528. private _useInvalidateRectOptimization;
  71529. /**
  71530. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71531. */
  71532. get useInvalidateRectOptimization(): boolean;
  71533. set useInvalidateRectOptimization(value: boolean);
  71534. private _invalidatedRectangle;
  71535. /**
  71536. * Invalidates a rectangle area on the gui texture
  71537. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71538. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71539. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71540. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71541. */
  71542. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71543. /**
  71544. * Marks the texture as dirty forcing a complete update
  71545. */
  71546. markAsDirty(): void;
  71547. /**
  71548. * Helper function used to create a new style
  71549. * @returns a new style
  71550. * @see http://doc.babylonjs.com/how_to/gui#styles
  71551. */
  71552. createStyle(): Style;
  71553. /**
  71554. * Adds a new control to the root container
  71555. * @param control defines the control to add
  71556. * @returns the current texture
  71557. */
  71558. addControl(control: Control): AdvancedDynamicTexture;
  71559. /**
  71560. * Removes a control from the root container
  71561. * @param control defines the control to remove
  71562. * @returns the current texture
  71563. */
  71564. removeControl(control: Control): AdvancedDynamicTexture;
  71565. /**
  71566. * Release all resources
  71567. */
  71568. dispose(): void;
  71569. private _onResize;
  71570. /** @hidden */
  71571. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71572. /**
  71573. * Get screen coordinates for a vector3
  71574. * @param position defines the position to project
  71575. * @param worldMatrix defines the world matrix to use
  71576. * @returns the projected position
  71577. */
  71578. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71579. private _checkUpdate;
  71580. private _clearMeasure;
  71581. private _render;
  71582. /** @hidden */
  71583. _changeCursor(cursor: string): void;
  71584. /** @hidden */
  71585. _registerLastControlDown(control: Control, pointerId: number): void;
  71586. private _doPicking;
  71587. /** @hidden */
  71588. _cleanControlAfterRemovalFromList(list: {
  71589. [pointerId: number]: Control;
  71590. }, control: Control): void;
  71591. /** @hidden */
  71592. _cleanControlAfterRemoval(control: Control): void;
  71593. /** Attach to all scene events required to support pointer events */
  71594. attach(): void;
  71595. /** @hidden */
  71596. private onClipboardCopy;
  71597. /** @hidden */
  71598. private onClipboardCut;
  71599. /** @hidden */
  71600. private onClipboardPaste;
  71601. /**
  71602. * Register the clipboard Events onto the canvas
  71603. */
  71604. registerClipboardEvents(): void;
  71605. /**
  71606. * Unregister the clipboard Events from the canvas
  71607. */
  71608. unRegisterClipboardEvents(): void;
  71609. /**
  71610. * Connect the texture to a hosting mesh to enable interactions
  71611. * @param mesh defines the mesh to attach to
  71612. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71613. */
  71614. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71615. /**
  71616. * Move the focus to a specific control
  71617. * @param control defines the control which will receive the focus
  71618. */
  71619. moveFocusToControl(control: IFocusableControl): void;
  71620. private _manageFocus;
  71621. private _attachToOnPointerOut;
  71622. /**
  71623. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71624. * @param mesh defines the mesh which will receive the texture
  71625. * @param width defines the texture width (1024 by default)
  71626. * @param height defines the texture height (1024 by default)
  71627. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71628. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71629. * @returns a new AdvancedDynamicTexture
  71630. */
  71631. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71632. /**
  71633. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71634. * In this mode the texture will rely on a layer for its rendering.
  71635. * This allows it to be treated like any other layer.
  71636. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71637. * LayerMask is set through advancedTexture.layer.layerMask
  71638. * @param name defines name for the texture
  71639. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71640. * @param scene defines the hsoting scene
  71641. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71642. * @returns a new AdvancedDynamicTexture
  71643. */
  71644. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71645. }
  71646. }
  71647. declare module BABYLON.GUI {
  71648. /**
  71649. * Root class used for all 2D controls
  71650. * @see http://doc.babylonjs.com/how_to/gui#controls
  71651. */
  71652. export class Control {
  71653. /** defines the name of the control */
  71654. name?: string | undefined;
  71655. /**
  71656. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71657. */
  71658. static AllowAlphaInheritance: boolean;
  71659. private _alpha;
  71660. private _alphaSet;
  71661. private _zIndex;
  71662. /** @hidden */
  71663. _host: AdvancedDynamicTexture;
  71664. /** Gets or sets the control parent */
  71665. parent: BABYLON.Nullable<Container>;
  71666. /** @hidden */
  71667. _currentMeasure: Measure;
  71668. private _fontFamily;
  71669. private _fontStyle;
  71670. private _fontWeight;
  71671. private _fontSize;
  71672. private _font;
  71673. /** @hidden */
  71674. _width: ValueAndUnit;
  71675. /** @hidden */
  71676. _height: ValueAndUnit;
  71677. /** @hidden */
  71678. protected _fontOffset: {
  71679. ascent: number;
  71680. height: number;
  71681. descent: number;
  71682. };
  71683. private _color;
  71684. private _style;
  71685. private _styleObserver;
  71686. /** @hidden */
  71687. protected _horizontalAlignment: number;
  71688. /** @hidden */
  71689. protected _verticalAlignment: number;
  71690. /** @hidden */
  71691. protected _isDirty: boolean;
  71692. /** @hidden */
  71693. protected _wasDirty: boolean;
  71694. /** @hidden */
  71695. _tempParentMeasure: Measure;
  71696. /** @hidden */
  71697. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71698. /** @hidden */
  71699. protected _cachedParentMeasure: Measure;
  71700. private _paddingLeft;
  71701. private _paddingRight;
  71702. private _paddingTop;
  71703. private _paddingBottom;
  71704. /** @hidden */
  71705. _left: ValueAndUnit;
  71706. /** @hidden */
  71707. _top: ValueAndUnit;
  71708. private _scaleX;
  71709. private _scaleY;
  71710. private _rotation;
  71711. private _transformCenterX;
  71712. private _transformCenterY;
  71713. /** @hidden */
  71714. _transformMatrix: Matrix2D;
  71715. /** @hidden */
  71716. protected _invertTransformMatrix: Matrix2D;
  71717. /** @hidden */
  71718. protected _transformedPosition: BABYLON.Vector2;
  71719. private _isMatrixDirty;
  71720. private _cachedOffsetX;
  71721. private _cachedOffsetY;
  71722. private _isVisible;
  71723. private _isHighlighted;
  71724. /** @hidden */
  71725. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71726. private _fontSet;
  71727. private _dummyVector2;
  71728. private _downCount;
  71729. private _enterCount;
  71730. private _doNotRender;
  71731. private _downPointerIds;
  71732. protected _isEnabled: boolean;
  71733. protected _disabledColor: string;
  71734. protected _disabledColorItem: string;
  71735. /** @hidden */
  71736. protected _rebuildLayout: boolean;
  71737. /** @hidden */
  71738. _customData: any;
  71739. /** @hidden */
  71740. _isClipped: boolean;
  71741. /** @hidden */
  71742. _automaticSize: boolean;
  71743. /** @hidden */
  71744. _tag: any;
  71745. /**
  71746. * 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
  71747. */
  71748. uniqueId: number;
  71749. /**
  71750. * Gets or sets an object used to store user defined information for the node
  71751. */
  71752. metadata: any;
  71753. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71754. isHitTestVisible: boolean;
  71755. /** Gets or sets a boolean indicating if the control can block pointer events */
  71756. isPointerBlocker: boolean;
  71757. /** Gets or sets a boolean indicating if the control can be focusable */
  71758. isFocusInvisible: boolean;
  71759. /**
  71760. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71761. * 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
  71762. */
  71763. clipChildren: boolean;
  71764. /**
  71765. * Gets or sets a boolean indicating that control content must be clipped
  71766. * 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
  71767. */
  71768. clipContent: boolean;
  71769. /**
  71770. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71771. */
  71772. useBitmapCache: boolean;
  71773. private _cacheData;
  71774. private _shadowOffsetX;
  71775. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71776. get shadowOffsetX(): number;
  71777. set shadowOffsetX(value: number);
  71778. private _shadowOffsetY;
  71779. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71780. get shadowOffsetY(): number;
  71781. set shadowOffsetY(value: number);
  71782. private _shadowBlur;
  71783. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71784. get shadowBlur(): number;
  71785. set shadowBlur(value: number);
  71786. private _shadowColor;
  71787. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71788. get shadowColor(): string;
  71789. set shadowColor(value: string);
  71790. /** Gets or sets the cursor to use when the control is hovered */
  71791. hoverCursor: string;
  71792. /** @hidden */
  71793. protected _linkOffsetX: ValueAndUnit;
  71794. /** @hidden */
  71795. protected _linkOffsetY: ValueAndUnit;
  71796. /** Gets the control type name */
  71797. get typeName(): string;
  71798. /**
  71799. * Get the current class name of the control.
  71800. * @returns current class name
  71801. */
  71802. getClassName(): string;
  71803. /**
  71804. * An event triggered when pointer wheel is scrolled
  71805. */
  71806. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71807. /**
  71808. * An event triggered when the pointer move over the control.
  71809. */
  71810. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71811. /**
  71812. * An event triggered when the pointer move out of the control.
  71813. */
  71814. onPointerOutObservable: BABYLON.Observable<Control>;
  71815. /**
  71816. * An event triggered when the pointer taps the control
  71817. */
  71818. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71819. /**
  71820. * An event triggered when pointer up
  71821. */
  71822. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71823. /**
  71824. * An event triggered when a control is clicked on
  71825. */
  71826. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71827. /**
  71828. * An event triggered when pointer enters the control
  71829. */
  71830. onPointerEnterObservable: BABYLON.Observable<Control>;
  71831. /**
  71832. * An event triggered when the control is marked as dirty
  71833. */
  71834. onDirtyObservable: BABYLON.Observable<Control>;
  71835. /**
  71836. * An event triggered before drawing the control
  71837. */
  71838. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71839. /**
  71840. * An event triggered after the control was drawn
  71841. */
  71842. onAfterDrawObservable: BABYLON.Observable<Control>;
  71843. /**
  71844. * Get the hosting AdvancedDynamicTexture
  71845. */
  71846. get host(): AdvancedDynamicTexture;
  71847. /** Gets or set information about font offsets (used to render and align text) */
  71848. get fontOffset(): {
  71849. ascent: number;
  71850. height: number;
  71851. descent: number;
  71852. };
  71853. set fontOffset(offset: {
  71854. ascent: number;
  71855. height: number;
  71856. descent: number;
  71857. });
  71858. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71859. get alpha(): number;
  71860. set alpha(value: number);
  71861. /**
  71862. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71863. */
  71864. get isHighlighted(): boolean;
  71865. set isHighlighted(value: boolean);
  71866. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71867. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71868. */
  71869. get scaleX(): number;
  71870. set scaleX(value: number);
  71871. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71872. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71873. */
  71874. get scaleY(): number;
  71875. set scaleY(value: number);
  71876. /** Gets or sets the rotation angle (0 by default)
  71877. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71878. */
  71879. get rotation(): number;
  71880. set rotation(value: number);
  71881. /** Gets or sets the transformation center on Y axis (0 by default)
  71882. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71883. */
  71884. get transformCenterY(): number;
  71885. set transformCenterY(value: number);
  71886. /** Gets or sets the transformation center on X axis (0 by default)
  71887. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71888. */
  71889. get transformCenterX(): number;
  71890. set transformCenterX(value: number);
  71891. /**
  71892. * Gets or sets the horizontal alignment
  71893. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71894. */
  71895. get horizontalAlignment(): number;
  71896. set horizontalAlignment(value: number);
  71897. /**
  71898. * Gets or sets the vertical alignment
  71899. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71900. */
  71901. get verticalAlignment(): number;
  71902. set verticalAlignment(value: number);
  71903. /**
  71904. * Gets or sets control width
  71905. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71906. */
  71907. get width(): string | number;
  71908. set width(value: string | number);
  71909. /**
  71910. * Gets or sets the control width in pixel
  71911. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71912. */
  71913. get widthInPixels(): number;
  71914. set widthInPixels(value: number);
  71915. /**
  71916. * Gets or sets control height
  71917. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71918. */
  71919. get height(): string | number;
  71920. set height(value: string | number);
  71921. /**
  71922. * Gets or sets control height in pixel
  71923. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71924. */
  71925. get heightInPixels(): number;
  71926. set heightInPixels(value: number);
  71927. /** Gets or set font family */
  71928. get fontFamily(): string;
  71929. set fontFamily(value: string);
  71930. /** Gets or sets font style */
  71931. get fontStyle(): string;
  71932. set fontStyle(value: string);
  71933. /** Gets or sets font weight */
  71934. get fontWeight(): string;
  71935. set fontWeight(value: string);
  71936. /**
  71937. * Gets or sets style
  71938. * @see http://doc.babylonjs.com/how_to/gui#styles
  71939. */
  71940. get style(): BABYLON.Nullable<Style>;
  71941. set style(value: BABYLON.Nullable<Style>);
  71942. /** @hidden */
  71943. get _isFontSizeInPercentage(): boolean;
  71944. /** Gets or sets font size in pixels */
  71945. get fontSizeInPixels(): number;
  71946. set fontSizeInPixels(value: number);
  71947. /** Gets or sets font size */
  71948. get fontSize(): string | number;
  71949. set fontSize(value: string | number);
  71950. /** Gets or sets foreground color */
  71951. get color(): string;
  71952. set color(value: string);
  71953. /** Gets or sets z index which is used to reorder controls on the z axis */
  71954. get zIndex(): number;
  71955. set zIndex(value: number);
  71956. /** Gets or sets a boolean indicating if the control can be rendered */
  71957. get notRenderable(): boolean;
  71958. set notRenderable(value: boolean);
  71959. /** Gets or sets a boolean indicating if the control is visible */
  71960. get isVisible(): boolean;
  71961. set isVisible(value: boolean);
  71962. /** Gets a boolean indicating that the control needs to update its rendering */
  71963. get isDirty(): boolean;
  71964. /**
  71965. * Gets the current linked mesh (or null if none)
  71966. */
  71967. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71968. /**
  71969. * Gets or sets a value indicating the padding to use on the left of the control
  71970. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71971. */
  71972. get paddingLeft(): string | number;
  71973. set paddingLeft(value: string | number);
  71974. /**
  71975. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71976. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71977. */
  71978. get paddingLeftInPixels(): number;
  71979. set paddingLeftInPixels(value: number);
  71980. /**
  71981. * Gets or sets a value indicating the padding to use on the right of the control
  71982. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71983. */
  71984. get paddingRight(): string | number;
  71985. set paddingRight(value: string | number);
  71986. /**
  71987. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71988. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71989. */
  71990. get paddingRightInPixels(): number;
  71991. set paddingRightInPixels(value: number);
  71992. /**
  71993. * Gets or sets a value indicating the padding to use on the top of the control
  71994. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71995. */
  71996. get paddingTop(): string | number;
  71997. set paddingTop(value: string | number);
  71998. /**
  71999. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  72000. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72001. */
  72002. get paddingTopInPixels(): number;
  72003. set paddingTopInPixels(value: number);
  72004. /**
  72005. * Gets or sets a value indicating the padding to use on the bottom of the control
  72006. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72007. */
  72008. get paddingBottom(): string | number;
  72009. set paddingBottom(value: string | number);
  72010. /**
  72011. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72012. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72013. */
  72014. get paddingBottomInPixels(): number;
  72015. set paddingBottomInPixels(value: number);
  72016. /**
  72017. * Gets or sets a value indicating the left coordinate of the control
  72018. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72019. */
  72020. get left(): string | number;
  72021. set left(value: string | number);
  72022. /**
  72023. * Gets or sets a value indicating the left coordinate in pixels of the control
  72024. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72025. */
  72026. get leftInPixels(): number;
  72027. set leftInPixels(value: number);
  72028. /**
  72029. * Gets or sets a value indicating the top coordinate of the control
  72030. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72031. */
  72032. get top(): string | number;
  72033. set top(value: string | number);
  72034. /**
  72035. * Gets or sets a value indicating the top coordinate in pixels of the control
  72036. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72037. */
  72038. get topInPixels(): number;
  72039. set topInPixels(value: number);
  72040. /**
  72041. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72042. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72043. */
  72044. get linkOffsetX(): string | number;
  72045. set linkOffsetX(value: string | number);
  72046. /**
  72047. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72048. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72049. */
  72050. get linkOffsetXInPixels(): number;
  72051. set linkOffsetXInPixels(value: number);
  72052. /**
  72053. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72054. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72055. */
  72056. get linkOffsetY(): string | number;
  72057. set linkOffsetY(value: string | number);
  72058. /**
  72059. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72060. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72061. */
  72062. get linkOffsetYInPixels(): number;
  72063. set linkOffsetYInPixels(value: number);
  72064. /** Gets the center coordinate on X axis */
  72065. get centerX(): number;
  72066. /** Gets the center coordinate on Y axis */
  72067. get centerY(): number;
  72068. /** Gets or sets if control is Enabled*/
  72069. get isEnabled(): boolean;
  72070. set isEnabled(value: boolean);
  72071. /** Gets or sets background color of control if it's disabled*/
  72072. get disabledColor(): string;
  72073. set disabledColor(value: string);
  72074. /** Gets or sets front color of control if it's disabled*/
  72075. get disabledColorItem(): string;
  72076. set disabledColorItem(value: string);
  72077. /**
  72078. * Creates a new control
  72079. * @param name defines the name of the control
  72080. */
  72081. constructor(
  72082. /** defines the name of the control */
  72083. name?: string | undefined);
  72084. /** @hidden */
  72085. protected _getTypeName(): string;
  72086. /**
  72087. * Gets the first ascendant in the hierarchy of the given type
  72088. * @param className defines the required type
  72089. * @returns the ascendant or null if not found
  72090. */
  72091. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72092. /** @hidden */
  72093. _resetFontCache(): void;
  72094. /**
  72095. * Determines if a container is an ascendant of the current control
  72096. * @param container defines the container to look for
  72097. * @returns true if the container is one of the ascendant of the control
  72098. */
  72099. isAscendant(container: Control): boolean;
  72100. /**
  72101. * Gets coordinates in local control space
  72102. * @param globalCoordinates defines the coordinates to transform
  72103. * @returns the new coordinates in local space
  72104. */
  72105. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72106. /**
  72107. * Gets coordinates in local control space
  72108. * @param globalCoordinates defines the coordinates to transform
  72109. * @param result defines the target vector2 where to store the result
  72110. * @returns the current control
  72111. */
  72112. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72113. /**
  72114. * Gets coordinates in parent local control space
  72115. * @param globalCoordinates defines the coordinates to transform
  72116. * @returns the new coordinates in parent local space
  72117. */
  72118. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72119. /**
  72120. * Move the current control to a vector3 position projected onto the screen.
  72121. * @param position defines the target position
  72122. * @param scene defines the hosting scene
  72123. */
  72124. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72125. /**
  72126. * Will store all controls that have this control as ascendant in a given array
  72127. * @param results defines the array where to store the descendants
  72128. * @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
  72129. * @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
  72130. */
  72131. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72132. /**
  72133. * Will return all controls that have this control as ascendant
  72134. * @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
  72135. * @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
  72136. * @return all child controls
  72137. */
  72138. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72139. /**
  72140. * Link current control with a target mesh
  72141. * @param mesh defines the mesh to link with
  72142. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72143. */
  72144. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72145. /** @hidden */
  72146. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72147. /** @hidden */
  72148. _offsetLeft(offset: number): void;
  72149. /** @hidden */
  72150. _offsetTop(offset: number): void;
  72151. /** @hidden */
  72152. _markMatrixAsDirty(): void;
  72153. /** @hidden */
  72154. _flagDescendantsAsMatrixDirty(): void;
  72155. /** @hidden */
  72156. _intersectsRect(rect: Measure): boolean;
  72157. /** @hidden */
  72158. protected invalidateRect(): void;
  72159. /** @hidden */
  72160. _markAsDirty(force?: boolean): void;
  72161. /** @hidden */
  72162. _markAllAsDirty(): void;
  72163. /** @hidden */
  72164. _link(host: AdvancedDynamicTexture): void;
  72165. /** @hidden */
  72166. protected _transform(context?: CanvasRenderingContext2D): void;
  72167. /** @hidden */
  72168. _renderHighlight(context: CanvasRenderingContext2D): void;
  72169. /** @hidden */
  72170. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72171. /** @hidden */
  72172. protected _applyStates(context: CanvasRenderingContext2D): void;
  72173. /** @hidden */
  72174. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72175. /** @hidden */
  72176. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72177. protected _evaluateClippingState(parentMeasure: Measure): void;
  72178. /** @hidden */
  72179. _measure(): void;
  72180. /** @hidden */
  72181. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72182. /** @hidden */
  72183. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72184. /** @hidden */
  72185. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72186. /** @hidden */
  72187. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72188. private static _ClipMeasure;
  72189. private _tmpMeasureA;
  72190. private _clip;
  72191. /** @hidden */
  72192. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72193. /** @hidden */
  72194. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72195. /**
  72196. * Tests if a given coordinates belong to the current control
  72197. * @param x defines x coordinate to test
  72198. * @param y defines y coordinate to test
  72199. * @returns true if the coordinates are inside the control
  72200. */
  72201. contains(x: number, y: number): boolean;
  72202. /** @hidden */
  72203. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72204. /** @hidden */
  72205. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72206. /** @hidden */
  72207. _onPointerEnter(target: Control): boolean;
  72208. /** @hidden */
  72209. _onPointerOut(target: Control, force?: boolean): void;
  72210. /** @hidden */
  72211. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72212. /** @hidden */
  72213. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72214. /** @hidden */
  72215. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72216. /** @hidden */
  72217. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72218. /** @hidden */
  72219. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72220. private _prepareFont;
  72221. /** Releases associated resources */
  72222. dispose(): void;
  72223. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72224. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72225. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72226. private static _VERTICAL_ALIGNMENT_TOP;
  72227. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72228. private static _VERTICAL_ALIGNMENT_CENTER;
  72229. /** HORIZONTAL_ALIGNMENT_LEFT */
  72230. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72231. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72232. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72233. /** HORIZONTAL_ALIGNMENT_CENTER */
  72234. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72235. /** VERTICAL_ALIGNMENT_TOP */
  72236. static get VERTICAL_ALIGNMENT_TOP(): number;
  72237. /** VERTICAL_ALIGNMENT_BOTTOM */
  72238. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72239. /** VERTICAL_ALIGNMENT_CENTER */
  72240. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72241. private static _FontHeightSizes;
  72242. /** @hidden */
  72243. static _GetFontOffset(font: string): {
  72244. ascent: number;
  72245. height: number;
  72246. descent: number;
  72247. };
  72248. /**
  72249. * Creates a stack panel that can be used to render headers
  72250. * @param control defines the control to associate with the header
  72251. * @param text defines the text of the header
  72252. * @param size defines the size of the header
  72253. * @param options defines options used to configure the header
  72254. * @returns a new StackPanel
  72255. * @ignore
  72256. * @hidden
  72257. */
  72258. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72259. isHorizontal: boolean;
  72260. controlFirst: boolean;
  72261. }) => any;
  72262. /** @hidden */
  72263. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72264. }
  72265. }
  72266. declare module BABYLON.GUI {
  72267. /**
  72268. * Root class for 2D containers
  72269. * @see http://doc.babylonjs.com/how_to/gui#containers
  72270. */
  72271. export class Container extends Control {
  72272. name?: string | undefined;
  72273. /** @hidden */
  72274. _children: Control[];
  72275. /** @hidden */
  72276. protected _measureForChildren: Measure;
  72277. /** @hidden */
  72278. protected _background: string;
  72279. /** @hidden */
  72280. protected _adaptWidthToChildren: boolean;
  72281. /** @hidden */
  72282. protected _adaptHeightToChildren: boolean;
  72283. /**
  72284. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72285. */
  72286. logLayoutCycleErrors: boolean;
  72287. /**
  72288. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72289. */
  72290. maxLayoutCycle: number;
  72291. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72292. get adaptHeightToChildren(): boolean;
  72293. set adaptHeightToChildren(value: boolean);
  72294. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72295. get adaptWidthToChildren(): boolean;
  72296. set adaptWidthToChildren(value: boolean);
  72297. /** Gets or sets background color */
  72298. get background(): string;
  72299. set background(value: string);
  72300. /** Gets the list of children */
  72301. get children(): Control[];
  72302. /**
  72303. * Creates a new Container
  72304. * @param name defines the name of the container
  72305. */
  72306. constructor(name?: string | undefined);
  72307. protected _getTypeName(): string;
  72308. _flagDescendantsAsMatrixDirty(): void;
  72309. /**
  72310. * Gets a child using its name
  72311. * @param name defines the child name to look for
  72312. * @returns the child control if found
  72313. */
  72314. getChildByName(name: string): BABYLON.Nullable<Control>;
  72315. /**
  72316. * Gets a child using its type and its name
  72317. * @param name defines the child name to look for
  72318. * @param type defines the child type to look for
  72319. * @returns the child control if found
  72320. */
  72321. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72322. /**
  72323. * Search for a specific control in children
  72324. * @param control defines the control to look for
  72325. * @returns true if the control is in child list
  72326. */
  72327. containsControl(control: Control): boolean;
  72328. /**
  72329. * Adds a new control to the current container
  72330. * @param control defines the control to add
  72331. * @returns the current container
  72332. */
  72333. addControl(control: BABYLON.Nullable<Control>): Container;
  72334. /**
  72335. * Removes all controls from the current container
  72336. * @returns the current container
  72337. */
  72338. clearControls(): Container;
  72339. /**
  72340. * Removes a control from the current container
  72341. * @param control defines the control to remove
  72342. * @returns the current container
  72343. */
  72344. removeControl(control: Control): Container;
  72345. /** @hidden */
  72346. _reOrderControl(control: Control): void;
  72347. /** @hidden */
  72348. _offsetLeft(offset: number): void;
  72349. /** @hidden */
  72350. _offsetTop(offset: number): void;
  72351. /** @hidden */
  72352. _markAllAsDirty(): void;
  72353. /** @hidden */
  72354. protected _localDraw(context: CanvasRenderingContext2D): void;
  72355. /** @hidden */
  72356. _link(host: AdvancedDynamicTexture): void;
  72357. /** @hidden */
  72358. protected _beforeLayout(): void;
  72359. /** @hidden */
  72360. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72361. /** @hidden */
  72362. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72363. protected _postMeasure(): void;
  72364. /** @hidden */
  72365. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72366. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72367. /** @hidden */
  72368. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72369. /** @hidden */
  72370. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72371. /** Releases associated resources */
  72372. dispose(): void;
  72373. }
  72374. }
  72375. declare module BABYLON.GUI {
  72376. /** Class used to create rectangle container */
  72377. export class Rectangle extends Container {
  72378. name?: string | undefined;
  72379. private _thickness;
  72380. private _cornerRadius;
  72381. /** Gets or sets border thickness */
  72382. get thickness(): number;
  72383. set thickness(value: number);
  72384. /** Gets or sets the corner radius angle */
  72385. get cornerRadius(): number;
  72386. set cornerRadius(value: number);
  72387. /**
  72388. * Creates a new Rectangle
  72389. * @param name defines the control name
  72390. */
  72391. constructor(name?: string | undefined);
  72392. protected _getTypeName(): string;
  72393. protected _localDraw(context: CanvasRenderingContext2D): void;
  72394. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72395. private _drawRoundedRect;
  72396. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72397. }
  72398. }
  72399. declare module BABYLON.GUI {
  72400. /**
  72401. * Enum that determines the text-wrapping mode to use.
  72402. */
  72403. export enum TextWrapping {
  72404. /**
  72405. * Clip the text when it's larger than Control.width; this is the default mode.
  72406. */
  72407. Clip = 0,
  72408. /**
  72409. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72410. */
  72411. WordWrap = 1,
  72412. /**
  72413. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72414. */
  72415. Ellipsis = 2
  72416. }
  72417. /**
  72418. * Class used to create text block control
  72419. */
  72420. export class TextBlock extends Control {
  72421. /**
  72422. * Defines the name of the control
  72423. */
  72424. name?: string | undefined;
  72425. private _text;
  72426. private _textWrapping;
  72427. private _textHorizontalAlignment;
  72428. private _textVerticalAlignment;
  72429. private _lines;
  72430. private _resizeToFit;
  72431. private _lineSpacing;
  72432. private _outlineWidth;
  72433. private _outlineColor;
  72434. /**
  72435. * An event triggered after the text is changed
  72436. */
  72437. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72438. /**
  72439. * An event triggered after the text was broken up into lines
  72440. */
  72441. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72442. /**
  72443. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72444. */
  72445. get lines(): any[];
  72446. /**
  72447. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72448. */
  72449. get resizeToFit(): boolean;
  72450. /**
  72451. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72452. */
  72453. set resizeToFit(value: boolean);
  72454. /**
  72455. * Gets or sets a boolean indicating if text must be wrapped
  72456. */
  72457. get textWrapping(): TextWrapping | boolean;
  72458. /**
  72459. * Gets or sets a boolean indicating if text must be wrapped
  72460. */
  72461. set textWrapping(value: TextWrapping | boolean);
  72462. /**
  72463. * Gets or sets text to display
  72464. */
  72465. get text(): string;
  72466. /**
  72467. * Gets or sets text to display
  72468. */
  72469. set text(value: string);
  72470. /**
  72471. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72472. */
  72473. get textHorizontalAlignment(): number;
  72474. /**
  72475. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72476. */
  72477. set textHorizontalAlignment(value: number);
  72478. /**
  72479. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72480. */
  72481. get textVerticalAlignment(): number;
  72482. /**
  72483. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72484. */
  72485. set textVerticalAlignment(value: number);
  72486. /**
  72487. * Gets or sets line spacing value
  72488. */
  72489. set lineSpacing(value: string | number);
  72490. /**
  72491. * Gets or sets line spacing value
  72492. */
  72493. get lineSpacing(): string | number;
  72494. /**
  72495. * Gets or sets outlineWidth of the text to display
  72496. */
  72497. get outlineWidth(): number;
  72498. /**
  72499. * Gets or sets outlineWidth of the text to display
  72500. */
  72501. set outlineWidth(value: number);
  72502. /**
  72503. * Gets or sets outlineColor of the text to display
  72504. */
  72505. get outlineColor(): string;
  72506. /**
  72507. * Gets or sets outlineColor of the text to display
  72508. */
  72509. set outlineColor(value: string);
  72510. /**
  72511. * Creates a new TextBlock object
  72512. * @param name defines the name of the control
  72513. * @param text defines the text to display (emptry string by default)
  72514. */
  72515. constructor(
  72516. /**
  72517. * Defines the name of the control
  72518. */
  72519. name?: string | undefined, text?: string);
  72520. protected _getTypeName(): string;
  72521. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72522. private _drawText;
  72523. /** @hidden */
  72524. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72525. protected _applyStates(context: CanvasRenderingContext2D): void;
  72526. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72527. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72528. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72529. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72530. protected _renderLines(context: CanvasRenderingContext2D): void;
  72531. /**
  72532. * Given a width constraint applied on the text block, find the expected height
  72533. * @returns expected height
  72534. */
  72535. computeExpectedHeight(): number;
  72536. dispose(): void;
  72537. }
  72538. }
  72539. declare module BABYLON.GUI {
  72540. /**
  72541. * Class used to create 2D images
  72542. */
  72543. export class Image extends Control {
  72544. name?: string | undefined;
  72545. private _workingCanvas;
  72546. private _domImage;
  72547. private _imageWidth;
  72548. private _imageHeight;
  72549. private _loaded;
  72550. private _stretch;
  72551. private _source;
  72552. private _autoScale;
  72553. private _sourceLeft;
  72554. private _sourceTop;
  72555. private _sourceWidth;
  72556. private _sourceHeight;
  72557. private _svgAttributesComputationCompleted;
  72558. private _isSVG;
  72559. private _cellWidth;
  72560. private _cellHeight;
  72561. private _cellId;
  72562. private _populateNinePatchSlicesFromImage;
  72563. private _sliceLeft;
  72564. private _sliceRight;
  72565. private _sliceTop;
  72566. private _sliceBottom;
  72567. private _detectPointerOnOpaqueOnly;
  72568. /**
  72569. * BABYLON.Observable notified when the content is loaded
  72570. */
  72571. onImageLoadedObservable: BABYLON.Observable<Image>;
  72572. /**
  72573. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72574. */
  72575. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72576. /**
  72577. * Gets a boolean indicating that the content is loaded
  72578. */
  72579. get isLoaded(): boolean;
  72580. /**
  72581. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72582. */
  72583. get populateNinePatchSlicesFromImage(): boolean;
  72584. set populateNinePatchSlicesFromImage(value: boolean);
  72585. /**
  72586. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72587. * Beware using this as this will comsume more memory as the image has to be stored twice
  72588. */
  72589. get detectPointerOnOpaqueOnly(): boolean;
  72590. set detectPointerOnOpaqueOnly(value: boolean);
  72591. /**
  72592. * Gets or sets the left value for slicing (9-patch)
  72593. */
  72594. get sliceLeft(): number;
  72595. set sliceLeft(value: number);
  72596. /**
  72597. * Gets or sets the right value for slicing (9-patch)
  72598. */
  72599. get sliceRight(): number;
  72600. set sliceRight(value: number);
  72601. /**
  72602. * Gets or sets the top value for slicing (9-patch)
  72603. */
  72604. get sliceTop(): number;
  72605. set sliceTop(value: number);
  72606. /**
  72607. * Gets or sets the bottom value for slicing (9-patch)
  72608. */
  72609. get sliceBottom(): number;
  72610. set sliceBottom(value: number);
  72611. /**
  72612. * Gets or sets the left coordinate in the source image
  72613. */
  72614. get sourceLeft(): number;
  72615. set sourceLeft(value: number);
  72616. /**
  72617. * Gets or sets the top coordinate in the source image
  72618. */
  72619. get sourceTop(): number;
  72620. set sourceTop(value: number);
  72621. /**
  72622. * Gets or sets the width to capture in the source image
  72623. */
  72624. get sourceWidth(): number;
  72625. set sourceWidth(value: number);
  72626. /**
  72627. * Gets or sets the height to capture in the source image
  72628. */
  72629. get sourceHeight(): number;
  72630. set sourceHeight(value: number);
  72631. /** Indicates if the format of the image is SVG */
  72632. get isSVG(): boolean;
  72633. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72634. get svgAttributesComputationCompleted(): boolean;
  72635. /**
  72636. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72637. * @see http://doc.babylonjs.com/how_to/gui#image
  72638. */
  72639. get autoScale(): boolean;
  72640. set autoScale(value: boolean);
  72641. /** Gets or sets the streching mode used by the image */
  72642. get stretch(): number;
  72643. set stretch(value: number);
  72644. /** @hidden */
  72645. _rotate90(n: number, preserveProperties?: boolean): Image;
  72646. private _handleRotationForSVGImage;
  72647. private _rotate90SourceProperties;
  72648. /**
  72649. * Gets or sets the internal DOM image used to render the control
  72650. */
  72651. set domImage(value: HTMLImageElement);
  72652. get domImage(): HTMLImageElement;
  72653. private _onImageLoaded;
  72654. private _extractNinePatchSliceDataFromImage;
  72655. /**
  72656. * Gets or sets image source url
  72657. */
  72658. set source(value: BABYLON.Nullable<string>);
  72659. /**
  72660. * Checks for svg document with icon id present
  72661. */
  72662. private _svgCheck;
  72663. /**
  72664. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72665. * given external svg file and icon id
  72666. */
  72667. private _getSVGAttribs;
  72668. /**
  72669. * Gets or sets the cell width to use when animation sheet is enabled
  72670. * @see http://doc.babylonjs.com/how_to/gui#image
  72671. */
  72672. get cellWidth(): number;
  72673. set cellWidth(value: number);
  72674. /**
  72675. * Gets or sets the cell height to use when animation sheet is enabled
  72676. * @see http://doc.babylonjs.com/how_to/gui#image
  72677. */
  72678. get cellHeight(): number;
  72679. set cellHeight(value: number);
  72680. /**
  72681. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72682. * @see http://doc.babylonjs.com/how_to/gui#image
  72683. */
  72684. get cellId(): number;
  72685. set cellId(value: number);
  72686. /**
  72687. * Creates a new Image
  72688. * @param name defines the control name
  72689. * @param url defines the image url
  72690. */
  72691. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72692. /**
  72693. * Tests if a given coordinates belong to the current control
  72694. * @param x defines x coordinate to test
  72695. * @param y defines y coordinate to test
  72696. * @returns true if the coordinates are inside the control
  72697. */
  72698. contains(x: number, y: number): boolean;
  72699. protected _getTypeName(): string;
  72700. /** Force the control to synchronize with its content */
  72701. synchronizeSizeWithContent(): void;
  72702. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72703. private _prepareWorkingCanvasForOpaqueDetection;
  72704. private _drawImage;
  72705. _draw(context: CanvasRenderingContext2D): void;
  72706. private _renderCornerPatch;
  72707. private _renderNinePatch;
  72708. dispose(): void;
  72709. /** STRETCH_NONE */
  72710. static readonly STRETCH_NONE: number;
  72711. /** STRETCH_FILL */
  72712. static readonly STRETCH_FILL: number;
  72713. /** STRETCH_UNIFORM */
  72714. static readonly STRETCH_UNIFORM: number;
  72715. /** STRETCH_EXTEND */
  72716. static readonly STRETCH_EXTEND: number;
  72717. /** NINE_PATCH */
  72718. static readonly STRETCH_NINE_PATCH: number;
  72719. }
  72720. }
  72721. declare module BABYLON.GUI {
  72722. /**
  72723. * Class used to create 2D buttons
  72724. */
  72725. export class Button extends Rectangle {
  72726. name?: string | undefined;
  72727. /**
  72728. * Function called to generate a pointer enter animation
  72729. */
  72730. pointerEnterAnimation: () => void;
  72731. /**
  72732. * Function called to generate a pointer out animation
  72733. */
  72734. pointerOutAnimation: () => void;
  72735. /**
  72736. * Function called to generate a pointer down animation
  72737. */
  72738. pointerDownAnimation: () => void;
  72739. /**
  72740. * Function called to generate a pointer up animation
  72741. */
  72742. pointerUpAnimation: () => void;
  72743. /**
  72744. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72745. */
  72746. delegatePickingToChildren: boolean;
  72747. private _image;
  72748. /**
  72749. * Returns the image part of the button (if any)
  72750. */
  72751. get image(): BABYLON.Nullable<Image>;
  72752. private _textBlock;
  72753. /**
  72754. * Returns the image part of the button (if any)
  72755. */
  72756. get textBlock(): BABYLON.Nullable<TextBlock>;
  72757. /**
  72758. * Creates a new Button
  72759. * @param name defines the name of the button
  72760. */
  72761. constructor(name?: string | undefined);
  72762. protected _getTypeName(): string;
  72763. /** @hidden */
  72764. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72765. /** @hidden */
  72766. _onPointerEnter(target: Control): boolean;
  72767. /** @hidden */
  72768. _onPointerOut(target: Control, force?: boolean): void;
  72769. /** @hidden */
  72770. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72771. /** @hidden */
  72772. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72773. /**
  72774. * Creates a new button made with an image and a text
  72775. * @param name defines the name of the button
  72776. * @param text defines the text of the button
  72777. * @param imageUrl defines the url of the image
  72778. * @returns a new Button
  72779. */
  72780. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72781. /**
  72782. * Creates a new button made with an image
  72783. * @param name defines the name of the button
  72784. * @param imageUrl defines the url of the image
  72785. * @returns a new Button
  72786. */
  72787. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72788. /**
  72789. * Creates a new button made with a text
  72790. * @param name defines the name of the button
  72791. * @param text defines the text of the button
  72792. * @returns a new Button
  72793. */
  72794. static CreateSimpleButton(name: string, text: string): Button;
  72795. /**
  72796. * Creates a new button made with an image and a centered text
  72797. * @param name defines the name of the button
  72798. * @param text defines the text of the button
  72799. * @param imageUrl defines the url of the image
  72800. * @returns a new Button
  72801. */
  72802. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72803. }
  72804. }
  72805. declare module BABYLON.GUI {
  72806. /**
  72807. * Class used to create a 2D stack panel container
  72808. */
  72809. export class StackPanel extends Container {
  72810. name?: string | undefined;
  72811. private _isVertical;
  72812. private _manualWidth;
  72813. private _manualHeight;
  72814. private _doNotTrackManualChanges;
  72815. /**
  72816. * Gets or sets a boolean indicating that layou warnings should be ignored
  72817. */
  72818. ignoreLayoutWarnings: boolean;
  72819. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72820. get isVertical(): boolean;
  72821. set isVertical(value: boolean);
  72822. /**
  72823. * Gets or sets panel width.
  72824. * This value should not be set when in horizontal mode as it will be computed automatically
  72825. */
  72826. set width(value: string | number);
  72827. get width(): string | number;
  72828. /**
  72829. * Gets or sets panel height.
  72830. * This value should not be set when in vertical mode as it will be computed automatically
  72831. */
  72832. set height(value: string | number);
  72833. get height(): string | number;
  72834. /**
  72835. * Creates a new StackPanel
  72836. * @param name defines control name
  72837. */
  72838. constructor(name?: string | undefined);
  72839. protected _getTypeName(): string;
  72840. /** @hidden */
  72841. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72842. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72843. protected _postMeasure(): void;
  72844. }
  72845. }
  72846. declare module BABYLON.GUI {
  72847. /**
  72848. * Class used to represent a 2D checkbox
  72849. */
  72850. export class Checkbox extends Control {
  72851. name?: string | undefined;
  72852. private _isChecked;
  72853. private _background;
  72854. private _checkSizeRatio;
  72855. private _thickness;
  72856. /** Gets or sets border thickness */
  72857. get thickness(): number;
  72858. set thickness(value: number);
  72859. /**
  72860. * BABYLON.Observable raised when isChecked property changes
  72861. */
  72862. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72863. /** Gets or sets a value indicating the ratio between overall size and check size */
  72864. get checkSizeRatio(): number;
  72865. set checkSizeRatio(value: number);
  72866. /** Gets or sets background color */
  72867. get background(): string;
  72868. set background(value: string);
  72869. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72870. get isChecked(): boolean;
  72871. set isChecked(value: boolean);
  72872. /**
  72873. * Creates a new CheckBox
  72874. * @param name defines the control name
  72875. */
  72876. constructor(name?: string | undefined);
  72877. protected _getTypeName(): string;
  72878. /** @hidden */
  72879. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72880. /** @hidden */
  72881. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72882. /**
  72883. * Utility function to easily create a checkbox with a header
  72884. * @param title defines the label to use for the header
  72885. * @param onValueChanged defines the callback to call when value changes
  72886. * @returns a StackPanel containing the checkbox and a textBlock
  72887. */
  72888. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72889. }
  72890. }
  72891. declare module BABYLON.GUI {
  72892. /**
  72893. * Class used to store key control properties
  72894. */
  72895. export class KeyPropertySet {
  72896. /** Width */
  72897. width?: string;
  72898. /** Height */
  72899. height?: string;
  72900. /** Left padding */
  72901. paddingLeft?: string;
  72902. /** Right padding */
  72903. paddingRight?: string;
  72904. /** Top padding */
  72905. paddingTop?: string;
  72906. /** Bottom padding */
  72907. paddingBottom?: string;
  72908. /** Foreground color */
  72909. color?: string;
  72910. /** Background color */
  72911. background?: string;
  72912. }
  72913. /**
  72914. * Class used to create virtual keyboard
  72915. */
  72916. export class VirtualKeyboard extends StackPanel {
  72917. /** BABYLON.Observable raised when a key is pressed */
  72918. onKeyPressObservable: BABYLON.Observable<string>;
  72919. /** Gets or sets default key button width */
  72920. defaultButtonWidth: string;
  72921. /** Gets or sets default key button height */
  72922. defaultButtonHeight: string;
  72923. /** Gets or sets default key button left padding */
  72924. defaultButtonPaddingLeft: string;
  72925. /** Gets or sets default key button right padding */
  72926. defaultButtonPaddingRight: string;
  72927. /** Gets or sets default key button top padding */
  72928. defaultButtonPaddingTop: string;
  72929. /** Gets or sets default key button bottom padding */
  72930. defaultButtonPaddingBottom: string;
  72931. /** Gets or sets default key button foreground color */
  72932. defaultButtonColor: string;
  72933. /** Gets or sets default key button background color */
  72934. defaultButtonBackground: string;
  72935. /** Gets or sets shift button foreground color */
  72936. shiftButtonColor: string;
  72937. /** Gets or sets shift button thickness*/
  72938. selectedShiftThickness: number;
  72939. /** Gets shift key state */
  72940. shiftState: number;
  72941. protected _getTypeName(): string;
  72942. private _createKey;
  72943. /**
  72944. * Adds a new row of keys
  72945. * @param keys defines the list of keys to add
  72946. * @param propertySets defines the associated property sets
  72947. */
  72948. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72949. /**
  72950. * Set the shift key to a specific state
  72951. * @param shiftState defines the new shift state
  72952. */
  72953. applyShiftState(shiftState: number): void;
  72954. private _currentlyConnectedInputText;
  72955. private _connectedInputTexts;
  72956. private _onKeyPressObserver;
  72957. /** Gets the input text control currently attached to the keyboard */
  72958. get connectedInputText(): BABYLON.Nullable<InputText>;
  72959. /**
  72960. * Connects the keyboard with an input text control
  72961. *
  72962. * @param input defines the target control
  72963. */
  72964. connect(input: InputText): void;
  72965. /**
  72966. * Disconnects the keyboard from connected InputText controls
  72967. *
  72968. * @param input optionally defines a target control, otherwise all are disconnected
  72969. */
  72970. disconnect(input?: InputText): void;
  72971. private _removeConnectedInputObservables;
  72972. /**
  72973. * Release all resources
  72974. */
  72975. dispose(): void;
  72976. /**
  72977. * Creates a new keyboard using a default layout
  72978. *
  72979. * @param name defines control name
  72980. * @returns a new VirtualKeyboard
  72981. */
  72982. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72983. }
  72984. }
  72985. declare module BABYLON.GUI {
  72986. /**
  72987. * Class used to create input text control
  72988. */
  72989. export class InputText extends Control implements IFocusableControl {
  72990. name?: string | undefined;
  72991. private _text;
  72992. private _placeholderText;
  72993. private _background;
  72994. private _focusedBackground;
  72995. private _focusedColor;
  72996. private _placeholderColor;
  72997. private _thickness;
  72998. private _margin;
  72999. private _autoStretchWidth;
  73000. private _maxWidth;
  73001. private _isFocused;
  73002. private _blinkTimeout;
  73003. private _blinkIsEven;
  73004. private _cursorOffset;
  73005. private _scrollLeft;
  73006. private _textWidth;
  73007. private _clickedCoordinate;
  73008. private _deadKey;
  73009. private _addKey;
  73010. private _currentKey;
  73011. private _isTextHighlightOn;
  73012. private _textHighlightColor;
  73013. private _highligherOpacity;
  73014. private _highlightedText;
  73015. private _startHighlightIndex;
  73016. private _endHighlightIndex;
  73017. private _cursorIndex;
  73018. private _onFocusSelectAll;
  73019. private _isPointerDown;
  73020. private _onClipboardObserver;
  73021. private _onPointerDblTapObserver;
  73022. /** @hidden */
  73023. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73024. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73025. promptMessage: string;
  73026. /** Force disable prompt on mobile device */
  73027. disableMobilePrompt: boolean;
  73028. /** BABYLON.Observable raised when the text changes */
  73029. onTextChangedObservable: BABYLON.Observable<InputText>;
  73030. /** BABYLON.Observable raised just before an entered character is to be added */
  73031. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73032. /** BABYLON.Observable raised when the control gets the focus */
  73033. onFocusObservable: BABYLON.Observable<InputText>;
  73034. /** BABYLON.Observable raised when the control loses the focus */
  73035. onBlurObservable: BABYLON.Observable<InputText>;
  73036. /**Observable raised when the text is highlighted */
  73037. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73038. /**Observable raised when copy event is triggered */
  73039. onTextCopyObservable: BABYLON.Observable<InputText>;
  73040. /** BABYLON.Observable raised when cut event is triggered */
  73041. onTextCutObservable: BABYLON.Observable<InputText>;
  73042. /** BABYLON.Observable raised when paste event is triggered */
  73043. onTextPasteObservable: BABYLON.Observable<InputText>;
  73044. /** BABYLON.Observable raised when a key event was processed */
  73045. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73046. /** Gets or sets the maximum width allowed by the control */
  73047. get maxWidth(): string | number;
  73048. /** Gets the maximum width allowed by the control in pixels */
  73049. get maxWidthInPixels(): number;
  73050. set maxWidth(value: string | number);
  73051. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73052. get highligherOpacity(): number;
  73053. set highligherOpacity(value: number);
  73054. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73055. get onFocusSelectAll(): boolean;
  73056. set onFocusSelectAll(value: boolean);
  73057. /** Gets or sets the text hightlight color */
  73058. get textHighlightColor(): string;
  73059. set textHighlightColor(value: string);
  73060. /** Gets or sets control margin */
  73061. get margin(): string;
  73062. /** Gets control margin in pixels */
  73063. get marginInPixels(): number;
  73064. set margin(value: string);
  73065. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73066. get autoStretchWidth(): boolean;
  73067. set autoStretchWidth(value: boolean);
  73068. /** Gets or sets border thickness */
  73069. get thickness(): number;
  73070. set thickness(value: number);
  73071. /** Gets or sets the background color when focused */
  73072. get focusedBackground(): string;
  73073. set focusedBackground(value: string);
  73074. /** Gets or sets the background color when focused */
  73075. get focusedColor(): string;
  73076. set focusedColor(value: string);
  73077. /** Gets or sets the background color */
  73078. get background(): string;
  73079. set background(value: string);
  73080. /** Gets or sets the placeholder color */
  73081. get placeholderColor(): string;
  73082. set placeholderColor(value: string);
  73083. /** Gets or sets the text displayed when the control is empty */
  73084. get placeholderText(): string;
  73085. set placeholderText(value: string);
  73086. /** Gets or sets the dead key flag */
  73087. get deadKey(): boolean;
  73088. set deadKey(flag: boolean);
  73089. /** Gets or sets the highlight text */
  73090. get highlightedText(): string;
  73091. set highlightedText(text: string);
  73092. /** Gets or sets if the current key should be added */
  73093. get addKey(): boolean;
  73094. set addKey(flag: boolean);
  73095. /** Gets or sets the value of the current key being entered */
  73096. get currentKey(): string;
  73097. set currentKey(key: string);
  73098. /** Gets or sets the text displayed in the control */
  73099. get text(): string;
  73100. set text(value: string);
  73101. /** Gets or sets control width */
  73102. get width(): string | number;
  73103. set width(value: string | number);
  73104. /**
  73105. * Creates a new InputText
  73106. * @param name defines the control name
  73107. * @param text defines the text of the control
  73108. */
  73109. constructor(name?: string | undefined, text?: string);
  73110. /** @hidden */
  73111. onBlur(): void;
  73112. /** @hidden */
  73113. onFocus(): void;
  73114. protected _getTypeName(): string;
  73115. /**
  73116. * Function called to get the list of controls that should not steal the focus from this control
  73117. * @returns an array of controls
  73118. */
  73119. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73120. /** @hidden */
  73121. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73122. /** @hidden */
  73123. private _updateValueFromCursorIndex;
  73124. /** @hidden */
  73125. private _processDblClick;
  73126. /** @hidden */
  73127. private _selectAllText;
  73128. /**
  73129. * Handles the keyboard event
  73130. * @param evt Defines the KeyboardEvent
  73131. */
  73132. processKeyboard(evt: KeyboardEvent): void;
  73133. /** @hidden */
  73134. private _onCopyText;
  73135. /** @hidden */
  73136. private _onCutText;
  73137. /** @hidden */
  73138. private _onPasteText;
  73139. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73140. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73141. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73142. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73143. protected _beforeRenderText(text: string): string;
  73144. dispose(): void;
  73145. }
  73146. }
  73147. declare module BABYLON.GUI {
  73148. /**
  73149. * Class used to create a 2D grid container
  73150. */
  73151. export class Grid extends Container {
  73152. name?: string | undefined;
  73153. private _rowDefinitions;
  73154. private _columnDefinitions;
  73155. private _cells;
  73156. private _childControls;
  73157. /**
  73158. * Gets the number of columns
  73159. */
  73160. get columnCount(): number;
  73161. /**
  73162. * Gets the number of rows
  73163. */
  73164. get rowCount(): number;
  73165. /** Gets the list of children */
  73166. get children(): Control[];
  73167. /** Gets the list of cells (e.g. the containers) */
  73168. get cells(): {
  73169. [key: string]: Container;
  73170. };
  73171. /**
  73172. * Gets the definition of a specific row
  73173. * @param index defines the index of the row
  73174. * @returns the row definition
  73175. */
  73176. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73177. /**
  73178. * Gets the definition of a specific column
  73179. * @param index defines the index of the column
  73180. * @returns the column definition
  73181. */
  73182. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73183. /**
  73184. * Adds a new row to the grid
  73185. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73186. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73187. * @returns the current grid
  73188. */
  73189. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73190. /**
  73191. * Adds a new column to the grid
  73192. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73193. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73194. * @returns the current grid
  73195. */
  73196. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73197. /**
  73198. * Update a row definition
  73199. * @param index defines the index of the row to update
  73200. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73201. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73202. * @returns the current grid
  73203. */
  73204. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73205. /**
  73206. * Update a column definition
  73207. * @param index defines the index of the column to update
  73208. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73209. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73210. * @returns the current grid
  73211. */
  73212. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73213. /**
  73214. * Gets the list of children stored in a specific cell
  73215. * @param row defines the row to check
  73216. * @param column defines the column to check
  73217. * @returns the list of controls
  73218. */
  73219. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73220. /**
  73221. * Gets a string representing the child cell info (row x column)
  73222. * @param child defines the control to get info from
  73223. * @returns a string containing the child cell info (row x column)
  73224. */
  73225. getChildCellInfo(child: Control): string;
  73226. private _removeCell;
  73227. private _offsetCell;
  73228. /**
  73229. * Remove a column definition at specified index
  73230. * @param index defines the index of the column to remove
  73231. * @returns the current grid
  73232. */
  73233. removeColumnDefinition(index: number): Grid;
  73234. /**
  73235. * Remove a row definition at specified index
  73236. * @param index defines the index of the row to remove
  73237. * @returns the current grid
  73238. */
  73239. removeRowDefinition(index: number): Grid;
  73240. /**
  73241. * Adds a new control to the current grid
  73242. * @param control defines the control to add
  73243. * @param row defines the row where to add the control (0 by default)
  73244. * @param column defines the column where to add the control (0 by default)
  73245. * @returns the current grid
  73246. */
  73247. addControl(control: Control, row?: number, column?: number): Grid;
  73248. /**
  73249. * Removes a control from the current container
  73250. * @param control defines the control to remove
  73251. * @returns the current container
  73252. */
  73253. removeControl(control: Control): Container;
  73254. /**
  73255. * Creates a new Grid
  73256. * @param name defines control name
  73257. */
  73258. constructor(name?: string | undefined);
  73259. protected _getTypeName(): string;
  73260. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73261. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73262. _flagDescendantsAsMatrixDirty(): void;
  73263. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73264. /** Releases associated resources */
  73265. dispose(): void;
  73266. }
  73267. }
  73268. declare module BABYLON.GUI {
  73269. /** Class used to create color pickers */
  73270. export class ColorPicker extends Control {
  73271. name?: string | undefined;
  73272. private static _Epsilon;
  73273. private _colorWheelCanvas;
  73274. private _value;
  73275. private _tmpColor;
  73276. private _pointerStartedOnSquare;
  73277. private _pointerStartedOnWheel;
  73278. private _squareLeft;
  73279. private _squareTop;
  73280. private _squareSize;
  73281. private _h;
  73282. private _s;
  73283. private _v;
  73284. private _lastPointerDownID;
  73285. /**
  73286. * BABYLON.Observable raised when the value changes
  73287. */
  73288. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73289. /** Gets or sets the color of the color picker */
  73290. get value(): BABYLON.Color3;
  73291. set value(value: BABYLON.Color3);
  73292. /**
  73293. * Gets or sets control width
  73294. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73295. */
  73296. get width(): string | number;
  73297. set width(value: string | number);
  73298. /**
  73299. * Gets or sets control height
  73300. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73301. */
  73302. get height(): string | number;
  73303. /** Gets or sets control height */
  73304. set height(value: string | number);
  73305. /** Gets or sets control size */
  73306. get size(): string | number;
  73307. set size(value: string | number);
  73308. /**
  73309. * Creates a new ColorPicker
  73310. * @param name defines the control name
  73311. */
  73312. constructor(name?: string | undefined);
  73313. protected _getTypeName(): string;
  73314. /** @hidden */
  73315. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73316. private _updateSquareProps;
  73317. private _drawGradientSquare;
  73318. private _drawCircle;
  73319. private _createColorWheelCanvas;
  73320. /** @hidden */
  73321. _draw(context: CanvasRenderingContext2D): void;
  73322. private _pointerIsDown;
  73323. private _updateValueFromPointer;
  73324. private _isPointOnSquare;
  73325. private _isPointOnWheel;
  73326. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73327. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73328. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73329. /**
  73330. * This function expands the color picker by creating a color picker dialog with manual
  73331. * color value input and the ability to save colors into an array to be used later in
  73332. * subsequent launches of the dialogue.
  73333. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73334. * @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.
  73335. * @returns picked color as a hex string and the saved colors array as hex strings.
  73336. */
  73337. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73338. pickerWidth?: string;
  73339. pickerHeight?: string;
  73340. headerHeight?: string;
  73341. lastColor?: string;
  73342. swatchLimit?: number;
  73343. numSwatchesPerLine?: number;
  73344. savedColors?: Array<string>;
  73345. }): Promise<{
  73346. savedColors?: string[];
  73347. pickedColor: string;
  73348. }>;
  73349. }
  73350. }
  73351. declare module BABYLON.GUI {
  73352. /** Class used to create 2D ellipse containers */
  73353. export class Ellipse extends Container {
  73354. name?: string | undefined;
  73355. private _thickness;
  73356. /** Gets or sets border thickness */
  73357. get thickness(): number;
  73358. set thickness(value: number);
  73359. /**
  73360. * Creates a new Ellipse
  73361. * @param name defines the control name
  73362. */
  73363. constructor(name?: string | undefined);
  73364. protected _getTypeName(): string;
  73365. protected _localDraw(context: CanvasRenderingContext2D): void;
  73366. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73367. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73368. }
  73369. }
  73370. declare module BABYLON.GUI {
  73371. /**
  73372. * Class used to create a password control
  73373. */
  73374. export class InputPassword extends InputText {
  73375. protected _beforeRenderText(text: string): string;
  73376. }
  73377. }
  73378. declare module BABYLON.GUI {
  73379. /** Class used to render 2D lines */
  73380. export class Line extends Control {
  73381. name?: string | undefined;
  73382. private _lineWidth;
  73383. private _x1;
  73384. private _y1;
  73385. private _x2;
  73386. private _y2;
  73387. private _dash;
  73388. private _connectedControl;
  73389. private _connectedControlDirtyObserver;
  73390. /** Gets or sets the dash pattern */
  73391. get dash(): Array<number>;
  73392. set dash(value: Array<number>);
  73393. /** Gets or sets the control connected with the line end */
  73394. get connectedControl(): Control;
  73395. set connectedControl(value: Control);
  73396. /** Gets or sets start coordinates on X axis */
  73397. get x1(): string | number;
  73398. set x1(value: string | number);
  73399. /** Gets or sets start coordinates on Y axis */
  73400. get y1(): string | number;
  73401. set y1(value: string | number);
  73402. /** Gets or sets end coordinates on X axis */
  73403. get x2(): string | number;
  73404. set x2(value: string | number);
  73405. /** Gets or sets end coordinates on Y axis */
  73406. get y2(): string | number;
  73407. set y2(value: string | number);
  73408. /** Gets or sets line width */
  73409. get lineWidth(): number;
  73410. set lineWidth(value: number);
  73411. /** Gets or sets horizontal alignment */
  73412. set horizontalAlignment(value: number);
  73413. /** Gets or sets vertical alignment */
  73414. set verticalAlignment(value: number);
  73415. private get _effectiveX2();
  73416. private get _effectiveY2();
  73417. /**
  73418. * Creates a new Line
  73419. * @param name defines the control name
  73420. */
  73421. constructor(name?: string | undefined);
  73422. protected _getTypeName(): string;
  73423. _draw(context: CanvasRenderingContext2D): void;
  73424. _measure(): void;
  73425. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73426. /**
  73427. * Move one end of the line given 3D cartesian coordinates.
  73428. * @param position Targeted world position
  73429. * @param scene BABYLON.Scene
  73430. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73431. */
  73432. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73433. /**
  73434. * Move one end of the line to a position in screen absolute space.
  73435. * @param projectedPosition Position in screen absolute space (X, Y)
  73436. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73437. */
  73438. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73439. }
  73440. }
  73441. declare module BABYLON.GUI {
  73442. /**
  73443. * Class used to store a point for a MultiLine object.
  73444. * The point can be pure 2D coordinates, a mesh or a control
  73445. */
  73446. export class MultiLinePoint {
  73447. private _multiLine;
  73448. private _x;
  73449. private _y;
  73450. private _control;
  73451. private _mesh;
  73452. private _controlObserver;
  73453. private _meshObserver;
  73454. /** @hidden */
  73455. _point: BABYLON.Vector2;
  73456. /**
  73457. * Creates a new MultiLinePoint
  73458. * @param multiLine defines the source MultiLine object
  73459. */
  73460. constructor(multiLine: MultiLine);
  73461. /** Gets or sets x coordinate */
  73462. get x(): string | number;
  73463. set x(value: string | number);
  73464. /** Gets or sets y coordinate */
  73465. get y(): string | number;
  73466. set y(value: string | number);
  73467. /** Gets or sets the control associated with this point */
  73468. get control(): BABYLON.Nullable<Control>;
  73469. set control(value: BABYLON.Nullable<Control>);
  73470. /** Gets or sets the mesh associated with this point */
  73471. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73472. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73473. /** Resets links */
  73474. resetLinks(): void;
  73475. /**
  73476. * Gets a translation vector
  73477. * @returns the translation vector
  73478. */
  73479. translate(): BABYLON.Vector2;
  73480. private _translatePoint;
  73481. /** Release associated resources */
  73482. dispose(): void;
  73483. }
  73484. }
  73485. declare module BABYLON.GUI {
  73486. /**
  73487. * Class used to create multi line control
  73488. */
  73489. export class MultiLine extends Control {
  73490. name?: string | undefined;
  73491. private _lineWidth;
  73492. private _dash;
  73493. private _points;
  73494. private _minX;
  73495. private _minY;
  73496. private _maxX;
  73497. private _maxY;
  73498. /**
  73499. * Creates a new MultiLine
  73500. * @param name defines the control name
  73501. */
  73502. constructor(name?: string | undefined);
  73503. /** Gets or sets dash pattern */
  73504. get dash(): Array<number>;
  73505. set dash(value: Array<number>);
  73506. /**
  73507. * Gets point stored at specified index
  73508. * @param index defines the index to look for
  73509. * @returns the requested point if found
  73510. */
  73511. getAt(index: number): MultiLinePoint;
  73512. /** Function called when a point is updated */
  73513. onPointUpdate: () => void;
  73514. /**
  73515. * Adds new points to the point collection
  73516. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73517. * @returns the list of created MultiLinePoint
  73518. */
  73519. add(...items: (AbstractMesh | Control | {
  73520. x: string | number;
  73521. y: string | number;
  73522. })[]): MultiLinePoint[];
  73523. /**
  73524. * Adds a new point to the point collection
  73525. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73526. * @returns the created MultiLinePoint
  73527. */
  73528. push(item?: (AbstractMesh | Control | {
  73529. x: string | number;
  73530. y: string | number;
  73531. })): MultiLinePoint;
  73532. /**
  73533. * Remove a specific value or point from the active point collection
  73534. * @param value defines the value or point to remove
  73535. */
  73536. remove(value: number | MultiLinePoint): void;
  73537. /**
  73538. * Resets this object to initial state (no point)
  73539. */
  73540. reset(): void;
  73541. /**
  73542. * Resets all links
  73543. */
  73544. resetLinks(): void;
  73545. /** Gets or sets line width */
  73546. get lineWidth(): number;
  73547. set lineWidth(value: number);
  73548. set horizontalAlignment(value: number);
  73549. set verticalAlignment(value: number);
  73550. protected _getTypeName(): string;
  73551. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73552. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73553. _measure(): void;
  73554. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73555. dispose(): void;
  73556. }
  73557. }
  73558. declare module BABYLON.GUI {
  73559. /**
  73560. * Class used to create radio button controls
  73561. */
  73562. export class RadioButton extends Control {
  73563. name?: string | undefined;
  73564. private _isChecked;
  73565. private _background;
  73566. private _checkSizeRatio;
  73567. private _thickness;
  73568. /** Gets or sets border thickness */
  73569. get thickness(): number;
  73570. set thickness(value: number);
  73571. /** Gets or sets group name */
  73572. group: string;
  73573. /** BABYLON.Observable raised when isChecked is changed */
  73574. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73575. /** Gets or sets a value indicating the ratio between overall size and check size */
  73576. get checkSizeRatio(): number;
  73577. set checkSizeRatio(value: number);
  73578. /** Gets or sets background color */
  73579. get background(): string;
  73580. set background(value: string);
  73581. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73582. get isChecked(): boolean;
  73583. set isChecked(value: boolean);
  73584. /**
  73585. * Creates a new RadioButton
  73586. * @param name defines the control name
  73587. */
  73588. constructor(name?: string | undefined);
  73589. protected _getTypeName(): string;
  73590. _draw(context: CanvasRenderingContext2D): void;
  73591. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73592. /**
  73593. * Utility function to easily create a radio button with a header
  73594. * @param title defines the label to use for the header
  73595. * @param group defines the group to use for the radio button
  73596. * @param isChecked defines the initial state of the radio button
  73597. * @param onValueChanged defines the callback to call when value changes
  73598. * @returns a StackPanel containing the radio button and a textBlock
  73599. */
  73600. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73601. }
  73602. }
  73603. declare module BABYLON.GUI {
  73604. /**
  73605. * Class used to create slider controls
  73606. */
  73607. export class BaseSlider extends Control {
  73608. name?: string | undefined;
  73609. protected _thumbWidth: ValueAndUnit;
  73610. private _minimum;
  73611. private _maximum;
  73612. private _value;
  73613. private _isVertical;
  73614. protected _barOffset: ValueAndUnit;
  73615. private _isThumbClamped;
  73616. protected _displayThumb: boolean;
  73617. private _step;
  73618. private _lastPointerDownID;
  73619. protected _effectiveBarOffset: number;
  73620. protected _renderLeft: number;
  73621. protected _renderTop: number;
  73622. protected _renderWidth: number;
  73623. protected _renderHeight: number;
  73624. protected _backgroundBoxLength: number;
  73625. protected _backgroundBoxThickness: number;
  73626. protected _effectiveThumbThickness: number;
  73627. /** BABYLON.Observable raised when the sldier value changes */
  73628. onValueChangedObservable: BABYLON.Observable<number>;
  73629. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73630. get displayThumb(): boolean;
  73631. set displayThumb(value: boolean);
  73632. /** Gets or sets a step to apply to values (0 by default) */
  73633. get step(): number;
  73634. set step(value: number);
  73635. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73636. get barOffset(): string | number;
  73637. /** Gets main bar offset in pixels*/
  73638. get barOffsetInPixels(): number;
  73639. set barOffset(value: string | number);
  73640. /** Gets or sets thumb width */
  73641. get thumbWidth(): string | number;
  73642. /** Gets thumb width in pixels */
  73643. get thumbWidthInPixels(): number;
  73644. set thumbWidth(value: string | number);
  73645. /** Gets or sets minimum value */
  73646. get minimum(): number;
  73647. set minimum(value: number);
  73648. /** Gets or sets maximum value */
  73649. get maximum(): number;
  73650. set maximum(value: number);
  73651. /** Gets or sets current value */
  73652. get value(): number;
  73653. set value(value: number);
  73654. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73655. get isVertical(): boolean;
  73656. set isVertical(value: boolean);
  73657. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73658. get isThumbClamped(): boolean;
  73659. set isThumbClamped(value: boolean);
  73660. /**
  73661. * Creates a new BaseSlider
  73662. * @param name defines the control name
  73663. */
  73664. constructor(name?: string | undefined);
  73665. protected _getTypeName(): string;
  73666. protected _getThumbPosition(): number;
  73667. protected _getThumbThickness(type: string): number;
  73668. protected _prepareRenderingData(type: string): void;
  73669. private _pointerIsDown;
  73670. /** @hidden */
  73671. protected _updateValueFromPointer(x: number, y: number): void;
  73672. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73673. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73674. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73675. }
  73676. }
  73677. declare module BABYLON.GUI {
  73678. /**
  73679. * Class used to create slider controls
  73680. */
  73681. export class Slider extends BaseSlider {
  73682. name?: string | undefined;
  73683. private _background;
  73684. private _borderColor;
  73685. private _isThumbCircle;
  73686. protected _displayValueBar: boolean;
  73687. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73688. get displayValueBar(): boolean;
  73689. set displayValueBar(value: boolean);
  73690. /** Gets or sets border color */
  73691. get borderColor(): string;
  73692. set borderColor(value: string);
  73693. /** Gets or sets background color */
  73694. get background(): string;
  73695. set background(value: string);
  73696. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73697. get isThumbCircle(): boolean;
  73698. set isThumbCircle(value: boolean);
  73699. /**
  73700. * Creates a new Slider
  73701. * @param name defines the control name
  73702. */
  73703. constructor(name?: string | undefined);
  73704. protected _getTypeName(): string;
  73705. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73706. }
  73707. }
  73708. declare module BABYLON.GUI {
  73709. /** Class used to create a RadioGroup
  73710. * which contains groups of radio buttons
  73711. */
  73712. export class SelectorGroup {
  73713. /** name of SelectorGroup */
  73714. name: string;
  73715. private _groupPanel;
  73716. private _selectors;
  73717. private _groupHeader;
  73718. /**
  73719. * Creates a new SelectorGroup
  73720. * @param name of group, used as a group heading
  73721. */
  73722. constructor(
  73723. /** name of SelectorGroup */
  73724. name: string);
  73725. /** Gets the groupPanel of the SelectorGroup */
  73726. get groupPanel(): StackPanel;
  73727. /** Gets the selectors array */
  73728. get selectors(): StackPanel[];
  73729. /** Gets and sets the group header */
  73730. get header(): string;
  73731. set header(label: string);
  73732. /** @hidden */
  73733. private _addGroupHeader;
  73734. /** @hidden*/
  73735. _getSelector(selectorNb: number): StackPanel | undefined;
  73736. /** Removes the selector at the given position
  73737. * @param selectorNb the position of the selector within the group
  73738. */
  73739. removeSelector(selectorNb: number): void;
  73740. }
  73741. /** Class used to create a CheckboxGroup
  73742. * which contains groups of checkbox buttons
  73743. */
  73744. export class CheckboxGroup extends SelectorGroup {
  73745. /** Adds a checkbox as a control
  73746. * @param text is the label for the selector
  73747. * @param func is the function called when the Selector is checked
  73748. * @param checked is true when Selector is checked
  73749. */
  73750. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73751. /** @hidden */
  73752. _setSelectorLabel(selectorNb: number, label: string): void;
  73753. /** @hidden */
  73754. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73755. /** @hidden */
  73756. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73757. /** @hidden */
  73758. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73759. }
  73760. /** Class used to create a RadioGroup
  73761. * which contains groups of radio buttons
  73762. */
  73763. export class RadioGroup extends SelectorGroup {
  73764. private _selectNb;
  73765. /** Adds a radio button as a control
  73766. * @param label is the label for the selector
  73767. * @param func is the function called when the Selector is checked
  73768. * @param checked is true when Selector is checked
  73769. */
  73770. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73771. /** @hidden */
  73772. _setSelectorLabel(selectorNb: number, label: string): void;
  73773. /** @hidden */
  73774. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73775. /** @hidden */
  73776. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73777. /** @hidden */
  73778. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73779. }
  73780. /** Class used to create a SliderGroup
  73781. * which contains groups of slider buttons
  73782. */
  73783. export class SliderGroup extends SelectorGroup {
  73784. /**
  73785. * Adds a slider to the SelectorGroup
  73786. * @param label is the label for the SliderBar
  73787. * @param func is the function called when the Slider moves
  73788. * @param unit is a string describing the units used, eg degrees or metres
  73789. * @param min is the minimum value for the Slider
  73790. * @param max is the maximum value for the Slider
  73791. * @param value is the start value for the Slider between min and max
  73792. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73793. */
  73794. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73795. /** @hidden */
  73796. _setSelectorLabel(selectorNb: number, label: string): void;
  73797. /** @hidden */
  73798. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73799. /** @hidden */
  73800. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73801. /** @hidden */
  73802. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73803. }
  73804. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73805. * @see http://doc.babylonjs.com/how_to/selector
  73806. */
  73807. export class SelectionPanel extends Rectangle {
  73808. /** name of SelectionPanel */
  73809. name: string;
  73810. /** an array of SelectionGroups */
  73811. groups: SelectorGroup[];
  73812. private _panel;
  73813. private _buttonColor;
  73814. private _buttonBackground;
  73815. private _headerColor;
  73816. private _barColor;
  73817. private _barHeight;
  73818. private _spacerHeight;
  73819. private _labelColor;
  73820. private _groups;
  73821. private _bars;
  73822. /**
  73823. * Creates a new SelectionPanel
  73824. * @param name of SelectionPanel
  73825. * @param groups is an array of SelectionGroups
  73826. */
  73827. constructor(
  73828. /** name of SelectionPanel */
  73829. name: string,
  73830. /** an array of SelectionGroups */
  73831. groups?: SelectorGroup[]);
  73832. protected _getTypeName(): string;
  73833. /** Gets or sets the headerColor */
  73834. get headerColor(): string;
  73835. set headerColor(color: string);
  73836. private _setHeaderColor;
  73837. /** Gets or sets the button color */
  73838. get buttonColor(): string;
  73839. set buttonColor(color: string);
  73840. private _setbuttonColor;
  73841. /** Gets or sets the label color */
  73842. get labelColor(): string;
  73843. set labelColor(color: string);
  73844. private _setLabelColor;
  73845. /** Gets or sets the button background */
  73846. get buttonBackground(): string;
  73847. set buttonBackground(color: string);
  73848. private _setButtonBackground;
  73849. /** Gets or sets the color of separator bar */
  73850. get barColor(): string;
  73851. set barColor(color: string);
  73852. private _setBarColor;
  73853. /** Gets or sets the height of separator bar */
  73854. get barHeight(): string;
  73855. set barHeight(value: string);
  73856. private _setBarHeight;
  73857. /** Gets or sets the height of spacers*/
  73858. get spacerHeight(): string;
  73859. set spacerHeight(value: string);
  73860. private _setSpacerHeight;
  73861. /** Adds a bar between groups */
  73862. private _addSpacer;
  73863. /** Add a group to the selection panel
  73864. * @param group is the selector group to add
  73865. */
  73866. addGroup(group: SelectorGroup): void;
  73867. /** Remove the group from the given position
  73868. * @param groupNb is the position of the group in the list
  73869. */
  73870. removeGroup(groupNb: number): void;
  73871. /** Change a group header label
  73872. * @param label is the new group header label
  73873. * @param groupNb is the number of the group to relabel
  73874. * */
  73875. setHeaderName(label: string, groupNb: number): void;
  73876. /** Change selector label to the one given
  73877. * @param label is the new selector label
  73878. * @param groupNb is the number of the groupcontaining the selector
  73879. * @param selectorNb is the number of the selector within a group to relabel
  73880. * */
  73881. relabel(label: string, groupNb: number, selectorNb: number): void;
  73882. /** For a given group position remove the selector at the given position
  73883. * @param groupNb is the number of the group to remove the selector from
  73884. * @param selectorNb is the number of the selector within the group
  73885. */
  73886. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73887. /** For a given group position of correct type add a checkbox button
  73888. * @param groupNb is the number of the group to remove the selector from
  73889. * @param label is the label for the selector
  73890. * @param func is the function called when the Selector is checked
  73891. * @param checked is true when Selector is checked
  73892. */
  73893. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73894. /** For a given group position of correct type add a radio button
  73895. * @param groupNb is the number of the group to remove the selector from
  73896. * @param label is the label for the selector
  73897. * @param func is the function called when the Selector is checked
  73898. * @param checked is true when Selector is checked
  73899. */
  73900. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73901. /**
  73902. * For a given slider group add a slider
  73903. * @param groupNb is the number of the group to add the slider to
  73904. * @param label is the label for the Slider
  73905. * @param func is the function called when the Slider moves
  73906. * @param unit is a string describing the units used, eg degrees or metres
  73907. * @param min is the minimum value for the Slider
  73908. * @param max is the maximum value for the Slider
  73909. * @param value is the start value for the Slider between min and max
  73910. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73911. */
  73912. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73913. }
  73914. }
  73915. declare module BABYLON.GUI {
  73916. /**
  73917. * Class used to hold a the container for ScrollViewer
  73918. * @hidden
  73919. */
  73920. export class _ScrollViewerWindow extends Container {
  73921. parentClientWidth: number;
  73922. parentClientHeight: number;
  73923. private _freezeControls;
  73924. private _parentMeasure;
  73925. private _oldLeft;
  73926. private _oldTop;
  73927. get freezeControls(): boolean;
  73928. set freezeControls(value: boolean);
  73929. private _bucketWidth;
  73930. private _bucketHeight;
  73931. private _buckets;
  73932. private _bucketLen;
  73933. get bucketWidth(): number;
  73934. get bucketHeight(): number;
  73935. setBucketSizes(width: number, height: number): void;
  73936. private _useBuckets;
  73937. private _makeBuckets;
  73938. private _dispatchInBuckets;
  73939. private _updateMeasures;
  73940. private _updateChildrenMeasures;
  73941. private _restoreMeasures;
  73942. /**
  73943. * Creates a new ScrollViewerWindow
  73944. * @param name of ScrollViewerWindow
  73945. */
  73946. constructor(name?: string);
  73947. protected _getTypeName(): string;
  73948. /** @hidden */
  73949. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73950. /** @hidden */
  73951. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73952. private _scrollChildren;
  73953. private _scrollChildrenWithBuckets;
  73954. /** @hidden */
  73955. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73956. protected _postMeasure(): void;
  73957. }
  73958. }
  73959. declare module BABYLON.GUI {
  73960. /**
  73961. * Class used to create slider controls
  73962. */
  73963. export class ScrollBar extends BaseSlider {
  73964. name?: string | undefined;
  73965. private _background;
  73966. private _borderColor;
  73967. private _tempMeasure;
  73968. /** Gets or sets border color */
  73969. get borderColor(): string;
  73970. set borderColor(value: string);
  73971. /** Gets or sets background color */
  73972. get background(): string;
  73973. set background(value: string);
  73974. /**
  73975. * Creates a new Slider
  73976. * @param name defines the control name
  73977. */
  73978. constructor(name?: string | undefined);
  73979. protected _getTypeName(): string;
  73980. protected _getThumbThickness(): number;
  73981. _draw(context: CanvasRenderingContext2D): void;
  73982. private _first;
  73983. private _originX;
  73984. private _originY;
  73985. /** @hidden */
  73986. protected _updateValueFromPointer(x: number, y: number): void;
  73987. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73988. }
  73989. }
  73990. declare module BABYLON.GUI {
  73991. /**
  73992. * Class used to create slider controls
  73993. */
  73994. export class ImageScrollBar extends BaseSlider {
  73995. name?: string | undefined;
  73996. private _backgroundBaseImage;
  73997. private _backgroundImage;
  73998. private _thumbImage;
  73999. private _thumbBaseImage;
  74000. private _thumbLength;
  74001. private _thumbHeight;
  74002. private _barImageHeight;
  74003. private _tempMeasure;
  74004. /** Number of 90° rotation to apply on the images when in vertical mode */
  74005. num90RotationInVerticalMode: number;
  74006. /**
  74007. * Gets or sets the image used to render the background for horizontal bar
  74008. */
  74009. get backgroundImage(): Image;
  74010. set backgroundImage(value: Image);
  74011. /**
  74012. * Gets or sets the image used to render the thumb
  74013. */
  74014. get thumbImage(): Image;
  74015. set thumbImage(value: Image);
  74016. /**
  74017. * Gets or sets the length of the thumb
  74018. */
  74019. get thumbLength(): number;
  74020. set thumbLength(value: number);
  74021. /**
  74022. * Gets or sets the height of the thumb
  74023. */
  74024. get thumbHeight(): number;
  74025. set thumbHeight(value: number);
  74026. /**
  74027. * Gets or sets the height of the bar image
  74028. */
  74029. get barImageHeight(): number;
  74030. set barImageHeight(value: number);
  74031. /**
  74032. * Creates a new ImageScrollBar
  74033. * @param name defines the control name
  74034. */
  74035. constructor(name?: string | undefined);
  74036. protected _getTypeName(): string;
  74037. protected _getThumbThickness(): number;
  74038. _draw(context: CanvasRenderingContext2D): void;
  74039. private _first;
  74040. private _originX;
  74041. private _originY;
  74042. /** @hidden */
  74043. protected _updateValueFromPointer(x: number, y: number): void;
  74044. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74045. }
  74046. }
  74047. declare module BABYLON.GUI {
  74048. /**
  74049. * Class used to hold a viewer window and sliders in a grid
  74050. */
  74051. export class ScrollViewer extends Rectangle {
  74052. private _grid;
  74053. private _horizontalBarSpace;
  74054. private _verticalBarSpace;
  74055. private _dragSpace;
  74056. private _horizontalBar;
  74057. private _verticalBar;
  74058. private _barColor;
  74059. private _barBackground;
  74060. private _barImage;
  74061. private _horizontalBarImage;
  74062. private _verticalBarImage;
  74063. private _barBackgroundImage;
  74064. private _horizontalBarBackgroundImage;
  74065. private _verticalBarBackgroundImage;
  74066. private _barSize;
  74067. private _window;
  74068. private _pointerIsOver;
  74069. private _wheelPrecision;
  74070. private _onWheelObserver;
  74071. private _clientWidth;
  74072. private _clientHeight;
  74073. private _useImageBar;
  74074. private _thumbLength;
  74075. private _thumbHeight;
  74076. private _barImageHeight;
  74077. private _horizontalBarImageHeight;
  74078. private _verticalBarImageHeight;
  74079. /**
  74080. * Gets the horizontal scrollbar
  74081. */
  74082. get horizontalBar(): ScrollBar | ImageScrollBar;
  74083. /**
  74084. * Gets the vertical scrollbar
  74085. */
  74086. get verticalBar(): ScrollBar | ImageScrollBar;
  74087. /**
  74088. * Adds a new control to the current container
  74089. * @param control defines the control to add
  74090. * @returns the current container
  74091. */
  74092. addControl(control: BABYLON.Nullable<Control>): Container;
  74093. /**
  74094. * Removes a control from the current container
  74095. * @param control defines the control to remove
  74096. * @returns the current container
  74097. */
  74098. removeControl(control: Control): Container;
  74099. /** Gets the list of children */
  74100. get children(): Control[];
  74101. _flagDescendantsAsMatrixDirty(): void;
  74102. /**
  74103. * Freezes or unfreezes the controls in the window.
  74104. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74105. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74106. */
  74107. get freezeControls(): boolean;
  74108. set freezeControls(value: boolean);
  74109. /** Gets the bucket width */
  74110. get bucketWidth(): number;
  74111. /** Gets the bucket height */
  74112. get bucketHeight(): number;
  74113. /**
  74114. * Sets the bucket sizes.
  74115. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74116. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74117. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74118. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74119. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74120. * used), that's why it is not enabled by default.
  74121. * @param width width of the bucket
  74122. * @param height height of the bucket
  74123. */
  74124. setBucketSizes(width: number, height: number): void;
  74125. private _forceHorizontalBar;
  74126. private _forceVerticalBar;
  74127. /**
  74128. * Forces the horizontal scroll bar to be displayed
  74129. */
  74130. get forceHorizontalBar(): boolean;
  74131. set forceHorizontalBar(value: boolean);
  74132. /**
  74133. * Forces the vertical scroll bar to be displayed
  74134. */
  74135. get forceVerticalBar(): boolean;
  74136. set forceVerticalBar(value: boolean);
  74137. /**
  74138. * Creates a new ScrollViewer
  74139. * @param name of ScrollViewer
  74140. */
  74141. constructor(name?: string, isImageBased?: boolean);
  74142. /** Reset the scroll viewer window to initial size */
  74143. resetWindow(): void;
  74144. protected _getTypeName(): string;
  74145. private _buildClientSizes;
  74146. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74147. protected _postMeasure(): void;
  74148. /**
  74149. * Gets or sets the mouse wheel precision
  74150. * from 0 to 1 with a default value of 0.05
  74151. * */
  74152. get wheelPrecision(): number;
  74153. set wheelPrecision(value: number);
  74154. /** Gets or sets the scroll bar container background color */
  74155. get scrollBackground(): string;
  74156. set scrollBackground(color: string);
  74157. /** Gets or sets the bar color */
  74158. get barColor(): string;
  74159. set barColor(color: string);
  74160. /** Gets or sets the bar image */
  74161. get thumbImage(): Image;
  74162. set thumbImage(value: Image);
  74163. /** Gets or sets the horizontal bar image */
  74164. get horizontalThumbImage(): Image;
  74165. set horizontalThumbImage(value: Image);
  74166. /** Gets or sets the vertical bar image */
  74167. get verticalThumbImage(): Image;
  74168. set verticalThumbImage(value: Image);
  74169. /** Gets or sets the size of the bar */
  74170. get barSize(): number;
  74171. set barSize(value: number);
  74172. /** Gets or sets the length of the thumb */
  74173. get thumbLength(): number;
  74174. set thumbLength(value: number);
  74175. /** Gets or sets the height of the thumb */
  74176. get thumbHeight(): number;
  74177. set thumbHeight(value: number);
  74178. /** Gets or sets the height of the bar image */
  74179. get barImageHeight(): number;
  74180. set barImageHeight(value: number);
  74181. /** Gets or sets the height of the horizontal bar image */
  74182. get horizontalBarImageHeight(): number;
  74183. set horizontalBarImageHeight(value: number);
  74184. /** Gets or sets the height of the vertical bar image */
  74185. get verticalBarImageHeight(): number;
  74186. set verticalBarImageHeight(value: number);
  74187. /** Gets or sets the bar background */
  74188. get barBackground(): string;
  74189. set barBackground(color: string);
  74190. /** Gets or sets the bar background image */
  74191. get barImage(): Image;
  74192. set barImage(value: Image);
  74193. /** Gets or sets the horizontal bar background image */
  74194. get horizontalBarImage(): Image;
  74195. set horizontalBarImage(value: Image);
  74196. /** Gets or sets the vertical bar background image */
  74197. get verticalBarImage(): Image;
  74198. set verticalBarImage(value: Image);
  74199. private _setWindowPosition;
  74200. /** @hidden */
  74201. private _updateScroller;
  74202. _link(host: AdvancedDynamicTexture): void;
  74203. /** @hidden */
  74204. private _addBar;
  74205. /** @hidden */
  74206. private _attachWheel;
  74207. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74208. /** Releases associated resources */
  74209. dispose(): void;
  74210. }
  74211. }
  74212. declare module BABYLON.GUI {
  74213. /** Class used to render a grid */
  74214. export class DisplayGrid extends Control {
  74215. name?: string | undefined;
  74216. private _cellWidth;
  74217. private _cellHeight;
  74218. private _minorLineTickness;
  74219. private _minorLineColor;
  74220. private _majorLineTickness;
  74221. private _majorLineColor;
  74222. private _majorLineFrequency;
  74223. private _background;
  74224. private _displayMajorLines;
  74225. private _displayMinorLines;
  74226. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74227. get displayMinorLines(): boolean;
  74228. set displayMinorLines(value: boolean);
  74229. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74230. get displayMajorLines(): boolean;
  74231. set displayMajorLines(value: boolean);
  74232. /** Gets or sets background color (Black by default) */
  74233. get background(): string;
  74234. set background(value: string);
  74235. /** Gets or sets the width of each cell (20 by default) */
  74236. get cellWidth(): number;
  74237. set cellWidth(value: number);
  74238. /** Gets or sets the height of each cell (20 by default) */
  74239. get cellHeight(): number;
  74240. set cellHeight(value: number);
  74241. /** Gets or sets the tickness of minor lines (1 by default) */
  74242. get minorLineTickness(): number;
  74243. set minorLineTickness(value: number);
  74244. /** Gets or sets the color of minor lines (DarkGray by default) */
  74245. get minorLineColor(): string;
  74246. set minorLineColor(value: string);
  74247. /** Gets or sets the tickness of major lines (2 by default) */
  74248. get majorLineTickness(): number;
  74249. set majorLineTickness(value: number);
  74250. /** Gets or sets the color of major lines (White by default) */
  74251. get majorLineColor(): string;
  74252. set majorLineColor(value: string);
  74253. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74254. get majorLineFrequency(): number;
  74255. set majorLineFrequency(value: number);
  74256. /**
  74257. * Creates a new GridDisplayRectangle
  74258. * @param name defines the control name
  74259. */
  74260. constructor(name?: string | undefined);
  74261. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74262. protected _getTypeName(): string;
  74263. }
  74264. }
  74265. declare module BABYLON.GUI {
  74266. /**
  74267. * Class used to create slider controls based on images
  74268. */
  74269. export class ImageBasedSlider extends BaseSlider {
  74270. name?: string | undefined;
  74271. private _backgroundImage;
  74272. private _thumbImage;
  74273. private _valueBarImage;
  74274. private _tempMeasure;
  74275. get displayThumb(): boolean;
  74276. set displayThumb(value: boolean);
  74277. /**
  74278. * Gets or sets the image used to render the background
  74279. */
  74280. get backgroundImage(): Image;
  74281. set backgroundImage(value: Image);
  74282. /**
  74283. * Gets or sets the image used to render the value bar
  74284. */
  74285. get valueBarImage(): Image;
  74286. set valueBarImage(value: Image);
  74287. /**
  74288. * Gets or sets the image used to render the thumb
  74289. */
  74290. get thumbImage(): Image;
  74291. set thumbImage(value: Image);
  74292. /**
  74293. * Creates a new ImageBasedSlider
  74294. * @param name defines the control name
  74295. */
  74296. constructor(name?: string | undefined);
  74297. protected _getTypeName(): string;
  74298. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74299. }
  74300. }
  74301. declare module BABYLON.GUI {
  74302. /**
  74303. * Forcing an export so that this code will execute
  74304. * @hidden
  74305. */
  74306. const name = "Statics";
  74307. }
  74308. declare module BABYLON.GUI {
  74309. /**
  74310. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74311. */
  74312. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74313. /**
  74314. * Define the instrumented AdvancedDynamicTexture.
  74315. */
  74316. texture: AdvancedDynamicTexture;
  74317. private _captureRenderTime;
  74318. private _renderTime;
  74319. private _captureLayoutTime;
  74320. private _layoutTime;
  74321. private _onBeginRenderObserver;
  74322. private _onEndRenderObserver;
  74323. private _onBeginLayoutObserver;
  74324. private _onEndLayoutObserver;
  74325. /**
  74326. * Gets the perf counter used to capture render time
  74327. */
  74328. get renderTimeCounter(): BABYLON.PerfCounter;
  74329. /**
  74330. * Gets the perf counter used to capture layout time
  74331. */
  74332. get layoutTimeCounter(): BABYLON.PerfCounter;
  74333. /**
  74334. * Enable or disable the render time capture
  74335. */
  74336. get captureRenderTime(): boolean;
  74337. set captureRenderTime(value: boolean);
  74338. /**
  74339. * Enable or disable the layout time capture
  74340. */
  74341. get captureLayoutTime(): boolean;
  74342. set captureLayoutTime(value: boolean);
  74343. /**
  74344. * Instantiates a new advanced dynamic texture instrumentation.
  74345. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74346. * @param texture Defines the AdvancedDynamicTexture to instrument
  74347. */
  74348. constructor(
  74349. /**
  74350. * Define the instrumented AdvancedDynamicTexture.
  74351. */
  74352. texture: AdvancedDynamicTexture);
  74353. /**
  74354. * Dispose and release associated resources.
  74355. */
  74356. dispose(): void;
  74357. }
  74358. }
  74359. declare module BABYLON.GUI {
  74360. /**
  74361. * Class used to load GUI via XML.
  74362. */
  74363. export class XmlLoader {
  74364. private _nodes;
  74365. private _nodeTypes;
  74366. private _isLoaded;
  74367. private _objectAttributes;
  74368. private _parentClass;
  74369. /**
  74370. * Create a new xml loader
  74371. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74372. */
  74373. constructor(parentClass?: null);
  74374. private _getChainElement;
  74375. private _getClassAttribute;
  74376. private _createGuiElement;
  74377. private _parseGrid;
  74378. private _parseElement;
  74379. private _prepareSourceElement;
  74380. private _parseElementsFromSource;
  74381. private _parseXml;
  74382. /**
  74383. * Gets if the loading has finished.
  74384. * @returns whether the loading has finished or not
  74385. */
  74386. isLoaded(): boolean;
  74387. /**
  74388. * Gets a loaded node / control by id.
  74389. * @param id the Controls id set in the xml
  74390. * @returns element of type Control
  74391. */
  74392. getNodeById(id: string): any;
  74393. /**
  74394. * Gets all loaded nodes / controls
  74395. * @returns Array of controls
  74396. */
  74397. getNodes(): any;
  74398. /**
  74399. * Initiates the xml layout loading
  74400. * @param xmlFile defines the xml layout to load
  74401. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74402. * @param callback defines the callback called on layout load.
  74403. */
  74404. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74405. }
  74406. }
  74407. declare module BABYLON.GUI {
  74408. /**
  74409. * Class used to create containers for controls
  74410. */
  74411. export class Container3D extends Control3D {
  74412. private _blockLayout;
  74413. /**
  74414. * Gets the list of child controls
  74415. */
  74416. protected _children: Control3D[];
  74417. /**
  74418. * Gets the list of child controls
  74419. */
  74420. get children(): Array<Control3D>;
  74421. /**
  74422. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74423. * This is helpful to optimize layout operation when adding multiple children in a row
  74424. */
  74425. get blockLayout(): boolean;
  74426. set blockLayout(value: boolean);
  74427. /**
  74428. * Creates a new container
  74429. * @param name defines the container name
  74430. */
  74431. constructor(name?: string);
  74432. /**
  74433. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74434. * @returns the current container
  74435. */
  74436. updateLayout(): Container3D;
  74437. /**
  74438. * Gets a boolean indicating if the given control is in the children of this control
  74439. * @param control defines the control to check
  74440. * @returns true if the control is in the child list
  74441. */
  74442. containsControl(control: Control3D): boolean;
  74443. /**
  74444. * Adds a control to the children of this control
  74445. * @param control defines the control to add
  74446. * @returns the current container
  74447. */
  74448. addControl(control: Control3D): Container3D;
  74449. /**
  74450. * This function will be called everytime a new control is added
  74451. */
  74452. protected _arrangeChildren(): void;
  74453. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74454. /**
  74455. * Removes a control from the children of this control
  74456. * @param control defines the control to remove
  74457. * @returns the current container
  74458. */
  74459. removeControl(control: Control3D): Container3D;
  74460. protected _getTypeName(): string;
  74461. /**
  74462. * Releases all associated resources
  74463. */
  74464. dispose(): void;
  74465. /** Control rotation will remain unchanged */
  74466. static readonly UNSET_ORIENTATION: number;
  74467. /** Control will rotate to make it look at sphere central axis */
  74468. static readonly FACEORIGIN_ORIENTATION: number;
  74469. /** Control will rotate to make it look back at sphere central axis */
  74470. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74471. /** Control will rotate to look at z axis (0, 0, 1) */
  74472. static readonly FACEFORWARD_ORIENTATION: number;
  74473. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74474. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74475. }
  74476. }
  74477. declare module BABYLON.GUI {
  74478. /**
  74479. * Class used to manage 3D user interface
  74480. * @see http://doc.babylonjs.com/how_to/gui3d
  74481. */
  74482. export class GUI3DManager implements BABYLON.IDisposable {
  74483. private _scene;
  74484. private _sceneDisposeObserver;
  74485. private _utilityLayer;
  74486. private _rootContainer;
  74487. private _pointerObserver;
  74488. private _pointerOutObserver;
  74489. /** @hidden */
  74490. _lastPickedControl: Control3D;
  74491. /** @hidden */
  74492. _lastControlOver: {
  74493. [pointerId: number]: Control3D;
  74494. };
  74495. /** @hidden */
  74496. _lastControlDown: {
  74497. [pointerId: number]: Control3D;
  74498. };
  74499. /**
  74500. * BABYLON.Observable raised when the point picked by the pointer events changed
  74501. */
  74502. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74503. /** @hidden */
  74504. _sharedMaterials: {
  74505. [key: string]: BABYLON.Material;
  74506. };
  74507. /** Gets the hosting scene */
  74508. get scene(): BABYLON.Scene;
  74509. /** Gets associated utility layer */
  74510. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74511. /**
  74512. * Creates a new GUI3DManager
  74513. * @param scene
  74514. */
  74515. constructor(scene?: BABYLON.Scene);
  74516. private _handlePointerOut;
  74517. private _doPicking;
  74518. /**
  74519. * Gets the root container
  74520. */
  74521. get rootContainer(): Container3D;
  74522. /**
  74523. * Gets a boolean indicating if the given control is in the root child list
  74524. * @param control defines the control to check
  74525. * @returns true if the control is in the root child list
  74526. */
  74527. containsControl(control: Control3D): boolean;
  74528. /**
  74529. * Adds a control to the root child list
  74530. * @param control defines the control to add
  74531. * @returns the current manager
  74532. */
  74533. addControl(control: Control3D): GUI3DManager;
  74534. /**
  74535. * Removes a control from the root child list
  74536. * @param control defines the control to remove
  74537. * @returns the current container
  74538. */
  74539. removeControl(control: Control3D): GUI3DManager;
  74540. /**
  74541. * Releases all associated resources
  74542. */
  74543. dispose(): void;
  74544. }
  74545. }
  74546. declare module BABYLON.GUI {
  74547. /**
  74548. * Class used to transport BABYLON.Vector3 information for pointer events
  74549. */
  74550. export class Vector3WithInfo extends BABYLON.Vector3 {
  74551. /** defines the current mouse button index */
  74552. buttonIndex: number;
  74553. /**
  74554. * Creates a new Vector3WithInfo
  74555. * @param source defines the vector3 data to transport
  74556. * @param buttonIndex defines the current mouse button index
  74557. */
  74558. constructor(source: BABYLON.Vector3,
  74559. /** defines the current mouse button index */
  74560. buttonIndex?: number);
  74561. }
  74562. }
  74563. declare module BABYLON.GUI {
  74564. /**
  74565. * Class used as base class for controls
  74566. */
  74567. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74568. /** Defines the control name */
  74569. name?: string | undefined;
  74570. /** @hidden */
  74571. _host: GUI3DManager;
  74572. private _node;
  74573. private _downCount;
  74574. private _enterCount;
  74575. private _downPointerIds;
  74576. private _isVisible;
  74577. /** Gets or sets the control position in world space */
  74578. get position(): BABYLON.Vector3;
  74579. set position(value: BABYLON.Vector3);
  74580. /** Gets or sets the control scaling in world space */
  74581. get scaling(): BABYLON.Vector3;
  74582. set scaling(value: BABYLON.Vector3);
  74583. /** Callback used to start pointer enter animation */
  74584. pointerEnterAnimation: () => void;
  74585. /** Callback used to start pointer out animation */
  74586. pointerOutAnimation: () => void;
  74587. /** Callback used to start pointer down animation */
  74588. pointerDownAnimation: () => void;
  74589. /** Callback used to start pointer up animation */
  74590. pointerUpAnimation: () => void;
  74591. /**
  74592. * An event triggered when the pointer move over the control
  74593. */
  74594. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74595. /**
  74596. * An event triggered when the pointer move out of the control
  74597. */
  74598. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74599. /**
  74600. * An event triggered when the pointer taps the control
  74601. */
  74602. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74603. /**
  74604. * An event triggered when pointer is up
  74605. */
  74606. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74607. /**
  74608. * An event triggered when a control is clicked on (with a mouse)
  74609. */
  74610. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74611. /**
  74612. * An event triggered when pointer enters the control
  74613. */
  74614. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74615. /**
  74616. * Gets or sets the parent container
  74617. */
  74618. parent: BABYLON.Nullable<Container3D>;
  74619. private _behaviors;
  74620. /**
  74621. * Gets the list of attached behaviors
  74622. * @see http://doc.babylonjs.com/features/behaviour
  74623. */
  74624. get behaviors(): BABYLON.Behavior<Control3D>[];
  74625. /**
  74626. * Attach a behavior to the control
  74627. * @see http://doc.babylonjs.com/features/behaviour
  74628. * @param behavior defines the behavior to attach
  74629. * @returns the current control
  74630. */
  74631. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74632. /**
  74633. * Remove an attached behavior
  74634. * @see http://doc.babylonjs.com/features/behaviour
  74635. * @param behavior defines the behavior to attach
  74636. * @returns the current control
  74637. */
  74638. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74639. /**
  74640. * Gets an attached behavior by name
  74641. * @param name defines the name of the behavior to look for
  74642. * @see http://doc.babylonjs.com/features/behaviour
  74643. * @returns null if behavior was not found else the requested behavior
  74644. */
  74645. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74646. /** Gets or sets a boolean indicating if the control is visible */
  74647. get isVisible(): boolean;
  74648. set isVisible(value: boolean);
  74649. /**
  74650. * Creates a new control
  74651. * @param name defines the control name
  74652. */
  74653. constructor(
  74654. /** Defines the control name */
  74655. name?: string | undefined);
  74656. /**
  74657. * Gets a string representing the class name
  74658. */
  74659. get typeName(): string;
  74660. /**
  74661. * Get the current class name of the control.
  74662. * @returns current class name
  74663. */
  74664. getClassName(): string;
  74665. protected _getTypeName(): string;
  74666. /**
  74667. * Gets the transform node used by this control
  74668. */
  74669. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74670. /**
  74671. * Gets the mesh used to render this control
  74672. */
  74673. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74674. /**
  74675. * Link the control as child of the given node
  74676. * @param node defines the node to link to. Use null to unlink the control
  74677. * @returns the current control
  74678. */
  74679. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74680. /** @hidden **/
  74681. _prepareNode(scene: BABYLON.Scene): void;
  74682. /**
  74683. * Node creation.
  74684. * Can be overriden by children
  74685. * @param scene defines the scene where the node must be attached
  74686. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74687. */
  74688. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74689. /**
  74690. * Affect a material to the given mesh
  74691. * @param mesh defines the mesh which will represent the control
  74692. */
  74693. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74694. /** @hidden */
  74695. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74696. /** @hidden */
  74697. _onPointerEnter(target: Control3D): boolean;
  74698. /** @hidden */
  74699. _onPointerOut(target: Control3D): void;
  74700. /** @hidden */
  74701. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74702. /** @hidden */
  74703. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74704. /** @hidden */
  74705. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74706. /** @hidden */
  74707. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74708. /** @hidden */
  74709. _disposeNode(): void;
  74710. /**
  74711. * Releases all associated resources
  74712. */
  74713. dispose(): void;
  74714. }
  74715. }
  74716. declare module BABYLON.GUI {
  74717. /**
  74718. * Class used as a root to all buttons
  74719. */
  74720. export class AbstractButton3D extends Control3D {
  74721. /**
  74722. * Creates a new button
  74723. * @param name defines the control name
  74724. */
  74725. constructor(name?: string);
  74726. protected _getTypeName(): string;
  74727. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74728. }
  74729. }
  74730. declare module BABYLON.GUI {
  74731. /**
  74732. * Class used to create a button in 3D
  74733. */
  74734. export class Button3D extends AbstractButton3D {
  74735. /** @hidden */
  74736. protected _currentMaterial: BABYLON.Material;
  74737. private _facadeTexture;
  74738. private _content;
  74739. private _contentResolution;
  74740. private _contentScaleRatio;
  74741. /**
  74742. * Gets or sets the texture resolution used to render content (512 by default)
  74743. */
  74744. get contentResolution(): BABYLON.int;
  74745. set contentResolution(value: BABYLON.int);
  74746. /**
  74747. * Gets or sets the texture scale ratio used to render content (2 by default)
  74748. */
  74749. get contentScaleRatio(): number;
  74750. set contentScaleRatio(value: number);
  74751. protected _disposeFacadeTexture(): void;
  74752. protected _resetContent(): void;
  74753. /**
  74754. * Creates a new button
  74755. * @param name defines the control name
  74756. */
  74757. constructor(name?: string);
  74758. /**
  74759. * Gets or sets the GUI 2D content used to display the button's facade
  74760. */
  74761. get content(): Control;
  74762. set content(value: Control);
  74763. /**
  74764. * Apply the facade texture (created from the content property).
  74765. * This function can be overloaded by child classes
  74766. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74767. */
  74768. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74769. protected _getTypeName(): string;
  74770. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74771. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74772. /**
  74773. * Releases all associated resources
  74774. */
  74775. dispose(): void;
  74776. }
  74777. }
  74778. declare module BABYLON.GUI {
  74779. /**
  74780. * Abstract class used to create a container panel deployed on the surface of a volume
  74781. */
  74782. export abstract class VolumeBasedPanel extends Container3D {
  74783. private _columns;
  74784. private _rows;
  74785. private _rowThenColum;
  74786. private _orientation;
  74787. protected _cellWidth: number;
  74788. protected _cellHeight: number;
  74789. /**
  74790. * Gets or sets the distance between elements
  74791. */
  74792. margin: number;
  74793. /**
  74794. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74795. * | Value | Type | Description |
  74796. * | ----- | ----------------------------------- | ----------- |
  74797. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74798. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74799. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74800. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74801. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74802. */
  74803. get orientation(): number;
  74804. set orientation(value: number);
  74805. /**
  74806. * Gets or sets the number of columns requested (10 by default).
  74807. * The panel will automatically compute the number of rows based on number of child controls.
  74808. */
  74809. get columns(): BABYLON.int;
  74810. set columns(value: BABYLON.int);
  74811. /**
  74812. * Gets or sets a the number of rows requested.
  74813. * The panel will automatically compute the number of columns based on number of child controls.
  74814. */
  74815. get rows(): BABYLON.int;
  74816. set rows(value: BABYLON.int);
  74817. /**
  74818. * Creates new VolumeBasedPanel
  74819. */
  74820. constructor();
  74821. protected _arrangeChildren(): void;
  74822. /** Child classes must implement this function to provide correct control positioning */
  74823. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74824. /** Child classes can implement this function to provide additional processing */
  74825. protected _finalProcessing(): void;
  74826. }
  74827. }
  74828. declare module BABYLON.GUI {
  74829. /**
  74830. * Class used to create a container panel deployed on the surface of a cylinder
  74831. */
  74832. export class CylinderPanel extends VolumeBasedPanel {
  74833. private _radius;
  74834. /**
  74835. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74836. */
  74837. get radius(): BABYLON.float;
  74838. set radius(value: BABYLON.float);
  74839. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74840. private _cylindricalMapping;
  74841. }
  74842. }
  74843. declare module BABYLON.GUI {
  74844. /** @hidden */
  74845. export var fluentVertexShader: {
  74846. name: string;
  74847. shader: string;
  74848. };
  74849. }
  74850. declare module BABYLON.GUI {
  74851. /** @hidden */
  74852. export var fluentPixelShader: {
  74853. name: string;
  74854. shader: string;
  74855. };
  74856. }
  74857. declare module BABYLON.GUI {
  74858. /** @hidden */
  74859. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74860. INNERGLOW: boolean;
  74861. BORDER: boolean;
  74862. HOVERLIGHT: boolean;
  74863. TEXTURE: boolean;
  74864. constructor();
  74865. }
  74866. /**
  74867. * Class used to render controls with fluent desgin
  74868. */
  74869. export class FluentMaterial extends BABYLON.PushMaterial {
  74870. /**
  74871. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74872. */
  74873. innerGlowColorIntensity: number;
  74874. /**
  74875. * Gets or sets the inner glow color (white by default)
  74876. */
  74877. innerGlowColor: BABYLON.Color3;
  74878. /**
  74879. * Gets or sets alpha value (default is 1.0)
  74880. */
  74881. alpha: number;
  74882. /**
  74883. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74884. */
  74885. albedoColor: BABYLON.Color3;
  74886. /**
  74887. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74888. */
  74889. renderBorders: boolean;
  74890. /**
  74891. * Gets or sets border width (default is 0.5)
  74892. */
  74893. borderWidth: number;
  74894. /**
  74895. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74896. */
  74897. edgeSmoothingValue: number;
  74898. /**
  74899. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74900. */
  74901. borderMinValue: number;
  74902. /**
  74903. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74904. */
  74905. renderHoverLight: boolean;
  74906. /**
  74907. * Gets or sets the radius used to render the hover light (default is 1.0)
  74908. */
  74909. hoverRadius: number;
  74910. /**
  74911. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74912. */
  74913. hoverColor: BABYLON.Color4;
  74914. /**
  74915. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74916. */
  74917. hoverPosition: BABYLON.Vector3;
  74918. private _albedoTexture;
  74919. /** Gets or sets the texture to use for albedo color */
  74920. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74921. /**
  74922. * Creates a new Fluent material
  74923. * @param name defines the name of the material
  74924. * @param scene defines the hosting scene
  74925. */
  74926. constructor(name: string, scene: BABYLON.Scene);
  74927. needAlphaBlending(): boolean;
  74928. needAlphaTesting(): boolean;
  74929. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74930. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74931. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74932. getActiveTextures(): BABYLON.BaseTexture[];
  74933. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74934. dispose(forceDisposeEffect?: boolean): void;
  74935. clone(name: string): FluentMaterial;
  74936. serialize(): any;
  74937. getClassName(): string;
  74938. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74939. }
  74940. }
  74941. declare module BABYLON.GUI {
  74942. /**
  74943. * Class used to create a holographic button in 3D
  74944. */
  74945. export class HolographicButton extends Button3D {
  74946. private _backPlate;
  74947. private _textPlate;
  74948. private _frontPlate;
  74949. private _text;
  74950. private _imageUrl;
  74951. private _shareMaterials;
  74952. private _frontMaterial;
  74953. private _backMaterial;
  74954. private _plateMaterial;
  74955. private _pickedPointObserver;
  74956. private _tooltipFade;
  74957. private _tooltipTextBlock;
  74958. private _tooltipTexture;
  74959. private _tooltipMesh;
  74960. private _tooltipHoverObserver;
  74961. private _tooltipOutObserver;
  74962. private _disposeTooltip;
  74963. /**
  74964. * Rendering ground id of all the mesh in the button
  74965. */
  74966. set renderingGroupId(id: number);
  74967. get renderingGroupId(): number;
  74968. /**
  74969. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74970. */
  74971. set tooltipText(text: BABYLON.Nullable<string>);
  74972. get tooltipText(): BABYLON.Nullable<string>;
  74973. /**
  74974. * Gets or sets text for the button
  74975. */
  74976. get text(): string;
  74977. set text(value: string);
  74978. /**
  74979. * Gets or sets the image url for the button
  74980. */
  74981. get imageUrl(): string;
  74982. set imageUrl(value: string);
  74983. /**
  74984. * Gets the back material used by this button
  74985. */
  74986. get backMaterial(): FluentMaterial;
  74987. /**
  74988. * Gets the front material used by this button
  74989. */
  74990. get frontMaterial(): FluentMaterial;
  74991. /**
  74992. * Gets the plate material used by this button
  74993. */
  74994. get plateMaterial(): BABYLON.StandardMaterial;
  74995. /**
  74996. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74997. */
  74998. get shareMaterials(): boolean;
  74999. /**
  75000. * Creates a new button
  75001. * @param name defines the control name
  75002. */
  75003. constructor(name?: string, shareMaterials?: boolean);
  75004. protected _getTypeName(): string;
  75005. private _rebuildContent;
  75006. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75007. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75008. private _createBackMaterial;
  75009. private _createFrontMaterial;
  75010. private _createPlateMaterial;
  75011. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75012. /**
  75013. * Releases all associated resources
  75014. */
  75015. dispose(): void;
  75016. }
  75017. }
  75018. declare module BABYLON.GUI {
  75019. /**
  75020. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75021. */
  75022. export class MeshButton3D extends Button3D {
  75023. /** @hidden */
  75024. protected _currentMesh: BABYLON.Mesh;
  75025. /**
  75026. * Creates a new 3D button based on a mesh
  75027. * @param mesh mesh to become a 3D button
  75028. * @param name defines the control name
  75029. */
  75030. constructor(mesh: BABYLON.Mesh, name?: string);
  75031. protected _getTypeName(): string;
  75032. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75033. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75034. }
  75035. }
  75036. declare module BABYLON.GUI {
  75037. /**
  75038. * Class used to create a container panel deployed on the surface of a plane
  75039. */
  75040. export class PlanePanel extends VolumeBasedPanel {
  75041. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75042. }
  75043. }
  75044. declare module BABYLON.GUI {
  75045. /**
  75046. * Class used to create a container panel where items get randomized planar mapping
  75047. */
  75048. export class ScatterPanel extends VolumeBasedPanel {
  75049. private _iteration;
  75050. /**
  75051. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75052. */
  75053. get iteration(): BABYLON.float;
  75054. set iteration(value: BABYLON.float);
  75055. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75056. private _scatterMapping;
  75057. protected _finalProcessing(): void;
  75058. }
  75059. }
  75060. declare module BABYLON.GUI {
  75061. /**
  75062. * Class used to create a container panel deployed on the surface of a sphere
  75063. */
  75064. export class SpherePanel extends VolumeBasedPanel {
  75065. private _radius;
  75066. /**
  75067. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75068. */
  75069. get radius(): BABYLON.float;
  75070. set radius(value: BABYLON.float);
  75071. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75072. private _sphericalMapping;
  75073. }
  75074. }
  75075. declare module BABYLON.GUI {
  75076. /**
  75077. * Class used to create a stack panel in 3D on XY plane
  75078. */
  75079. export class StackPanel3D extends Container3D {
  75080. private _isVertical;
  75081. /**
  75082. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75083. */
  75084. get isVertical(): boolean;
  75085. set isVertical(value: boolean);
  75086. /**
  75087. * Gets or sets the distance between elements
  75088. */
  75089. margin: number;
  75090. /**
  75091. * Creates new StackPanel
  75092. * @param isVertical
  75093. */
  75094. constructor(isVertical?: boolean);
  75095. protected _arrangeChildren(): void;
  75096. }
  75097. }
  75098. declare module BABYLON {
  75099. /**
  75100. * Configuration for glTF validation
  75101. */
  75102. export interface IGLTFValidationConfiguration {
  75103. /**
  75104. * The url of the glTF validator.
  75105. */
  75106. url: string;
  75107. }
  75108. /**
  75109. * glTF validation
  75110. */
  75111. export class GLTFValidation {
  75112. /**
  75113. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75114. */
  75115. static Configuration: IGLTFValidationConfiguration;
  75116. private static _LoadScriptPromise;
  75117. /**
  75118. * Validate a glTF asset using the glTF-Validator.
  75119. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75120. * @param rootUrl The root url for the glTF
  75121. * @param fileName The file name for the glTF
  75122. * @param getExternalResource The callback to get external resources for the glTF validator
  75123. * @returns A promise that resolves with the glTF validation results once complete
  75124. */
  75125. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75126. }
  75127. }
  75128. declare module BABYLON {
  75129. /**
  75130. * Mode that determines the coordinate system to use.
  75131. */
  75132. export enum GLTFLoaderCoordinateSystemMode {
  75133. /**
  75134. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75135. */
  75136. AUTO = 0,
  75137. /**
  75138. * Sets the useRightHandedSystem flag on the scene.
  75139. */
  75140. FORCE_RIGHT_HANDED = 1
  75141. }
  75142. /**
  75143. * Mode that determines what animations will start.
  75144. */
  75145. export enum GLTFLoaderAnimationStartMode {
  75146. /**
  75147. * No animation will start.
  75148. */
  75149. NONE = 0,
  75150. /**
  75151. * The first animation will start.
  75152. */
  75153. FIRST = 1,
  75154. /**
  75155. * All animations will start.
  75156. */
  75157. ALL = 2
  75158. }
  75159. /**
  75160. * Interface that contains the data for the glTF asset.
  75161. */
  75162. export interface IGLTFLoaderData {
  75163. /**
  75164. * The object that represents the glTF JSON.
  75165. */
  75166. json: Object;
  75167. /**
  75168. * The BIN chunk of a binary glTF.
  75169. */
  75170. bin: Nullable<IDataBuffer>;
  75171. }
  75172. /**
  75173. * Interface for extending the loader.
  75174. */
  75175. export interface IGLTFLoaderExtension {
  75176. /**
  75177. * The name of this extension.
  75178. */
  75179. readonly name: string;
  75180. /**
  75181. * Defines whether this extension is enabled.
  75182. */
  75183. enabled: boolean;
  75184. /**
  75185. * Defines the order of this extension.
  75186. * The loader sorts the extensions using these values when loading.
  75187. */
  75188. order?: number;
  75189. }
  75190. /**
  75191. * Loader state.
  75192. */
  75193. export enum GLTFLoaderState {
  75194. /**
  75195. * The asset is loading.
  75196. */
  75197. LOADING = 0,
  75198. /**
  75199. * The asset is ready for rendering.
  75200. */
  75201. READY = 1,
  75202. /**
  75203. * The asset is completely loaded.
  75204. */
  75205. COMPLETE = 2
  75206. }
  75207. /** @hidden */
  75208. export interface IImportMeshAsyncOutput {
  75209. meshes: AbstractMesh[];
  75210. particleSystems: IParticleSystem[];
  75211. skeletons: Skeleton[];
  75212. animationGroups: AnimationGroup[];
  75213. lights: Light[];
  75214. transformNodes: TransformNode[];
  75215. }
  75216. /** @hidden */
  75217. export interface IGLTFLoader extends IDisposable {
  75218. readonly state: Nullable<GLTFLoaderState>;
  75219. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75220. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75221. }
  75222. /**
  75223. * File loader for loading glTF files into a scene.
  75224. */
  75225. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75226. /** @hidden */
  75227. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75228. /** @hidden */
  75229. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75230. /**
  75231. * Raised when the asset has been parsed
  75232. */
  75233. onParsedObservable: Observable<IGLTFLoaderData>;
  75234. private _onParsedObserver;
  75235. /**
  75236. * Raised when the asset has been parsed
  75237. */
  75238. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75239. /**
  75240. * 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.
  75241. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75242. * Defaults to true.
  75243. * @hidden
  75244. */
  75245. static IncrementalLoading: boolean;
  75246. /**
  75247. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75248. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75249. * @hidden
  75250. */
  75251. static HomogeneousCoordinates: boolean;
  75252. /**
  75253. * The coordinate system mode. Defaults to AUTO.
  75254. */
  75255. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75256. /**
  75257. * The animation start mode. Defaults to FIRST.
  75258. */
  75259. animationStartMode: GLTFLoaderAnimationStartMode;
  75260. /**
  75261. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75262. */
  75263. compileMaterials: boolean;
  75264. /**
  75265. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75266. */
  75267. useClipPlane: boolean;
  75268. /**
  75269. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75270. */
  75271. compileShadowGenerators: boolean;
  75272. /**
  75273. * Defines if the Alpha blended materials are only applied as coverage.
  75274. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75275. * If true, no extra effects are applied to transparent pixels.
  75276. */
  75277. transparencyAsCoverage: boolean;
  75278. /**
  75279. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75280. * Enabling will disable offline support and glTF validator.
  75281. * Defaults to false.
  75282. */
  75283. useRangeRequests: boolean;
  75284. /**
  75285. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75286. */
  75287. createInstances: boolean;
  75288. /**
  75289. * Function called before loading a url referenced by the asset.
  75290. */
  75291. preprocessUrlAsync: (url: string) => Promise<string>;
  75292. /**
  75293. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75294. */
  75295. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75296. private _onMeshLoadedObserver;
  75297. /**
  75298. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75299. */
  75300. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75301. /**
  75302. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75303. */
  75304. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75305. private _onTextureLoadedObserver;
  75306. /**
  75307. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75308. */
  75309. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75310. /**
  75311. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75312. */
  75313. readonly onMaterialLoadedObservable: Observable<Material>;
  75314. private _onMaterialLoadedObserver;
  75315. /**
  75316. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75317. */
  75318. set onMaterialLoaded(callback: (material: Material) => void);
  75319. /**
  75320. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75321. */
  75322. readonly onCameraLoadedObservable: Observable<Camera>;
  75323. private _onCameraLoadedObserver;
  75324. /**
  75325. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75326. */
  75327. set onCameraLoaded(callback: (camera: Camera) => void);
  75328. /**
  75329. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75330. * For assets with LODs, raised when all of the LODs are complete.
  75331. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75332. */
  75333. readonly onCompleteObservable: Observable<void>;
  75334. private _onCompleteObserver;
  75335. /**
  75336. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75337. * For assets with LODs, raised when all of the LODs are complete.
  75338. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75339. */
  75340. set onComplete(callback: () => void);
  75341. /**
  75342. * Observable raised when an error occurs.
  75343. */
  75344. readonly onErrorObservable: Observable<any>;
  75345. private _onErrorObserver;
  75346. /**
  75347. * Callback raised when an error occurs.
  75348. */
  75349. set onError(callback: (reason: any) => void);
  75350. /**
  75351. * Observable raised after the loader is disposed.
  75352. */
  75353. readonly onDisposeObservable: Observable<void>;
  75354. private _onDisposeObserver;
  75355. /**
  75356. * Callback raised after the loader is disposed.
  75357. */
  75358. set onDispose(callback: () => void);
  75359. /**
  75360. * Observable raised after a loader extension is created.
  75361. * Set additional options for a loader extension in this event.
  75362. */
  75363. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75364. private _onExtensionLoadedObserver;
  75365. /**
  75366. * Callback raised after a loader extension is created.
  75367. */
  75368. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75369. /**
  75370. * Defines if the loader logging is enabled.
  75371. */
  75372. get loggingEnabled(): boolean;
  75373. set loggingEnabled(value: boolean);
  75374. /**
  75375. * Defines if the loader should capture performance counters.
  75376. */
  75377. get capturePerformanceCounters(): boolean;
  75378. set capturePerformanceCounters(value: boolean);
  75379. /**
  75380. * Defines if the loader should validate the asset.
  75381. */
  75382. validate: boolean;
  75383. /**
  75384. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75385. */
  75386. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75387. private _onValidatedObserver;
  75388. /**
  75389. * Callback raised after a loader extension is created.
  75390. */
  75391. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75392. private _loader;
  75393. /**
  75394. * Name of the loader ("gltf")
  75395. */
  75396. name: string;
  75397. /** @hidden */
  75398. extensions: ISceneLoaderPluginExtensions;
  75399. /**
  75400. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75401. */
  75402. dispose(): void;
  75403. /** @hidden */
  75404. _clear(): void;
  75405. /** @hidden */
  75406. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75407. /** @hidden */
  75408. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75409. /** @hidden */
  75410. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75411. meshes: AbstractMesh[];
  75412. particleSystems: IParticleSystem[];
  75413. skeletons: Skeleton[];
  75414. animationGroups: AnimationGroup[];
  75415. }>;
  75416. /** @hidden */
  75417. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75418. /** @hidden */
  75419. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75420. /** @hidden */
  75421. canDirectLoad(data: string): boolean;
  75422. /** @hidden */
  75423. directLoad(scene: Scene, data: string): any;
  75424. /**
  75425. * The callback that allows custom handling of the root url based on the response url.
  75426. * @param rootUrl the original root url
  75427. * @param responseURL the response url if available
  75428. * @returns the new root url
  75429. */
  75430. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75431. /** @hidden */
  75432. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75433. /**
  75434. * The loader state or null if the loader is not active.
  75435. */
  75436. get loaderState(): Nullable<GLTFLoaderState>;
  75437. /**
  75438. * Returns a promise that resolves when the asset is completely loaded.
  75439. * @returns a promise that resolves when the asset is completely loaded.
  75440. */
  75441. whenCompleteAsync(): Promise<void>;
  75442. private _validate;
  75443. private _getLoader;
  75444. private _parseJson;
  75445. private _unpackBinaryAsync;
  75446. private _unpackBinaryV1Async;
  75447. private _unpackBinaryV2Async;
  75448. private static _parseVersion;
  75449. private static _compareVersion;
  75450. private static readonly _logSpaces;
  75451. private _logIndentLevel;
  75452. private _loggingEnabled;
  75453. /** @hidden */
  75454. _log: (message: string) => void;
  75455. /** @hidden */
  75456. _logOpen(message: string): void;
  75457. /** @hidden */
  75458. _logClose(): void;
  75459. private _logEnabled;
  75460. private _logDisabled;
  75461. private _capturePerformanceCounters;
  75462. /** @hidden */
  75463. _startPerformanceCounter: (counterName: string) => void;
  75464. /** @hidden */
  75465. _endPerformanceCounter: (counterName: string) => void;
  75466. private _startPerformanceCounterEnabled;
  75467. private _startPerformanceCounterDisabled;
  75468. private _endPerformanceCounterEnabled;
  75469. private _endPerformanceCounterDisabled;
  75470. }
  75471. }
  75472. declare module BABYLON.GLTF1 {
  75473. /**
  75474. * Enums
  75475. * @hidden
  75476. */
  75477. export enum EComponentType {
  75478. BYTE = 5120,
  75479. UNSIGNED_BYTE = 5121,
  75480. SHORT = 5122,
  75481. UNSIGNED_SHORT = 5123,
  75482. FLOAT = 5126
  75483. }
  75484. /** @hidden */
  75485. export enum EShaderType {
  75486. FRAGMENT = 35632,
  75487. VERTEX = 35633
  75488. }
  75489. /** @hidden */
  75490. export enum EParameterType {
  75491. BYTE = 5120,
  75492. UNSIGNED_BYTE = 5121,
  75493. SHORT = 5122,
  75494. UNSIGNED_SHORT = 5123,
  75495. INT = 5124,
  75496. UNSIGNED_INT = 5125,
  75497. FLOAT = 5126,
  75498. FLOAT_VEC2 = 35664,
  75499. FLOAT_VEC3 = 35665,
  75500. FLOAT_VEC4 = 35666,
  75501. INT_VEC2 = 35667,
  75502. INT_VEC3 = 35668,
  75503. INT_VEC4 = 35669,
  75504. BOOL = 35670,
  75505. BOOL_VEC2 = 35671,
  75506. BOOL_VEC3 = 35672,
  75507. BOOL_VEC4 = 35673,
  75508. FLOAT_MAT2 = 35674,
  75509. FLOAT_MAT3 = 35675,
  75510. FLOAT_MAT4 = 35676,
  75511. SAMPLER_2D = 35678
  75512. }
  75513. /** @hidden */
  75514. export enum ETextureWrapMode {
  75515. CLAMP_TO_EDGE = 33071,
  75516. MIRRORED_REPEAT = 33648,
  75517. REPEAT = 10497
  75518. }
  75519. /** @hidden */
  75520. export enum ETextureFilterType {
  75521. NEAREST = 9728,
  75522. LINEAR = 9728,
  75523. NEAREST_MIPMAP_NEAREST = 9984,
  75524. LINEAR_MIPMAP_NEAREST = 9985,
  75525. NEAREST_MIPMAP_LINEAR = 9986,
  75526. LINEAR_MIPMAP_LINEAR = 9987
  75527. }
  75528. /** @hidden */
  75529. export enum ETextureFormat {
  75530. ALPHA = 6406,
  75531. RGB = 6407,
  75532. RGBA = 6408,
  75533. LUMINANCE = 6409,
  75534. LUMINANCE_ALPHA = 6410
  75535. }
  75536. /** @hidden */
  75537. export enum ECullingType {
  75538. FRONT = 1028,
  75539. BACK = 1029,
  75540. FRONT_AND_BACK = 1032
  75541. }
  75542. /** @hidden */
  75543. export enum EBlendingFunction {
  75544. ZERO = 0,
  75545. ONE = 1,
  75546. SRC_COLOR = 768,
  75547. ONE_MINUS_SRC_COLOR = 769,
  75548. DST_COLOR = 774,
  75549. ONE_MINUS_DST_COLOR = 775,
  75550. SRC_ALPHA = 770,
  75551. ONE_MINUS_SRC_ALPHA = 771,
  75552. DST_ALPHA = 772,
  75553. ONE_MINUS_DST_ALPHA = 773,
  75554. CONSTANT_COLOR = 32769,
  75555. ONE_MINUS_CONSTANT_COLOR = 32770,
  75556. CONSTANT_ALPHA = 32771,
  75557. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75558. SRC_ALPHA_SATURATE = 776
  75559. }
  75560. /** @hidden */
  75561. export interface IGLTFProperty {
  75562. extensions?: {
  75563. [key: string]: any;
  75564. };
  75565. extras?: Object;
  75566. }
  75567. /** @hidden */
  75568. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75569. name?: string;
  75570. }
  75571. /** @hidden */
  75572. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75573. bufferView: string;
  75574. byteOffset: number;
  75575. byteStride: number;
  75576. count: number;
  75577. type: string;
  75578. componentType: EComponentType;
  75579. max?: number[];
  75580. min?: number[];
  75581. name?: string;
  75582. }
  75583. /** @hidden */
  75584. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75585. buffer: string;
  75586. byteOffset: number;
  75587. byteLength: number;
  75588. byteStride: number;
  75589. target?: number;
  75590. }
  75591. /** @hidden */
  75592. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75593. uri: string;
  75594. byteLength?: number;
  75595. type?: string;
  75596. }
  75597. /** @hidden */
  75598. export interface IGLTFShader extends IGLTFChildRootProperty {
  75599. uri: string;
  75600. type: EShaderType;
  75601. }
  75602. /** @hidden */
  75603. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75604. attributes: string[];
  75605. fragmentShader: string;
  75606. vertexShader: string;
  75607. }
  75608. /** @hidden */
  75609. export interface IGLTFTechniqueParameter {
  75610. type: number;
  75611. count?: number;
  75612. semantic?: string;
  75613. node?: string;
  75614. value?: number | boolean | string | Array<any>;
  75615. source?: string;
  75616. babylonValue?: any;
  75617. }
  75618. /** @hidden */
  75619. export interface IGLTFTechniqueCommonProfile {
  75620. lightingModel: string;
  75621. texcoordBindings: Object;
  75622. parameters?: Array<any>;
  75623. }
  75624. /** @hidden */
  75625. export interface IGLTFTechniqueStatesFunctions {
  75626. blendColor?: number[];
  75627. blendEquationSeparate?: number[];
  75628. blendFuncSeparate?: number[];
  75629. colorMask: boolean[];
  75630. cullFace: number[];
  75631. }
  75632. /** @hidden */
  75633. export interface IGLTFTechniqueStates {
  75634. enable: number[];
  75635. functions: IGLTFTechniqueStatesFunctions;
  75636. }
  75637. /** @hidden */
  75638. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75639. parameters: {
  75640. [key: string]: IGLTFTechniqueParameter;
  75641. };
  75642. program: string;
  75643. attributes: {
  75644. [key: string]: string;
  75645. };
  75646. uniforms: {
  75647. [key: string]: string;
  75648. };
  75649. states: IGLTFTechniqueStates;
  75650. }
  75651. /** @hidden */
  75652. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75653. technique?: string;
  75654. values: string[];
  75655. }
  75656. /** @hidden */
  75657. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75658. attributes: {
  75659. [key: string]: string;
  75660. };
  75661. indices: string;
  75662. material: string;
  75663. mode?: number;
  75664. }
  75665. /** @hidden */
  75666. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75667. primitives: IGLTFMeshPrimitive[];
  75668. }
  75669. /** @hidden */
  75670. export interface IGLTFImage extends IGLTFChildRootProperty {
  75671. uri: string;
  75672. }
  75673. /** @hidden */
  75674. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75675. magFilter?: number;
  75676. minFilter?: number;
  75677. wrapS?: number;
  75678. wrapT?: number;
  75679. }
  75680. /** @hidden */
  75681. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75682. sampler: string;
  75683. source: string;
  75684. format?: ETextureFormat;
  75685. internalFormat?: ETextureFormat;
  75686. target?: number;
  75687. type?: number;
  75688. babylonTexture?: Texture;
  75689. }
  75690. /** @hidden */
  75691. export interface IGLTFAmbienLight {
  75692. color?: number[];
  75693. }
  75694. /** @hidden */
  75695. export interface IGLTFDirectionalLight {
  75696. color?: number[];
  75697. }
  75698. /** @hidden */
  75699. export interface IGLTFPointLight {
  75700. color?: number[];
  75701. constantAttenuation?: number;
  75702. linearAttenuation?: number;
  75703. quadraticAttenuation?: number;
  75704. }
  75705. /** @hidden */
  75706. export interface IGLTFSpotLight {
  75707. color?: number[];
  75708. constantAttenuation?: number;
  75709. fallOfAngle?: number;
  75710. fallOffExponent?: number;
  75711. linearAttenuation?: number;
  75712. quadraticAttenuation?: number;
  75713. }
  75714. /** @hidden */
  75715. export interface IGLTFLight extends IGLTFChildRootProperty {
  75716. type: string;
  75717. }
  75718. /** @hidden */
  75719. export interface IGLTFCameraOrthographic {
  75720. xmag: number;
  75721. ymag: number;
  75722. zfar: number;
  75723. znear: number;
  75724. }
  75725. /** @hidden */
  75726. export interface IGLTFCameraPerspective {
  75727. aspectRatio: number;
  75728. yfov: number;
  75729. zfar: number;
  75730. znear: number;
  75731. }
  75732. /** @hidden */
  75733. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75734. type: string;
  75735. }
  75736. /** @hidden */
  75737. export interface IGLTFAnimationChannelTarget {
  75738. id: string;
  75739. path: string;
  75740. }
  75741. /** @hidden */
  75742. export interface IGLTFAnimationChannel {
  75743. sampler: string;
  75744. target: IGLTFAnimationChannelTarget;
  75745. }
  75746. /** @hidden */
  75747. export interface IGLTFAnimationSampler {
  75748. input: string;
  75749. output: string;
  75750. interpolation?: string;
  75751. }
  75752. /** @hidden */
  75753. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75754. channels?: IGLTFAnimationChannel[];
  75755. parameters?: {
  75756. [key: string]: string;
  75757. };
  75758. samplers?: {
  75759. [key: string]: IGLTFAnimationSampler;
  75760. };
  75761. }
  75762. /** @hidden */
  75763. export interface IGLTFNodeInstanceSkin {
  75764. skeletons: string[];
  75765. skin: string;
  75766. meshes: string[];
  75767. }
  75768. /** @hidden */
  75769. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75770. bindShapeMatrix: number[];
  75771. inverseBindMatrices: string;
  75772. jointNames: string[];
  75773. babylonSkeleton?: Skeleton;
  75774. }
  75775. /** @hidden */
  75776. export interface IGLTFNode extends IGLTFChildRootProperty {
  75777. camera?: string;
  75778. children: string[];
  75779. skin?: string;
  75780. jointName?: string;
  75781. light?: string;
  75782. matrix: number[];
  75783. mesh?: string;
  75784. meshes?: string[];
  75785. rotation?: number[];
  75786. scale?: number[];
  75787. translation?: number[];
  75788. babylonNode?: Node;
  75789. }
  75790. /** @hidden */
  75791. export interface IGLTFScene extends IGLTFChildRootProperty {
  75792. nodes: string[];
  75793. }
  75794. /** @hidden */
  75795. export interface IGLTFRuntime {
  75796. extensions: {
  75797. [key: string]: any;
  75798. };
  75799. accessors: {
  75800. [key: string]: IGLTFAccessor;
  75801. };
  75802. buffers: {
  75803. [key: string]: IGLTFBuffer;
  75804. };
  75805. bufferViews: {
  75806. [key: string]: IGLTFBufferView;
  75807. };
  75808. meshes: {
  75809. [key: string]: IGLTFMesh;
  75810. };
  75811. lights: {
  75812. [key: string]: IGLTFLight;
  75813. };
  75814. cameras: {
  75815. [key: string]: IGLTFCamera;
  75816. };
  75817. nodes: {
  75818. [key: string]: IGLTFNode;
  75819. };
  75820. images: {
  75821. [key: string]: IGLTFImage;
  75822. };
  75823. textures: {
  75824. [key: string]: IGLTFTexture;
  75825. };
  75826. shaders: {
  75827. [key: string]: IGLTFShader;
  75828. };
  75829. programs: {
  75830. [key: string]: IGLTFProgram;
  75831. };
  75832. samplers: {
  75833. [key: string]: IGLTFSampler;
  75834. };
  75835. techniques: {
  75836. [key: string]: IGLTFTechnique;
  75837. };
  75838. materials: {
  75839. [key: string]: IGLTFMaterial;
  75840. };
  75841. animations: {
  75842. [key: string]: IGLTFAnimation;
  75843. };
  75844. skins: {
  75845. [key: string]: IGLTFSkins;
  75846. };
  75847. currentScene?: Object;
  75848. scenes: {
  75849. [key: string]: IGLTFScene;
  75850. };
  75851. extensionsUsed: string[];
  75852. extensionsRequired?: string[];
  75853. buffersCount: number;
  75854. shaderscount: number;
  75855. scene: Scene;
  75856. rootUrl: string;
  75857. loadedBufferCount: number;
  75858. loadedBufferViews: {
  75859. [name: string]: ArrayBufferView;
  75860. };
  75861. loadedShaderCount: number;
  75862. importOnlyMeshes: boolean;
  75863. importMeshesNames?: string[];
  75864. dummyNodes: Node[];
  75865. forAssetContainer: boolean;
  75866. }
  75867. /** @hidden */
  75868. export interface INodeToRoot {
  75869. bone: Bone;
  75870. node: IGLTFNode;
  75871. id: string;
  75872. }
  75873. /** @hidden */
  75874. export interface IJointNode {
  75875. node: IGLTFNode;
  75876. id: string;
  75877. }
  75878. }
  75879. declare module BABYLON.GLTF1 {
  75880. /**
  75881. * Utils functions for GLTF
  75882. * @hidden
  75883. */
  75884. export class GLTFUtils {
  75885. /**
  75886. * Sets the given "parameter" matrix
  75887. * @param scene: the Scene object
  75888. * @param source: the source node where to pick the matrix
  75889. * @param parameter: the GLTF technique parameter
  75890. * @param uniformName: the name of the shader's uniform
  75891. * @param shaderMaterial: the shader material
  75892. */
  75893. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75894. /**
  75895. * Sets the given "parameter" matrix
  75896. * @param shaderMaterial: the shader material
  75897. * @param uniform: the name of the shader's uniform
  75898. * @param value: the value of the uniform
  75899. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75900. */
  75901. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75902. /**
  75903. * Returns the wrap mode of the texture
  75904. * @param mode: the mode value
  75905. */
  75906. static GetWrapMode(mode: number): number;
  75907. /**
  75908. * Returns the byte stride giving an accessor
  75909. * @param accessor: the GLTF accessor objet
  75910. */
  75911. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75912. /**
  75913. * Returns the texture filter mode giving a mode value
  75914. * @param mode: the filter mode value
  75915. */
  75916. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75917. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75918. /**
  75919. * Returns a buffer from its accessor
  75920. * @param gltfRuntime: the GLTF runtime
  75921. * @param accessor: the GLTF accessor
  75922. */
  75923. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75924. /**
  75925. * Decodes a buffer view into a string
  75926. * @param view: the buffer view
  75927. */
  75928. static DecodeBufferToText(view: ArrayBufferView): string;
  75929. /**
  75930. * Returns the default material of gltf. Related to
  75931. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75932. * @param scene: the Babylon.js scene
  75933. */
  75934. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75935. private static _DefaultMaterial;
  75936. }
  75937. }
  75938. declare module BABYLON.GLTF1 {
  75939. /**
  75940. * Implementation of the base glTF spec
  75941. * @hidden
  75942. */
  75943. export class GLTFLoaderBase {
  75944. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75945. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75946. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75947. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75948. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75949. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75950. }
  75951. /**
  75952. * glTF V1 Loader
  75953. * @hidden
  75954. */
  75955. export class GLTFLoader implements IGLTFLoader {
  75956. static Extensions: {
  75957. [name: string]: GLTFLoaderExtension;
  75958. };
  75959. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75960. state: Nullable<GLTFLoaderState>;
  75961. dispose(): void;
  75962. private _importMeshAsync;
  75963. /**
  75964. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75965. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75966. * @param scene the scene the meshes should be added to
  75967. * @param forAssetContainer defines if the entities must be stored in the scene
  75968. * @param data gltf data containing information of the meshes in a loaded file
  75969. * @param rootUrl root url to load from
  75970. * @param onProgress event that fires when loading progress has occured
  75971. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75972. */
  75973. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75974. private _loadAsync;
  75975. /**
  75976. * Imports all objects from a loaded gltf file and adds them to the scene
  75977. * @param scene the scene the objects should be added to
  75978. * @param data gltf data containing information of the meshes in a loaded file
  75979. * @param rootUrl root url to load from
  75980. * @param onProgress event that fires when loading progress has occured
  75981. * @returns a promise which completes when objects have been loaded to the scene
  75982. */
  75983. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75984. private _loadShadersAsync;
  75985. private _loadBuffersAsync;
  75986. private _createNodes;
  75987. }
  75988. /** @hidden */
  75989. export abstract class GLTFLoaderExtension {
  75990. private _name;
  75991. constructor(name: string);
  75992. get name(): string;
  75993. /**
  75994. * Defines an override for loading the runtime
  75995. * Return true to stop further extensions from loading the runtime
  75996. */
  75997. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75998. /**
  75999. * Defines an onverride for creating gltf runtime
  76000. * Return true to stop further extensions from creating the runtime
  76001. */
  76002. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  76003. /**
  76004. * Defines an override for loading buffers
  76005. * Return true to stop further extensions from loading this buffer
  76006. */
  76007. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  76008. /**
  76009. * Defines an override for loading texture buffers
  76010. * Return true to stop further extensions from loading this texture data
  76011. */
  76012. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76013. /**
  76014. * Defines an override for creating textures
  76015. * Return true to stop further extensions from loading this texture
  76016. */
  76017. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76018. /**
  76019. * Defines an override for loading shader strings
  76020. * Return true to stop further extensions from loading this shader data
  76021. */
  76022. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76023. /**
  76024. * Defines an override for loading materials
  76025. * Return true to stop further extensions from loading this material
  76026. */
  76027. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76028. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76029. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76030. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76031. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76032. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76033. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76034. private static LoadTextureBufferAsync;
  76035. private static CreateTextureAsync;
  76036. private static ApplyExtensions;
  76037. }
  76038. }
  76039. declare module BABYLON.GLTF1 {
  76040. /** @hidden */
  76041. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76042. private _bin;
  76043. constructor();
  76044. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76045. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76046. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76047. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76048. }
  76049. }
  76050. declare module BABYLON.GLTF1 {
  76051. /** @hidden */
  76052. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76053. constructor();
  76054. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76055. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76056. private _loadTexture;
  76057. }
  76058. }
  76059. declare module BABYLON.GLTF2.Loader {
  76060. /**
  76061. * Loader interface with an index field.
  76062. */
  76063. export interface IArrayItem {
  76064. /**
  76065. * The index of this item in the array.
  76066. */
  76067. index: number;
  76068. }
  76069. /**
  76070. * Loader interface with additional members.
  76071. */
  76072. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76073. /** @hidden */
  76074. _data?: Promise<ArrayBufferView>;
  76075. /** @hidden */
  76076. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76077. }
  76078. /**
  76079. * Loader interface with additional members.
  76080. */
  76081. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76082. }
  76083. /** @hidden */
  76084. export interface _IAnimationSamplerData {
  76085. input: Float32Array;
  76086. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76087. output: Float32Array;
  76088. }
  76089. /**
  76090. * Loader interface with additional members.
  76091. */
  76092. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76093. /** @hidden */
  76094. _data?: Promise<_IAnimationSamplerData>;
  76095. }
  76096. /**
  76097. * Loader interface with additional members.
  76098. */
  76099. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76100. channels: IAnimationChannel[];
  76101. samplers: IAnimationSampler[];
  76102. /** @hidden */
  76103. _babylonAnimationGroup?: AnimationGroup;
  76104. }
  76105. /**
  76106. * Loader interface with additional members.
  76107. */
  76108. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76109. /** @hidden */
  76110. _data?: Promise<ArrayBufferView>;
  76111. }
  76112. /**
  76113. * Loader interface with additional members.
  76114. */
  76115. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76116. /** @hidden */
  76117. _data?: Promise<ArrayBufferView>;
  76118. /** @hidden */
  76119. _babylonBuffer?: Promise<Buffer>;
  76120. }
  76121. /**
  76122. * Loader interface with additional members.
  76123. */
  76124. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76125. }
  76126. /**
  76127. * Loader interface with additional members.
  76128. */
  76129. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76130. /** @hidden */
  76131. _data?: Promise<ArrayBufferView>;
  76132. }
  76133. /**
  76134. * Loader interface with additional members.
  76135. */
  76136. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76137. }
  76138. /**
  76139. * Loader interface with additional members.
  76140. */
  76141. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76142. }
  76143. /**
  76144. * Loader interface with additional members.
  76145. */
  76146. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76147. baseColorTexture?: ITextureInfo;
  76148. metallicRoughnessTexture?: ITextureInfo;
  76149. }
  76150. /**
  76151. * Loader interface with additional members.
  76152. */
  76153. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76154. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76155. normalTexture?: IMaterialNormalTextureInfo;
  76156. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76157. emissiveTexture?: ITextureInfo;
  76158. /** @hidden */
  76159. _data?: {
  76160. [babylonDrawMode: number]: {
  76161. babylonMaterial: Material;
  76162. babylonMeshes: AbstractMesh[];
  76163. promise: Promise<void>;
  76164. };
  76165. };
  76166. }
  76167. /**
  76168. * Loader interface with additional members.
  76169. */
  76170. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76171. primitives: IMeshPrimitive[];
  76172. }
  76173. /**
  76174. * Loader interface with additional members.
  76175. */
  76176. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76177. /** @hidden */
  76178. _instanceData?: {
  76179. babylonSourceMesh: Mesh;
  76180. promise: Promise<any>;
  76181. };
  76182. }
  76183. /**
  76184. * Loader interface with additional members.
  76185. */
  76186. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76187. /**
  76188. * The parent glTF node.
  76189. */
  76190. parent?: INode;
  76191. /** @hidden */
  76192. _babylonTransformNode?: TransformNode;
  76193. /** @hidden */
  76194. _primitiveBabylonMeshes?: AbstractMesh[];
  76195. /** @hidden */
  76196. _babylonBones?: Bone[];
  76197. /** @hidden */
  76198. _numMorphTargets?: number;
  76199. }
  76200. /** @hidden */
  76201. export interface _ISamplerData {
  76202. noMipMaps: boolean;
  76203. samplingMode: number;
  76204. wrapU: number;
  76205. wrapV: number;
  76206. }
  76207. /**
  76208. * Loader interface with additional members.
  76209. */
  76210. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76211. /** @hidden */
  76212. _data?: _ISamplerData;
  76213. }
  76214. /**
  76215. * Loader interface with additional members.
  76216. */
  76217. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76218. }
  76219. /**
  76220. * Loader interface with additional members.
  76221. */
  76222. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76223. /** @hidden */
  76224. _data?: {
  76225. babylonSkeleton: Skeleton;
  76226. promise: Promise<void>;
  76227. };
  76228. }
  76229. /**
  76230. * Loader interface with additional members.
  76231. */
  76232. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76233. }
  76234. /**
  76235. * Loader interface with additional members.
  76236. */
  76237. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76238. }
  76239. /**
  76240. * Loader interface with additional members.
  76241. */
  76242. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76243. accessors?: IAccessor[];
  76244. animations?: IAnimation[];
  76245. buffers?: IBuffer[];
  76246. bufferViews?: IBufferView[];
  76247. cameras?: ICamera[];
  76248. images?: IImage[];
  76249. materials?: IMaterial[];
  76250. meshes?: IMesh[];
  76251. nodes?: INode[];
  76252. samplers?: ISampler[];
  76253. scenes?: IScene[];
  76254. skins?: ISkin[];
  76255. textures?: ITexture[];
  76256. }
  76257. }
  76258. declare module BABYLON.GLTF2 {
  76259. /**
  76260. * Interface for a glTF loader extension.
  76261. */
  76262. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76263. /**
  76264. * Called after the loader state changes to LOADING.
  76265. */
  76266. onLoading?(): void;
  76267. /**
  76268. * Called after the loader state changes to READY.
  76269. */
  76270. onReady?(): void;
  76271. /**
  76272. * Define this method to modify the default behavior when loading scenes.
  76273. * @param context The context when loading the asset
  76274. * @param scene The glTF scene property
  76275. * @returns A promise that resolves when the load is complete or null if not handled
  76276. */
  76277. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76278. /**
  76279. * Define this method to modify the default behavior when loading nodes.
  76280. * @param context The context when loading the asset
  76281. * @param node The glTF node property
  76282. * @param assign A function called synchronously after parsing the glTF properties
  76283. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76284. */
  76285. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76286. /**
  76287. * Define this method to modify the default behavior when loading cameras.
  76288. * @param context The context when loading the asset
  76289. * @param camera The glTF camera property
  76290. * @param assign A function called synchronously after parsing the glTF properties
  76291. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76292. */
  76293. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76294. /**
  76295. * @hidden
  76296. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76297. * @param context The context when loading the asset
  76298. * @param primitive The glTF mesh primitive property
  76299. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76300. */
  76301. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76302. /**
  76303. * @hidden
  76304. * Define this method to modify the default behavior when loading data for mesh primitives.
  76305. * @param context The context when loading the asset
  76306. * @param name The mesh name when loading the asset
  76307. * @param node The glTF node when loading the asset
  76308. * @param mesh The glTF mesh when loading the asset
  76309. * @param primitive The glTF mesh primitive property
  76310. * @param assign A function called synchronously after parsing the glTF properties
  76311. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76312. */
  76313. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76314. /**
  76315. * @hidden
  76316. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76317. * @param context The context when loading the asset
  76318. * @param material The glTF material property
  76319. * @param assign A function called synchronously after parsing the glTF properties
  76320. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76321. */
  76322. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76323. /**
  76324. * Define this method to modify the default behavior when creating materials.
  76325. * @param context The context when loading the asset
  76326. * @param material The glTF material property
  76327. * @param babylonDrawMode The draw mode for the Babylon material
  76328. * @returns The Babylon material or null if not handled
  76329. */
  76330. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76331. /**
  76332. * Define this method to modify the default behavior when loading material properties.
  76333. * @param context The context when loading the asset
  76334. * @param material The glTF material property
  76335. * @param babylonMaterial The Babylon material
  76336. * @returns A promise that resolves when the load is complete or null if not handled
  76337. */
  76338. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76339. /**
  76340. * Define this method to modify the default behavior when loading texture infos.
  76341. * @param context The context when loading the asset
  76342. * @param textureInfo The glTF texture info 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. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76347. /**
  76348. * @hidden
  76349. * Define this method to modify the default behavior when loading textures.
  76350. * @param context The context when loading the asset
  76351. * @param texture The glTF texture property
  76352. * @param assign A function called synchronously after parsing the glTF properties
  76353. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76354. */
  76355. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76356. /**
  76357. * Define this method to modify the default behavior when loading animations.
  76358. * @param context The context when loading the asset
  76359. * @param animation The glTF animation property
  76360. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76361. */
  76362. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76363. /**
  76364. * @hidden
  76365. * Define this method to modify the default behavior when loading skins.
  76366. * @param context The context when loading the asset
  76367. * @param node The glTF node property
  76368. * @param skin The glTF skin property
  76369. * @returns A promise that resolves when the load is complete or null if not handled
  76370. */
  76371. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76372. /**
  76373. * @hidden
  76374. * Define this method to modify the default behavior when loading uris.
  76375. * @param context The context when loading the asset
  76376. * @param property The glTF property associated with the uri
  76377. * @param uri The uri to load
  76378. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76379. */
  76380. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76381. /**
  76382. * Define this method to modify the default behavior when loading buffer views.
  76383. * @param context The context when loading the asset
  76384. * @param bufferView The glTF buffer view property
  76385. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76386. */
  76387. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76388. /**
  76389. * Define this method to modify the default behavior when loading buffers.
  76390. * @param context The context when loading the asset
  76391. * @param buffer The glTF buffer property
  76392. * @param byteOffset The byte offset to load
  76393. * @param byteLength The byte length to load
  76394. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76395. */
  76396. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76397. }
  76398. }
  76399. declare module BABYLON.GLTF2 {
  76400. /**
  76401. * Helper class for working with arrays when loading the glTF asset
  76402. */
  76403. export class ArrayItem {
  76404. /**
  76405. * Gets an item from the given array.
  76406. * @param context The context when loading the asset
  76407. * @param array The array to get the item from
  76408. * @param index The index to the array
  76409. * @returns The array item
  76410. */
  76411. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76412. /**
  76413. * Assign an `index` field to each item of the given array.
  76414. * @param array The array of items
  76415. */
  76416. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76417. }
  76418. /**
  76419. * The glTF 2.0 loader
  76420. */
  76421. export class GLTFLoader implements IGLTFLoader {
  76422. /** @hidden */
  76423. _completePromises: Promise<any>[];
  76424. /** @hidden */
  76425. _forAssetContainer: boolean;
  76426. /** Storage */
  76427. _babylonLights: Light[];
  76428. private _disposed;
  76429. private _parent;
  76430. private _state;
  76431. private _extensions;
  76432. private _rootUrl;
  76433. private _fileName;
  76434. private _uniqueRootUrl;
  76435. private _gltf;
  76436. private _bin;
  76437. private _babylonScene;
  76438. private _rootBabylonMesh;
  76439. private _defaultBabylonMaterialData;
  76440. private _progressCallback?;
  76441. private _requests;
  76442. private static _RegisteredExtensions;
  76443. /**
  76444. * The default glTF sampler.
  76445. */
  76446. static readonly DefaultSampler: ISampler;
  76447. /**
  76448. * Registers a loader extension.
  76449. * @param name The name of the loader extension.
  76450. * @param factory The factory function that creates the loader extension.
  76451. */
  76452. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76453. /**
  76454. * Unregisters a loader extension.
  76455. * @param name The name of the loader extension.
  76456. * @returns A boolean indicating whether the extension has been unregistered
  76457. */
  76458. static UnregisterExtension(name: string): boolean;
  76459. /**
  76460. * The loader state.
  76461. */
  76462. get state(): Nullable<GLTFLoaderState>;
  76463. /**
  76464. * The object that represents the glTF JSON.
  76465. */
  76466. get gltf(): IGLTF;
  76467. /**
  76468. * The BIN chunk of a binary glTF.
  76469. */
  76470. get bin(): Nullable<IDataBuffer>;
  76471. /**
  76472. * The parent file loader.
  76473. */
  76474. get parent(): GLTFFileLoader;
  76475. /**
  76476. * The Babylon scene when loading the asset.
  76477. */
  76478. get babylonScene(): Scene;
  76479. /**
  76480. * The root Babylon mesh when loading the asset.
  76481. */
  76482. get rootBabylonMesh(): Mesh;
  76483. /** @hidden */
  76484. constructor(parent: GLTFFileLoader);
  76485. /** @hidden */
  76486. dispose(): void;
  76487. /** @hidden */
  76488. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76489. /** @hidden */
  76490. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76491. private _loadAsync;
  76492. private _loadData;
  76493. private _setupData;
  76494. private _loadExtensions;
  76495. private _checkExtensions;
  76496. private _setState;
  76497. private _createRootNode;
  76498. /**
  76499. * Loads a glTF scene.
  76500. * @param context The context when loading the asset
  76501. * @param scene The glTF scene property
  76502. * @returns A promise that resolves when the load is complete
  76503. */
  76504. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76505. private _forEachPrimitive;
  76506. private _getMeshes;
  76507. private _getTransformNodes;
  76508. private _getSkeletons;
  76509. private _getAnimationGroups;
  76510. private _startAnimations;
  76511. /**
  76512. * Loads a glTF node.
  76513. * @param context The context when loading the asset
  76514. * @param node The glTF node property
  76515. * @param assign A function called synchronously after parsing the glTF properties
  76516. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76517. */
  76518. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76519. private _loadMeshAsync;
  76520. /**
  76521. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76522. * @param context The context when loading the asset
  76523. * @param name The mesh name when loading the asset
  76524. * @param node The glTF node when loading the asset
  76525. * @param mesh The glTF mesh when loading the asset
  76526. * @param primitive The glTF mesh primitive property
  76527. * @param assign A function called synchronously after parsing the glTF properties
  76528. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76529. */
  76530. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76531. private _loadVertexDataAsync;
  76532. private _createMorphTargets;
  76533. private _loadMorphTargetsAsync;
  76534. private _loadMorphTargetVertexDataAsync;
  76535. private static _LoadTransform;
  76536. private _loadSkinAsync;
  76537. private _loadBones;
  76538. private _loadBone;
  76539. private _loadSkinInverseBindMatricesDataAsync;
  76540. private _updateBoneMatrices;
  76541. private _getNodeMatrix;
  76542. /**
  76543. * Loads a glTF camera.
  76544. * @param context The context when loading the asset
  76545. * @param camera The glTF camera property
  76546. * @param assign A function called synchronously after parsing the glTF properties
  76547. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76548. */
  76549. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76550. private _loadAnimationsAsync;
  76551. /**
  76552. * Loads a glTF animation.
  76553. * @param context The context when loading the asset
  76554. * @param animation The glTF animation property
  76555. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76556. */
  76557. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76558. /**
  76559. * @hidden Loads a glTF animation channel.
  76560. * @param context The context when loading the asset
  76561. * @param animationContext The context of the animation when loading the asset
  76562. * @param animation The glTF animation property
  76563. * @param channel The glTF animation channel property
  76564. * @param babylonAnimationGroup The babylon animation group property
  76565. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76566. * @returns A void promise when the channel load is complete
  76567. */
  76568. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76569. private _loadAnimationSamplerAsync;
  76570. private _loadBufferAsync;
  76571. /**
  76572. * Loads a glTF buffer view.
  76573. * @param context The context when loading the asset
  76574. * @param bufferView The glTF buffer view property
  76575. * @returns A promise that resolves with the loaded data when the load is complete
  76576. */
  76577. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76578. private _loadAccessorAsync;
  76579. /** @hidden */
  76580. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76581. private _loadIndicesAccessorAsync;
  76582. private _loadVertexBufferViewAsync;
  76583. private _loadVertexAccessorAsync;
  76584. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76585. /** @hidden */
  76586. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76587. private _createDefaultMaterial;
  76588. /**
  76589. * Creates a Babylon material from a glTF material.
  76590. * @param context The context when loading the asset
  76591. * @param material The glTF material property
  76592. * @param babylonDrawMode The draw mode for the Babylon material
  76593. * @returns The Babylon material
  76594. */
  76595. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76596. /**
  76597. * Loads properties from a glTF material into a Babylon material.
  76598. * @param context The context when loading the asset
  76599. * @param material The glTF material property
  76600. * @param babylonMaterial The Babylon material
  76601. * @returns A promise that resolves when the load is complete
  76602. */
  76603. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76604. /**
  76605. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76606. * @param context The context when loading the asset
  76607. * @param material The glTF material property
  76608. * @param babylonMaterial The Babylon material
  76609. * @returns A promise that resolves when the load is complete
  76610. */
  76611. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76612. /**
  76613. * Loads the alpha properties from a glTF material into a Babylon material.
  76614. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76615. * @param context The context when loading the asset
  76616. * @param material The glTF material property
  76617. * @param babylonMaterial The Babylon material
  76618. */
  76619. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76620. /**
  76621. * Loads a glTF texture info.
  76622. * @param context The context when loading the asset
  76623. * @param textureInfo The glTF texture info property
  76624. * @param assign A function called synchronously after parsing the glTF properties
  76625. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76626. */
  76627. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76628. /** @hidden */
  76629. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76630. /** @hidden */
  76631. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76632. private _loadSampler;
  76633. /**
  76634. * Loads a glTF image.
  76635. * @param context The context when loading the asset
  76636. * @param image The glTF image property
  76637. * @returns A promise that resolves with the loaded data when the load is complete
  76638. */
  76639. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76640. /**
  76641. * Loads a glTF uri.
  76642. * @param context The context when loading the asset
  76643. * @param property The glTF property associated with the uri
  76644. * @param uri The base64 or relative uri
  76645. * @returns A promise that resolves with the loaded data when the load is complete
  76646. */
  76647. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76648. private _onProgress;
  76649. /**
  76650. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76651. * @param babylonObject the Babylon object with metadata
  76652. * @param pointer the JSON pointer
  76653. */
  76654. static AddPointerMetadata(babylonObject: {
  76655. metadata: any;
  76656. }, pointer: string): void;
  76657. private static _GetTextureWrapMode;
  76658. private static _GetTextureSamplingMode;
  76659. private static _GetTypedArrayConstructor;
  76660. private static _GetTypedArray;
  76661. private static _GetNumComponents;
  76662. private static _ValidateUri;
  76663. private static _GetDrawMode;
  76664. private _compileMaterialsAsync;
  76665. private _compileShadowGeneratorsAsync;
  76666. private _forEachExtensions;
  76667. private _applyExtensions;
  76668. private _extensionsOnLoading;
  76669. private _extensionsOnReady;
  76670. private _extensionsLoadSceneAsync;
  76671. private _extensionsLoadNodeAsync;
  76672. private _extensionsLoadCameraAsync;
  76673. private _extensionsLoadVertexDataAsync;
  76674. private _extensionsLoadMeshPrimitiveAsync;
  76675. private _extensionsLoadMaterialAsync;
  76676. private _extensionsCreateMaterial;
  76677. private _extensionsLoadMaterialPropertiesAsync;
  76678. private _extensionsLoadTextureInfoAsync;
  76679. private _extensionsLoadTextureAsync;
  76680. private _extensionsLoadAnimationAsync;
  76681. private _extensionsLoadSkinAsync;
  76682. private _extensionsLoadUriAsync;
  76683. private _extensionsLoadBufferViewAsync;
  76684. private _extensionsLoadBufferAsync;
  76685. /**
  76686. * Helper method called by a loader extension to load an glTF extension.
  76687. * @param context The context when loading the asset
  76688. * @param property The glTF property to load the extension 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 extension does not exist
  76692. */
  76693. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76694. /**
  76695. * Helper method called by a loader extension to load a glTF extra.
  76696. * @param context The context when loading the asset
  76697. * @param property The glTF property to load the extra from
  76698. * @param extensionName The name of the extension to load
  76699. * @param actionAsync The action to run
  76700. * @returns The promise returned by actionAsync or null if the extra does not exist
  76701. */
  76702. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76703. /**
  76704. * Checks for presence of an extension.
  76705. * @param name The name of the extension to check
  76706. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76707. */
  76708. isExtensionUsed(name: string): boolean;
  76709. /**
  76710. * Increments the indentation level and logs a message.
  76711. * @param message The message to log
  76712. */
  76713. logOpen(message: string): void;
  76714. /**
  76715. * Decrements the indentation level.
  76716. */
  76717. logClose(): void;
  76718. /**
  76719. * Logs a message
  76720. * @param message The message to log
  76721. */
  76722. log(message: string): void;
  76723. /**
  76724. * Starts a performance counter.
  76725. * @param counterName The name of the performance counter
  76726. */
  76727. startPerformanceCounter(counterName: string): void;
  76728. /**
  76729. * Ends a performance counter.
  76730. * @param counterName The name of the performance counter
  76731. */
  76732. endPerformanceCounter(counterName: string): void;
  76733. }
  76734. }
  76735. declare module BABYLON.GLTF2.Loader.Extensions {
  76736. /**
  76737. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76738. */
  76739. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76740. /**
  76741. * The name of this extension.
  76742. */
  76743. readonly name: string;
  76744. /**
  76745. * Defines whether this extension is enabled.
  76746. */
  76747. enabled: boolean;
  76748. private _loader;
  76749. private _lights?;
  76750. /** @hidden */
  76751. constructor(loader: GLTFLoader);
  76752. /** @hidden */
  76753. dispose(): void;
  76754. /** @hidden */
  76755. onLoading(): void;
  76756. /** @hidden */
  76757. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76758. private _loadLightAsync;
  76759. }
  76760. }
  76761. declare module BABYLON.GLTF2.Loader.Extensions {
  76762. /**
  76763. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76764. */
  76765. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76766. /**
  76767. * The name of this extension.
  76768. */
  76769. readonly name: string;
  76770. /**
  76771. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76772. */
  76773. dracoCompression?: DracoCompression;
  76774. /**
  76775. * Defines whether this extension is enabled.
  76776. */
  76777. enabled: boolean;
  76778. private _loader;
  76779. /** @hidden */
  76780. constructor(loader: GLTFLoader);
  76781. /** @hidden */
  76782. dispose(): void;
  76783. /** @hidden */
  76784. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76785. }
  76786. }
  76787. declare module BABYLON.GLTF2.Loader.Extensions {
  76788. /**
  76789. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76790. */
  76791. export class KHR_lights implements IGLTFLoaderExtension {
  76792. /**
  76793. * The name of this extension.
  76794. */
  76795. readonly name: string;
  76796. /**
  76797. * Defines whether this extension is enabled.
  76798. */
  76799. enabled: boolean;
  76800. private _loader;
  76801. private _lights?;
  76802. /** @hidden */
  76803. constructor(loader: GLTFLoader);
  76804. /** @hidden */
  76805. dispose(): void;
  76806. /** @hidden */
  76807. onLoading(): void;
  76808. /** @hidden */
  76809. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76810. }
  76811. }
  76812. declare module BABYLON.GLTF2.Loader.Extensions {
  76813. /**
  76814. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76815. */
  76816. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76817. /**
  76818. * The name of this extension.
  76819. */
  76820. readonly name: string;
  76821. /**
  76822. * Defines whether this extension is enabled.
  76823. */
  76824. enabled: boolean;
  76825. /**
  76826. * Defines a number that determines the order the extensions are applied.
  76827. */
  76828. order: number;
  76829. private _loader;
  76830. /** @hidden */
  76831. constructor(loader: GLTFLoader);
  76832. /** @hidden */
  76833. dispose(): void;
  76834. /** @hidden */
  76835. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76836. private _loadSpecularGlossinessPropertiesAsync;
  76837. }
  76838. }
  76839. declare module BABYLON.GLTF2.Loader.Extensions {
  76840. /**
  76841. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76842. */
  76843. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76844. /**
  76845. * The name of this extension.
  76846. */
  76847. readonly name: string;
  76848. /**
  76849. * Defines whether this extension is enabled.
  76850. */
  76851. enabled: boolean;
  76852. /**
  76853. * Defines a number that determines the order the extensions are applied.
  76854. */
  76855. order: number;
  76856. private _loader;
  76857. /** @hidden */
  76858. constructor(loader: GLTFLoader);
  76859. /** @hidden */
  76860. dispose(): void;
  76861. /** @hidden */
  76862. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76863. private _loadUnlitPropertiesAsync;
  76864. }
  76865. }
  76866. declare module BABYLON.GLTF2.Loader.Extensions {
  76867. /**
  76868. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76869. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76870. * !!! Experimental Extension Subject to Changes !!!
  76871. */
  76872. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76873. /**
  76874. * The name of this extension.
  76875. */
  76876. readonly name: string;
  76877. /**
  76878. * Defines whether this extension is enabled.
  76879. */
  76880. enabled: boolean;
  76881. /**
  76882. * Defines a number that determines the order the extensions are applied.
  76883. */
  76884. order: number;
  76885. private _loader;
  76886. /** @hidden */
  76887. constructor(loader: GLTFLoader);
  76888. /** @hidden */
  76889. dispose(): void;
  76890. /** @hidden */
  76891. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76892. private _loadClearCoatPropertiesAsync;
  76893. }
  76894. }
  76895. declare module BABYLON.GLTF2.Loader.Extensions {
  76896. /**
  76897. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76898. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76899. * !!! Experimental Extension Subject to Changes !!!
  76900. */
  76901. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76902. /**
  76903. * The name of this extension.
  76904. */
  76905. readonly name: string;
  76906. /**
  76907. * Defines whether this extension is enabled.
  76908. */
  76909. enabled: boolean;
  76910. /**
  76911. * Defines a number that determines the order the extensions are applied.
  76912. */
  76913. order: number;
  76914. private _loader;
  76915. /** @hidden */
  76916. constructor(loader: GLTFLoader);
  76917. /** @hidden */
  76918. dispose(): void;
  76919. /** @hidden */
  76920. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76921. private _loadSheenPropertiesAsync;
  76922. }
  76923. }
  76924. declare module BABYLON.GLTF2.Loader.Extensions {
  76925. /**
  76926. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76927. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76928. * !!! Experimental Extension Subject to Changes !!!
  76929. */
  76930. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76931. /**
  76932. * The name of this extension.
  76933. */
  76934. readonly name: string;
  76935. /**
  76936. * Defines whether this extension is enabled.
  76937. */
  76938. enabled: boolean;
  76939. /**
  76940. * Defines a number that determines the order the extensions are applied.
  76941. */
  76942. order: number;
  76943. private _loader;
  76944. /** @hidden */
  76945. constructor(loader: GLTFLoader);
  76946. /** @hidden */
  76947. dispose(): void;
  76948. /** @hidden */
  76949. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76950. private _loadSpecularPropertiesAsync;
  76951. }
  76952. }
  76953. declare module BABYLON.GLTF2.Loader.Extensions {
  76954. /**
  76955. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76956. * [Playground Sample](//TODO)
  76957. * !!! Experimental Extension Subject to Changes !!!
  76958. */
  76959. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  76960. /**
  76961. * The name of this extension.
  76962. */
  76963. readonly name: string;
  76964. /**
  76965. * Defines whether this extension is enabled.
  76966. */
  76967. enabled: boolean;
  76968. private _loader;
  76969. /** @hidden */
  76970. constructor(loader: GLTFLoader);
  76971. /** @hidden */
  76972. dispose(): void;
  76973. /** @hidden */
  76974. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76975. }
  76976. }
  76977. declare module BABYLON.GLTF2.Loader.Extensions {
  76978. /**
  76979. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76980. */
  76981. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76982. /**
  76983. * The name of this extension.
  76984. */
  76985. readonly name: string;
  76986. /**
  76987. * Defines whether this extension is enabled.
  76988. */
  76989. enabled: boolean;
  76990. /** @hidden */
  76991. constructor(loader: GLTFLoader);
  76992. /** @hidden */
  76993. dispose(): void;
  76994. }
  76995. }
  76996. declare module BABYLON.GLTF2.Loader.Extensions {
  76997. /**
  76998. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  76999. * !!! Experimental Extension Subject to Changes !!!
  77000. */
  77001. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  77002. /** The name of this extension. */
  77003. readonly name: string;
  77004. /** Defines whether this extension is enabled. */
  77005. enabled: boolean;
  77006. private _loader;
  77007. /** @hidden */
  77008. constructor(loader: GLTFLoader);
  77009. /** @hidden */
  77010. dispose(): void;
  77011. /** @hidden */
  77012. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77013. }
  77014. }
  77015. declare module BABYLON.GLTF2.Loader.Extensions {
  77016. /**
  77017. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77018. */
  77019. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77020. /**
  77021. * The name of this extension.
  77022. */
  77023. readonly name: string;
  77024. /**
  77025. * Defines whether this extension is enabled.
  77026. */
  77027. enabled: boolean;
  77028. private _loader;
  77029. /** @hidden */
  77030. constructor(loader: GLTFLoader);
  77031. /** @hidden */
  77032. dispose(): void;
  77033. /** @hidden */
  77034. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77035. }
  77036. }
  77037. declare module BABYLON.GLTF2.Loader.Extensions {
  77038. /**
  77039. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77040. */
  77041. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  77042. /**
  77043. * The name of this extension.
  77044. */
  77045. readonly name: string;
  77046. /**
  77047. * Defines whether this extension is enabled.
  77048. */
  77049. enabled: boolean;
  77050. private _loader;
  77051. private _clips;
  77052. private _emitters;
  77053. /** @hidden */
  77054. constructor(loader: GLTFLoader);
  77055. /** @hidden */
  77056. dispose(): void;
  77057. /** @hidden */
  77058. onLoading(): void;
  77059. /** @hidden */
  77060. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77061. /** @hidden */
  77062. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77063. /** @hidden */
  77064. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77065. private _loadClipAsync;
  77066. private _loadEmitterAsync;
  77067. private _getEventAction;
  77068. private _loadAnimationEventAsync;
  77069. }
  77070. }
  77071. declare module BABYLON.GLTF2.Loader.Extensions {
  77072. /**
  77073. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77074. */
  77075. export class MSFT_lod implements IGLTFLoaderExtension {
  77076. /**
  77077. * The name of this extension.
  77078. */
  77079. readonly name: string;
  77080. /**
  77081. * Defines whether this extension is enabled.
  77082. */
  77083. enabled: boolean;
  77084. /**
  77085. * Defines a number that determines the order the extensions are applied.
  77086. */
  77087. order: number;
  77088. /**
  77089. * Maximum number of LODs to load, starting from the lowest LOD.
  77090. */
  77091. maxLODsToLoad: number;
  77092. /**
  77093. * Observable raised when all node LODs of one level are loaded.
  77094. * The event data is the index of the loaded LOD starting from zero.
  77095. * Dispose the loader to cancel the loading of the next level of LODs.
  77096. */
  77097. onNodeLODsLoadedObservable: Observable<number>;
  77098. /**
  77099. * Observable raised when all material LODs of one level are loaded.
  77100. * The event data is the index of the loaded LOD starting from zero.
  77101. * Dispose the loader to cancel the loading of the next level of LODs.
  77102. */
  77103. onMaterialLODsLoadedObservable: Observable<number>;
  77104. private _loader;
  77105. private _nodeIndexLOD;
  77106. private _nodeSignalLODs;
  77107. private _nodePromiseLODs;
  77108. private _materialIndexLOD;
  77109. private _materialSignalLODs;
  77110. private _materialPromiseLODs;
  77111. private _indexLOD;
  77112. private _bufferLODs;
  77113. /** @hidden */
  77114. constructor(loader: GLTFLoader);
  77115. /** @hidden */
  77116. dispose(): void;
  77117. /** @hidden */
  77118. onReady(): void;
  77119. /** @hidden */
  77120. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77121. /** @hidden */
  77122. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77123. /** @hidden */
  77124. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77125. /** @hidden */
  77126. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77127. /** @hidden */
  77128. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77129. private _loadBufferLOD;
  77130. /**
  77131. * Gets an array of LOD properties from lowest to highest.
  77132. */
  77133. private _getLODs;
  77134. private _disposeTransformNode;
  77135. private _disposeMaterials;
  77136. }
  77137. }
  77138. declare module BABYLON.GLTF2.Loader.Extensions {
  77139. /** @hidden */
  77140. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77141. readonly name: string;
  77142. enabled: boolean;
  77143. private _loader;
  77144. constructor(loader: GLTFLoader);
  77145. dispose(): void;
  77146. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77147. }
  77148. }
  77149. declare module BABYLON.GLTF2.Loader.Extensions {
  77150. /** @hidden */
  77151. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77152. readonly name: string;
  77153. enabled: boolean;
  77154. private _loader;
  77155. constructor(loader: GLTFLoader);
  77156. dispose(): void;
  77157. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77158. }
  77159. }
  77160. declare module BABYLON.GLTF2.Loader.Extensions {
  77161. /**
  77162. * Store glTF extras (if present) in BJS objects' metadata
  77163. */
  77164. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77165. /**
  77166. * The name of this extension.
  77167. */
  77168. readonly name: string;
  77169. /**
  77170. * Defines whether this extension is enabled.
  77171. */
  77172. enabled: boolean;
  77173. private _loader;
  77174. private _assignExtras;
  77175. /** @hidden */
  77176. constructor(loader: GLTFLoader);
  77177. /** @hidden */
  77178. dispose(): void;
  77179. /** @hidden */
  77180. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77181. /** @hidden */
  77182. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77183. /** @hidden */
  77184. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77185. }
  77186. }
  77187. declare module BABYLON {
  77188. /**
  77189. * Class reading and parsing the MTL file bundled with the obj file.
  77190. */
  77191. export class MTLFileLoader {
  77192. /**
  77193. * Invert Y-Axis of referenced textures on load
  77194. */
  77195. static INVERT_TEXTURE_Y: boolean;
  77196. /**
  77197. * All material loaded from the mtl will be set here
  77198. */
  77199. materials: StandardMaterial[];
  77200. /**
  77201. * This function will read the mtl file and create each material described inside
  77202. * This function could be improve by adding :
  77203. * -some component missing (Ni, Tf...)
  77204. * -including the specific options available
  77205. *
  77206. * @param scene defines the scene the material will be created in
  77207. * @param data defines the mtl data to parse
  77208. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77209. * @param forAssetContainer defines if the material should be registered in the scene
  77210. */
  77211. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77212. /**
  77213. * Gets the texture for the material.
  77214. *
  77215. * If the material is imported from input file,
  77216. * We sanitize the url to ensure it takes the textre from aside the material.
  77217. *
  77218. * @param rootUrl The root url to load from
  77219. * @param value The value stored in the mtl
  77220. * @return The Texture
  77221. */
  77222. private static _getTexture;
  77223. }
  77224. }
  77225. declare module BABYLON {
  77226. /**
  77227. * Options for loading OBJ/MTL files
  77228. */
  77229. type MeshLoadOptions = {
  77230. /**
  77231. * Defines if UVs are optimized by default during load.
  77232. */
  77233. OptimizeWithUV: boolean;
  77234. /**
  77235. * Defines custom scaling of UV coordinates of loaded meshes.
  77236. */
  77237. UVScaling: Vector2;
  77238. /**
  77239. * Invert model on y-axis (does a model scaling inversion)
  77240. */
  77241. InvertY: boolean;
  77242. /**
  77243. * Invert Y-Axis of referenced textures on load
  77244. */
  77245. InvertTextureY: boolean;
  77246. /**
  77247. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77248. */
  77249. ImportVertexColors: boolean;
  77250. /**
  77251. * Compute the normals for the model, even if normals are present in the file.
  77252. */
  77253. ComputeNormals: boolean;
  77254. /**
  77255. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77256. */
  77257. SkipMaterials: boolean;
  77258. /**
  77259. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77260. */
  77261. MaterialLoadingFailsSilently: boolean;
  77262. };
  77263. /**
  77264. * OBJ file type loader.
  77265. * This is a babylon scene loader plugin.
  77266. */
  77267. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77268. /**
  77269. * Defines if UVs are optimized by default during load.
  77270. */
  77271. static OPTIMIZE_WITH_UV: boolean;
  77272. /**
  77273. * Invert model on y-axis (does a model scaling inversion)
  77274. */
  77275. static INVERT_Y: boolean;
  77276. /**
  77277. * Invert Y-Axis of referenced textures on load
  77278. */
  77279. static get INVERT_TEXTURE_Y(): boolean;
  77280. static set INVERT_TEXTURE_Y(value: boolean);
  77281. /**
  77282. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77283. */
  77284. static IMPORT_VERTEX_COLORS: boolean;
  77285. /**
  77286. * Compute the normals for the model, even if normals are present in the file.
  77287. */
  77288. static COMPUTE_NORMALS: boolean;
  77289. /**
  77290. * Defines custom scaling of UV coordinates of loaded meshes.
  77291. */
  77292. static UV_SCALING: Vector2;
  77293. /**
  77294. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77295. */
  77296. static SKIP_MATERIALS: boolean;
  77297. /**
  77298. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77299. *
  77300. * Defaults to true for backwards compatibility.
  77301. */
  77302. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77303. /**
  77304. * Defines the name of the plugin.
  77305. */
  77306. name: string;
  77307. /**
  77308. * Defines the extension the plugin is able to load.
  77309. */
  77310. extensions: string;
  77311. /** @hidden */
  77312. obj: RegExp;
  77313. /** @hidden */
  77314. group: RegExp;
  77315. /** @hidden */
  77316. mtllib: RegExp;
  77317. /** @hidden */
  77318. usemtl: RegExp;
  77319. /** @hidden */
  77320. smooth: RegExp;
  77321. /** @hidden */
  77322. vertexPattern: RegExp;
  77323. /** @hidden */
  77324. normalPattern: RegExp;
  77325. /** @hidden */
  77326. uvPattern: RegExp;
  77327. /** @hidden */
  77328. facePattern1: RegExp;
  77329. /** @hidden */
  77330. facePattern2: RegExp;
  77331. /** @hidden */
  77332. facePattern3: RegExp;
  77333. /** @hidden */
  77334. facePattern4: RegExp;
  77335. /** @hidden */
  77336. facePattern5: RegExp;
  77337. private _forAssetContainer;
  77338. private _meshLoadOptions;
  77339. /**
  77340. * Creates loader for .OBJ files
  77341. *
  77342. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77343. */
  77344. constructor(meshLoadOptions?: MeshLoadOptions);
  77345. private static get currentMeshLoadOptions();
  77346. /**
  77347. * Calls synchronously the MTL file attached to this obj.
  77348. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77349. * Without this function materials are not displayed in the first frame (but displayed after).
  77350. * In consequence it is impossible to get material information in your HTML file
  77351. *
  77352. * @param url The URL of the MTL file
  77353. * @param rootUrl
  77354. * @param onSuccess Callback function to be called when the MTL file is loaded
  77355. * @private
  77356. */
  77357. private _loadMTL;
  77358. /**
  77359. * Instantiates a OBJ file loader plugin.
  77360. * @returns the created plugin
  77361. */
  77362. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77363. /**
  77364. * If the data string can be loaded directly.
  77365. *
  77366. * @param data string containing the file data
  77367. * @returns if the data can be loaded directly
  77368. */
  77369. canDirectLoad(data: string): boolean;
  77370. /**
  77371. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77372. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77373. * @param scene the scene the meshes should be added to
  77374. * @param data the OBJ data to load
  77375. * @param rootUrl root url to load from
  77376. * @param onProgress event that fires when loading progress has occured
  77377. * @param fileName Defines the name of the file to load
  77378. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77379. */
  77380. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77381. meshes: AbstractMesh[];
  77382. particleSystems: IParticleSystem[];
  77383. skeletons: Skeleton[];
  77384. animationGroups: AnimationGroup[];
  77385. }>;
  77386. /**
  77387. * Imports all objects from the loaded OBJ data and adds them to the scene
  77388. * @param scene the scene the objects should be added to
  77389. * @param data the OBJ data to load
  77390. * @param rootUrl root url to load from
  77391. * @param onProgress event that fires when loading progress has occured
  77392. * @param fileName Defines the name of the file to load
  77393. * @returns a promise which completes when objects have been loaded to the scene
  77394. */
  77395. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77396. /**
  77397. * Load into an asset container.
  77398. * @param scene The scene to load into
  77399. * @param data The data to import
  77400. * @param rootUrl The root url for scene and resources
  77401. * @param onProgress The callback when the load progresses
  77402. * @param fileName Defines the name of the file to load
  77403. * @returns The loaded asset container
  77404. */
  77405. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77406. /**
  77407. * Read the OBJ file and create an Array of meshes.
  77408. * Each mesh contains all information given by the OBJ and the MTL file.
  77409. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77410. *
  77411. * @param meshesNames
  77412. * @param scene Scene The scene where are displayed the data
  77413. * @param data String The content of the obj file
  77414. * @param rootUrl String The path to the folder
  77415. * @returns Array<AbstractMesh>
  77416. * @private
  77417. */
  77418. private _parseSolid;
  77419. }
  77420. }
  77421. declare module BABYLON {
  77422. /**
  77423. * STL file type loader.
  77424. * This is a babylon scene loader plugin.
  77425. */
  77426. export class STLFileLoader implements ISceneLoaderPlugin {
  77427. /** @hidden */
  77428. solidPattern: RegExp;
  77429. /** @hidden */
  77430. facetsPattern: RegExp;
  77431. /** @hidden */
  77432. normalPattern: RegExp;
  77433. /** @hidden */
  77434. vertexPattern: RegExp;
  77435. /**
  77436. * Defines the name of the plugin.
  77437. */
  77438. name: string;
  77439. /**
  77440. * Defines the extensions the stl loader is able to load.
  77441. * force data to come in as an ArrayBuffer
  77442. * we'll convert to string if it looks like it's an ASCII .stl
  77443. */
  77444. extensions: ISceneLoaderPluginExtensions;
  77445. /**
  77446. * Import meshes into a scene.
  77447. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77448. * @param scene The scene to import into
  77449. * @param data The data to import
  77450. * @param rootUrl The root url for scene and resources
  77451. * @param meshes The meshes array to import into
  77452. * @param particleSystems The particle systems array to import into
  77453. * @param skeletons The skeletons array to import into
  77454. * @param onError The callback when import fails
  77455. * @returns True if successful or false otherwise
  77456. */
  77457. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77458. /**
  77459. * Load into a scene.
  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 true if successful or false otherwise
  77465. */
  77466. load(scene: Scene, data: any, rootUrl: string): boolean;
  77467. /**
  77468. * Load into an asset container.
  77469. * @param scene The scene to load into
  77470. * @param data The data to import
  77471. * @param rootUrl The root url for scene and resources
  77472. * @param onError The callback when import fails
  77473. * @returns The loaded asset container
  77474. */
  77475. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77476. private _isBinary;
  77477. private _parseBinary;
  77478. private _parseASCII;
  77479. }
  77480. }
  77481. declare module BABYLON {
  77482. /**
  77483. * Class for generating OBJ data from a Babylon scene.
  77484. */
  77485. export class OBJExport {
  77486. /**
  77487. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77488. * @param mesh defines the list of meshes to serialize
  77489. * @param materials defines if materials should be exported
  77490. * @param matlibname defines the name of the associated mtl file
  77491. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77492. * @returns the OBJ content
  77493. */
  77494. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77495. /**
  77496. * Exports the material(s) of a mesh in .MTL file format (text)
  77497. * @param mesh defines the mesh to extract the material from
  77498. * @returns the mtl content
  77499. */
  77500. static MTL(mesh: Mesh): string;
  77501. }
  77502. }
  77503. declare module BABYLON {
  77504. /** @hidden */
  77505. export var __IGLTFExporterExtension: number;
  77506. /**
  77507. * Interface for extending the exporter
  77508. * @hidden
  77509. */
  77510. export interface IGLTFExporterExtension {
  77511. /**
  77512. * The name of this extension
  77513. */
  77514. readonly name: string;
  77515. /**
  77516. * Defines whether this extension is enabled
  77517. */
  77518. enabled: boolean;
  77519. /**
  77520. * Defines whether this extension is required
  77521. */
  77522. required: boolean;
  77523. }
  77524. }
  77525. declare module BABYLON.GLTF2.Exporter {
  77526. /** @hidden */
  77527. export var __IGLTFExporterExtensionV2: number;
  77528. /**
  77529. * Interface for a glTF exporter extension
  77530. * @hidden
  77531. */
  77532. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77533. /**
  77534. * Define this method to modify the default behavior before exporting a texture
  77535. * @param context The context when loading the asset
  77536. * @param babylonTexture The Babylon.js texture
  77537. * @param mimeType The mime-type of the generated image
  77538. * @returns A promise that resolves with the exported texture
  77539. */
  77540. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77541. /**
  77542. * Define this method to get notified when a texture info is created
  77543. * @param context The context when loading the asset
  77544. * @param textureInfo The glTF texture info
  77545. * @param babylonTexture The Babylon.js texture
  77546. */
  77547. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77548. /**
  77549. * Define this method to modify the default behavior when exporting texture info
  77550. * @param context The context when loading the asset
  77551. * @param meshPrimitive glTF mesh primitive
  77552. * @param babylonSubMesh Babylon submesh
  77553. * @param binaryWriter glTF serializer binary writer instance
  77554. * @returns nullable IMeshPrimitive promise
  77555. */
  77556. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77557. /**
  77558. * Define this method to modify the default behavior when exporting a node
  77559. * @param context The context when exporting the node
  77560. * @param node glTF node
  77561. * @param babylonNode BabylonJS node
  77562. * @returns nullable INode promise
  77563. */
  77564. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77565. [key: number]: number;
  77566. }): Promise<Nullable<INode>>;
  77567. /**
  77568. * Define this method to modify the default behavior when exporting a material
  77569. * @param material glTF material
  77570. * @param babylonMaterial BabylonJS material
  77571. * @returns nullable IMaterial promise
  77572. */
  77573. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77574. /**
  77575. * Define this method to return additional textures to export from a material
  77576. * @param material glTF material
  77577. * @param babylonMaterial BabylonJS material
  77578. * @returns List of textures
  77579. */
  77580. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77581. /** Gets a boolean indicating that this extension was used */
  77582. wasUsed: boolean;
  77583. /** Gets a boolean indicating that this extension is required for the file to work */
  77584. required: boolean;
  77585. /**
  77586. * Called after the exporter state changes to EXPORTING
  77587. */
  77588. onExporting?(): void;
  77589. }
  77590. }
  77591. declare module BABYLON.GLTF2.Exporter {
  77592. /**
  77593. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77594. * @hidden
  77595. */
  77596. export class _GLTFMaterialExporter {
  77597. /**
  77598. * Represents the dielectric specular values for R, G and B
  77599. */
  77600. private static readonly _DielectricSpecular;
  77601. /**
  77602. * Allows the maximum specular power to be defined for material calculations
  77603. */
  77604. private static readonly _MaxSpecularPower;
  77605. /**
  77606. * Mapping to store textures
  77607. */
  77608. private _textureMap;
  77609. /**
  77610. * Numeric tolerance value
  77611. */
  77612. private static readonly _Epsilon;
  77613. /**
  77614. * Reference to the glTF Exporter
  77615. */
  77616. private _exporter;
  77617. constructor(exporter: _Exporter);
  77618. /**
  77619. * Specifies if two colors are approximately equal in value
  77620. * @param color1 first color to compare to
  77621. * @param color2 second color to compare to
  77622. * @param epsilon threshold value
  77623. */
  77624. private static FuzzyEquals;
  77625. /**
  77626. * Gets the materials from a Babylon scene and converts them to glTF materials
  77627. * @param scene babylonjs scene
  77628. * @param mimeType texture mime type
  77629. * @param images array of images
  77630. * @param textures array of textures
  77631. * @param materials array of materials
  77632. * @param imageData mapping of texture names to base64 textures
  77633. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77634. */
  77635. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77636. /**
  77637. * Makes a copy of the glTF material without the texture parameters
  77638. * @param originalMaterial original glTF material
  77639. * @returns glTF material without texture parameters
  77640. */
  77641. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77642. /**
  77643. * Specifies if the material has any texture parameters present
  77644. * @param material glTF Material
  77645. * @returns boolean specifying if texture parameters are present
  77646. */
  77647. _hasTexturesPresent(material: IMaterial): boolean;
  77648. /**
  77649. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77650. * @param babylonStandardMaterial
  77651. * @returns glTF Metallic Roughness Material representation
  77652. */
  77653. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77654. /**
  77655. * Computes the metallic factor
  77656. * @param diffuse diffused value
  77657. * @param specular specular value
  77658. * @param oneMinusSpecularStrength one minus the specular strength
  77659. * @returns metallic value
  77660. */
  77661. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77662. /**
  77663. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77664. * @param glTFMaterial glTF material
  77665. * @param babylonMaterial Babylon material
  77666. */
  77667. private static _SetAlphaMode;
  77668. /**
  77669. * Converts a Babylon Standard Material to a glTF Material
  77670. * @param babylonStandardMaterial BJS Standard Material
  77671. * @param mimeType mime type to use for the textures
  77672. * @param images array of glTF image interfaces
  77673. * @param textures array of glTF texture interfaces
  77674. * @param materials array of glTF material interfaces
  77675. * @param imageData map of image file name to data
  77676. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77677. */
  77678. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77679. private _finishMaterial;
  77680. /**
  77681. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77682. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77683. * @param mimeType mime type to use for the textures
  77684. * @param images array of glTF image interfaces
  77685. * @param textures array of glTF texture interfaces
  77686. * @param materials array of glTF material interfaces
  77687. * @param imageData map of image file name to data
  77688. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77689. */
  77690. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77691. /**
  77692. * Converts an image typed array buffer to a base64 image
  77693. * @param buffer typed array buffer
  77694. * @param width width of the image
  77695. * @param height height of the image
  77696. * @param mimeType mimetype of the image
  77697. * @returns base64 image string
  77698. */
  77699. private _createBase64FromCanvasAsync;
  77700. /**
  77701. * Generates a white texture based on the specified width and height
  77702. * @param width width of the texture in pixels
  77703. * @param height height of the texture in pixels
  77704. * @param scene babylonjs scene
  77705. * @returns white texture
  77706. */
  77707. private _createWhiteTexture;
  77708. /**
  77709. * 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
  77710. * @param texture1 first texture to resize
  77711. * @param texture2 second texture to resize
  77712. * @param scene babylonjs scene
  77713. * @returns resized textures or null
  77714. */
  77715. private _resizeTexturesToSameDimensions;
  77716. /**
  77717. * Converts an array of pixels to a Float32Array
  77718. * Throws an error if the pixel format is not supported
  77719. * @param pixels - array buffer containing pixel values
  77720. * @returns Float32 of pixels
  77721. */
  77722. private _convertPixelArrayToFloat32;
  77723. /**
  77724. * Convert Specular Glossiness Textures to Metallic Roughness
  77725. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77726. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77727. * @param diffuseTexture texture used to store diffuse information
  77728. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77729. * @param factors specular glossiness material factors
  77730. * @param mimeType the mime type to use for the texture
  77731. * @returns pbr metallic roughness interface or null
  77732. */
  77733. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77734. /**
  77735. * Converts specular glossiness material properties to metallic roughness
  77736. * @param specularGlossiness interface with specular glossiness material properties
  77737. * @returns interface with metallic roughness material properties
  77738. */
  77739. private _convertSpecularGlossinessToMetallicRoughness;
  77740. /**
  77741. * Calculates the surface reflectance, independent of lighting conditions
  77742. * @param color Color source to calculate brightness from
  77743. * @returns number representing the perceived brightness, or zero if color is undefined
  77744. */
  77745. private _getPerceivedBrightness;
  77746. /**
  77747. * Returns the maximum color component value
  77748. * @param color
  77749. * @returns maximum color component value, or zero if color is null or undefined
  77750. */
  77751. private _getMaxComponent;
  77752. /**
  77753. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77754. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77755. * @param mimeType mime type to use for the textures
  77756. * @param images array of glTF image interfaces
  77757. * @param textures array of glTF texture interfaces
  77758. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77759. * @param imageData map of image file name to data
  77760. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77761. * @returns glTF PBR Metallic Roughness factors
  77762. */
  77763. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77764. private _getGLTFTextureSampler;
  77765. private _getGLTFTextureWrapMode;
  77766. private _getGLTFTextureWrapModesSampler;
  77767. /**
  77768. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77769. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77770. * @param mimeType mime type to use for the textures
  77771. * @param images array of glTF image interfaces
  77772. * @param textures array of glTF texture interfaces
  77773. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77774. * @param imageData map of image file name to data
  77775. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77776. * @returns glTF PBR Metallic Roughness factors
  77777. */
  77778. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77779. /**
  77780. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77781. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77782. * @param mimeType mime type to use for the textures
  77783. * @param images array of glTF image interfaces
  77784. * @param textures array of glTF texture interfaces
  77785. * @param materials array of glTF material interfaces
  77786. * @param imageData map of image file name to data
  77787. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77788. */
  77789. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77790. private setMetallicRoughnessPbrMaterial;
  77791. private getPixelsFromTexture;
  77792. /**
  77793. * Extracts a texture from a Babylon texture into file data and glTF data
  77794. * @param babylonTexture Babylon texture to extract
  77795. * @param mimeType Mime Type of the babylonTexture
  77796. * @return glTF texture info, or null if the texture format is not supported
  77797. */
  77798. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77799. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77800. /**
  77801. * Builds a texture from base64 string
  77802. * @param base64Texture base64 texture string
  77803. * @param baseTextureName Name to use for the texture
  77804. * @param mimeType image mime type for the texture
  77805. * @param images array of images
  77806. * @param textures array of textures
  77807. * @param imageData map of image data
  77808. * @returns glTF texture info, or null if the texture format is not supported
  77809. */
  77810. private _getTextureInfoFromBase64;
  77811. }
  77812. }
  77813. declare module BABYLON {
  77814. /**
  77815. * Class for holding and downloading glTF file data
  77816. */
  77817. export class GLTFData {
  77818. /**
  77819. * Object which contains the file name as the key and its data as the value
  77820. */
  77821. glTFFiles: {
  77822. [fileName: string]: string | Blob;
  77823. };
  77824. /**
  77825. * Initializes the glTF file object
  77826. */
  77827. constructor();
  77828. /**
  77829. * Downloads the glTF data as files based on their names and data
  77830. */
  77831. downloadFiles(): void;
  77832. }
  77833. }
  77834. declare module BABYLON {
  77835. /**
  77836. * Holds a collection of exporter options and parameters
  77837. */
  77838. export interface IExportOptions {
  77839. /**
  77840. * Function which indicates whether a babylon node should be exported or not
  77841. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77842. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77843. */
  77844. shouldExportNode?(node: Node): boolean;
  77845. /**
  77846. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77847. * @param metadata source metadata to read from
  77848. * @returns the data to store to glTF node extras
  77849. */
  77850. metadataSelector?(metadata: any): any;
  77851. /**
  77852. * The sample rate to bake animation curves
  77853. */
  77854. animationSampleRate?: number;
  77855. /**
  77856. * Begin serialization without waiting for the scene to be ready
  77857. */
  77858. exportWithoutWaitingForScene?: boolean;
  77859. /**
  77860. * Indicates if coordinate system swapping root nodes should be included in export
  77861. */
  77862. includeCoordinateSystemConversionNodes?: boolean;
  77863. }
  77864. /**
  77865. * Class for generating glTF data from a Babylon scene.
  77866. */
  77867. export class GLTF2Export {
  77868. /**
  77869. * Exports the geometry of the scene to .gltf file format asynchronously
  77870. * @param scene Babylon scene with scene hierarchy information
  77871. * @param filePrefix File prefix to use when generating the glTF file
  77872. * @param options Exporter options
  77873. * @returns Returns an object with a .gltf file and associates texture names
  77874. * as keys and their data and paths as values
  77875. */
  77876. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77877. private static _PreExportAsync;
  77878. private static _PostExportAsync;
  77879. /**
  77880. * Exports the geometry of the scene to .glb file format asychronously
  77881. * @param scene Babylon scene with scene hierarchy information
  77882. * @param filePrefix File prefix to use when generating glb file
  77883. * @param options Exporter options
  77884. * @returns Returns an object with a .glb filename as key and data as value
  77885. */
  77886. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77887. }
  77888. }
  77889. declare module BABYLON.GLTF2.Exporter {
  77890. /**
  77891. * @hidden
  77892. */
  77893. export class _GLTFUtilities {
  77894. /**
  77895. * Creates a buffer view based on the supplied arguments
  77896. * @param bufferIndex index value of the specified buffer
  77897. * @param byteOffset byte offset value
  77898. * @param byteLength byte length of the bufferView
  77899. * @param byteStride byte distance between conequential elements
  77900. * @param name name of the buffer view
  77901. * @returns bufferView for glTF
  77902. */
  77903. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  77904. /**
  77905. * Creates an accessor based on the supplied arguments
  77906. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  77907. * @param name The name of the accessor
  77908. * @param type The type of the accessor
  77909. * @param componentType The datatype of components in the attribute
  77910. * @param count The number of attributes referenced by this accessor
  77911. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77912. * @param min Minimum value of each component in this attribute
  77913. * @param max Maximum value of each component in this attribute
  77914. * @returns accessor for glTF
  77915. */
  77916. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77917. /**
  77918. * Calculates the minimum and maximum values of an array of position floats
  77919. * @param positions Positions array of a mesh
  77920. * @param vertexStart Starting vertex offset to calculate min and max values
  77921. * @param vertexCount Number of vertices to check for min and max values
  77922. * @returns min number array and max number array
  77923. */
  77924. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77925. min: number[];
  77926. max: number[];
  77927. };
  77928. /**
  77929. * Converts a new right-handed Vector3
  77930. * @param vector vector3 array
  77931. * @returns right-handed Vector3
  77932. */
  77933. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77934. /**
  77935. * Converts a Vector3 to right-handed
  77936. * @param vector Vector3 to convert to right-handed
  77937. */
  77938. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77939. /**
  77940. * Converts a three element number array to right-handed
  77941. * @param vector number array to convert to right-handed
  77942. */
  77943. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77944. /**
  77945. * Converts a new right-handed Vector3
  77946. * @param vector vector3 array
  77947. * @returns right-handed Vector3
  77948. */
  77949. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77950. /**
  77951. * Converts a Vector3 to right-handed
  77952. * @param vector Vector3 to convert to right-handed
  77953. */
  77954. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77955. /**
  77956. * Converts a three element number array to right-handed
  77957. * @param vector number array to convert to right-handed
  77958. */
  77959. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77960. /**
  77961. * Converts a Vector4 to right-handed
  77962. * @param vector Vector4 to convert to right-handed
  77963. */
  77964. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77965. /**
  77966. * Converts a Vector4 to right-handed
  77967. * @param vector Vector4 to convert to right-handed
  77968. */
  77969. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77970. /**
  77971. * Converts a Quaternion to right-handed
  77972. * @param quaternion Source quaternion to convert to right-handed
  77973. */
  77974. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77975. /**
  77976. * Converts a Quaternion to right-handed
  77977. * @param quaternion Source quaternion to convert to right-handed
  77978. */
  77979. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77980. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77981. }
  77982. }
  77983. declare module BABYLON.GLTF2.Exporter {
  77984. /**
  77985. * Converts Babylon Scene into glTF 2.0.
  77986. * @hidden
  77987. */
  77988. export class _Exporter {
  77989. /**
  77990. * Stores the glTF to export
  77991. */
  77992. _glTF: IGLTF;
  77993. /**
  77994. * Stores all generated buffer views, which represents views into the main glTF buffer data
  77995. */
  77996. _bufferViews: IBufferView[];
  77997. /**
  77998. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  77999. */
  78000. _accessors: IAccessor[];
  78001. /**
  78002. * Stores all the generated nodes, which contains transform and/or mesh information per node
  78003. */
  78004. _nodes: INode[];
  78005. /**
  78006. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  78007. */
  78008. private _scenes;
  78009. /**
  78010. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78011. */
  78012. private _meshes;
  78013. /**
  78014. * Stores all the generated material information, which represents the appearance of each primitive
  78015. */
  78016. _materials: IMaterial[];
  78017. _materialMap: {
  78018. [materialID: number]: number;
  78019. };
  78020. /**
  78021. * Stores all the generated texture information, which is referenced by glTF materials
  78022. */
  78023. _textures: ITexture[];
  78024. /**
  78025. * Stores all the generated image information, which is referenced by glTF textures
  78026. */
  78027. _images: IImage[];
  78028. /**
  78029. * Stores all the texture samplers
  78030. */
  78031. _samplers: ISampler[];
  78032. /**
  78033. * Stores all the generated animation samplers, which is referenced by glTF animations
  78034. */
  78035. /**
  78036. * Stores the animations for glTF models
  78037. */
  78038. private _animations;
  78039. /**
  78040. * Stores the total amount of bytes stored in the glTF buffer
  78041. */
  78042. private _totalByteLength;
  78043. /**
  78044. * Stores a reference to the Babylon scene containing the source geometry and material information
  78045. */
  78046. _babylonScene: Scene;
  78047. /**
  78048. * Stores a map of the image data, where the key is the file name and the value
  78049. * is the image data
  78050. */
  78051. _imageData: {
  78052. [fileName: string]: {
  78053. data: Uint8Array;
  78054. mimeType: ImageMimeType;
  78055. };
  78056. };
  78057. /**
  78058. * Stores a map of the unique id of a node to its index in the node array
  78059. */
  78060. _nodeMap: {
  78061. [key: number]: number;
  78062. };
  78063. /**
  78064. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78065. */
  78066. _convertToRightHandedSystem: boolean;
  78067. /**
  78068. * Specifies if a Babylon node should be converted to right-handed on export
  78069. */
  78070. _convertToRightHandedSystemMap: {
  78071. [nodeId: number]: boolean;
  78072. };
  78073. _includeCoordinateSystemConversionNodes: boolean;
  78074. /**
  78075. * Baked animation sample rate
  78076. */
  78077. private _animationSampleRate;
  78078. private _options;
  78079. private _localEngine;
  78080. _glTFMaterialExporter: _GLTFMaterialExporter;
  78081. private _extensions;
  78082. private static _ExtensionNames;
  78083. private static _ExtensionFactories;
  78084. private _applyExtension;
  78085. private _applyExtensions;
  78086. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78087. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78088. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78089. [key: number]: number;
  78090. }): Promise<Nullable<INode>>;
  78091. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78092. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78093. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78094. private _forEachExtensions;
  78095. private _extensionsOnExporting;
  78096. /**
  78097. * Load glTF serializer extensions
  78098. */
  78099. private _loadExtensions;
  78100. /**
  78101. * Creates a glTF Exporter instance, which can accept optional exporter options
  78102. * @param babylonScene Babylon scene object
  78103. * @param options Options to modify the behavior of the exporter
  78104. */
  78105. constructor(babylonScene: Scene, options?: IExportOptions);
  78106. dispose(): void;
  78107. /**
  78108. * Registers a glTF exporter extension
  78109. * @param name Name of the extension to export
  78110. * @param factory The factory function that creates the exporter extension
  78111. */
  78112. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78113. /**
  78114. * Un-registers an exporter extension
  78115. * @param name The name fo the exporter extension
  78116. * @returns A boolean indicating whether the extension has been un-registered
  78117. */
  78118. static UnregisterExtension(name: string): boolean;
  78119. /**
  78120. * Lazy load a local engine
  78121. */
  78122. _getLocalEngine(): Engine;
  78123. private reorderIndicesBasedOnPrimitiveMode;
  78124. /**
  78125. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78126. * clock-wise during export to glTF
  78127. * @param submesh BabylonJS submesh
  78128. * @param primitiveMode Primitive mode of the mesh
  78129. * @param sideOrientation the winding order of the submesh
  78130. * @param vertexBufferKind The type of vertex attribute
  78131. * @param meshAttributeArray The vertex attribute data
  78132. * @param byteOffset The offset to the binary data
  78133. * @param binaryWriter The binary data for the glTF file
  78134. * @param convertToRightHandedSystem Converts the values to right-handed
  78135. */
  78136. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78137. /**
  78138. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78139. * clock-wise during export to glTF
  78140. * @param submesh BabylonJS submesh
  78141. * @param primitiveMode Primitive mode of the mesh
  78142. * @param sideOrientation the winding order of the submesh
  78143. * @param vertexBufferKind The type of vertex attribute
  78144. * @param meshAttributeArray The vertex attribute data
  78145. * @param byteOffset The offset to the binary data
  78146. * @param binaryWriter The binary data for the glTF file
  78147. * @param convertToRightHandedSystem Converts the values to right-handed
  78148. */
  78149. private reorderTriangleFillMode;
  78150. /**
  78151. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78152. * clock-wise during export to glTF
  78153. * @param submesh BabylonJS submesh
  78154. * @param primitiveMode Primitive mode of the mesh
  78155. * @param sideOrientation the winding order of the submesh
  78156. * @param vertexBufferKind The type of vertex attribute
  78157. * @param meshAttributeArray The vertex attribute data
  78158. * @param byteOffset The offset to the binary data
  78159. * @param binaryWriter The binary data for the glTF file
  78160. * @param convertToRightHandedSystem Converts the values to right-handed
  78161. */
  78162. private reorderTriangleStripDrawMode;
  78163. /**
  78164. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78165. * clock-wise during export to glTF
  78166. * @param submesh BabylonJS submesh
  78167. * @param primitiveMode Primitive mode of the mesh
  78168. * @param sideOrientation the winding order of the submesh
  78169. * @param vertexBufferKind The type of vertex attribute
  78170. * @param meshAttributeArray The vertex attribute data
  78171. * @param byteOffset The offset to the binary data
  78172. * @param binaryWriter The binary data for the glTF file
  78173. * @param convertToRightHandedSystem Converts the values to right-handed
  78174. */
  78175. private reorderTriangleFanMode;
  78176. /**
  78177. * Writes the vertex attribute data to binary
  78178. * @param vertices The vertices to write to the binary writer
  78179. * @param byteOffset The offset into the binary writer to overwrite binary data
  78180. * @param vertexAttributeKind The vertex attribute type
  78181. * @param meshAttributeArray The vertex attribute data
  78182. * @param binaryWriter The writer containing the binary data
  78183. * @param convertToRightHandedSystem Converts the values to right-handed
  78184. */
  78185. private writeVertexAttributeData;
  78186. /**
  78187. * Writes mesh attribute data to a data buffer
  78188. * Returns the bytelength of the data
  78189. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78190. * @param meshAttributeArray Array containing the attribute data
  78191. * @param binaryWriter The buffer to write the binary data to
  78192. * @param indices Used to specify the order of the vertex data
  78193. * @param convertToRightHandedSystem Converts the values to right-handed
  78194. */
  78195. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78196. /**
  78197. * Generates glTF json data
  78198. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78199. * @param glTFPrefix Text to use when prefixing a glTF file
  78200. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78201. * @returns json data as string
  78202. */
  78203. private generateJSON;
  78204. /**
  78205. * Generates data for .gltf and .bin files based on the glTF prefix string
  78206. * @param glTFPrefix Text to use when prefixing a glTF file
  78207. * @param dispose Dispose the exporter
  78208. * @returns GLTFData with glTF file data
  78209. */
  78210. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78211. /**
  78212. * Creates a binary buffer for glTF
  78213. * @returns array buffer for binary data
  78214. */
  78215. private _generateBinaryAsync;
  78216. /**
  78217. * Pads the number to a multiple of 4
  78218. * @param num number to pad
  78219. * @returns padded number
  78220. */
  78221. private _getPadding;
  78222. /**
  78223. * @hidden
  78224. */
  78225. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78226. /**
  78227. * Sets the TRS for each node
  78228. * @param node glTF Node for storing the transformation data
  78229. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78230. * @param convertToRightHandedSystem Converts the values to right-handed
  78231. */
  78232. private setNodeTransformation;
  78233. private getVertexBufferFromMesh;
  78234. /**
  78235. * Creates a bufferview based on the vertices type for the Babylon mesh
  78236. * @param kind Indicates the type of vertices data
  78237. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78238. * @param binaryWriter The buffer to write the bufferview data to
  78239. * @param convertToRightHandedSystem Converts the values to right-handed
  78240. */
  78241. private createBufferViewKind;
  78242. /**
  78243. * The primitive mode of the Babylon mesh
  78244. * @param babylonMesh The BabylonJS mesh
  78245. */
  78246. private getMeshPrimitiveMode;
  78247. /**
  78248. * Sets the primitive mode of the glTF mesh primitive
  78249. * @param meshPrimitive glTF mesh primitive
  78250. * @param primitiveMode The primitive mode
  78251. */
  78252. private setPrimitiveMode;
  78253. /**
  78254. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78255. * @param meshPrimitive glTF mesh primitive
  78256. * @param attributeKind vertex attribute
  78257. * @returns boolean specifying if uv coordinates are present
  78258. */
  78259. private setAttributeKind;
  78260. /**
  78261. * Sets data for the primitive attributes of each submesh
  78262. * @param mesh glTF Mesh object to store the primitive attribute information
  78263. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78264. * @param binaryWriter Buffer to write the attribute data to
  78265. * @param convertToRightHandedSystem Converts the values to right-handed
  78266. */
  78267. private setPrimitiveAttributesAsync;
  78268. /**
  78269. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78270. * @param node The node to check
  78271. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78272. */
  78273. private isBabylonCoordinateSystemConvertingNode;
  78274. /**
  78275. * Creates a glTF scene based on the array of meshes
  78276. * Returns the the total byte offset
  78277. * @param babylonScene Babylon scene to get the mesh data from
  78278. * @param binaryWriter Buffer to write binary data to
  78279. */
  78280. private createSceneAsync;
  78281. /**
  78282. * Creates a mapping of Node unique id to node index and handles animations
  78283. * @param babylonScene Babylon Scene
  78284. * @param nodes Babylon transform nodes
  78285. * @param binaryWriter Buffer to write binary data to
  78286. * @returns Node mapping of unique id to index
  78287. */
  78288. private createNodeMapAndAnimationsAsync;
  78289. /**
  78290. * Creates a glTF node from a Babylon mesh
  78291. * @param babylonMesh Source Babylon mesh
  78292. * @param binaryWriter Buffer for storing geometry data
  78293. * @param convertToRightHandedSystem Converts the values to right-handed
  78294. * @param nodeMap Node mapping of unique id to glTF node index
  78295. * @returns glTF node
  78296. */
  78297. private createNodeAsync;
  78298. }
  78299. /**
  78300. * @hidden
  78301. *
  78302. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78303. */
  78304. export class _BinaryWriter {
  78305. /**
  78306. * Array buffer which stores all binary data
  78307. */
  78308. private _arrayBuffer;
  78309. /**
  78310. * View of the array buffer
  78311. */
  78312. private _dataView;
  78313. /**
  78314. * byte offset of data in array buffer
  78315. */
  78316. private _byteOffset;
  78317. /**
  78318. * Initialize binary writer with an initial byte length
  78319. * @param byteLength Initial byte length of the array buffer
  78320. */
  78321. constructor(byteLength: number);
  78322. /**
  78323. * Resize the array buffer to the specified byte length
  78324. * @param byteLength
  78325. */
  78326. private resizeBuffer;
  78327. /**
  78328. * Get an array buffer with the length of the byte offset
  78329. * @returns ArrayBuffer resized to the byte offset
  78330. */
  78331. getArrayBuffer(): ArrayBuffer;
  78332. /**
  78333. * Get the byte offset of the array buffer
  78334. * @returns byte offset
  78335. */
  78336. getByteOffset(): number;
  78337. /**
  78338. * Stores an UInt8 in the array buffer
  78339. * @param entry
  78340. * @param byteOffset If defined, specifies where to set the value as an offset.
  78341. */
  78342. setUInt8(entry: number, byteOffset?: number): void;
  78343. /**
  78344. * Gets an UInt32 in the array buffer
  78345. * @param entry
  78346. * @param byteOffset If defined, specifies where to set the value as an offset.
  78347. */
  78348. getUInt32(byteOffset: number): number;
  78349. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78350. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78351. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78352. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78353. /**
  78354. * Stores a Float32 in the array buffer
  78355. * @param entry
  78356. */
  78357. setFloat32(entry: number, byteOffset?: number): void;
  78358. /**
  78359. * Stores an UInt32 in the array buffer
  78360. * @param entry
  78361. * @param byteOffset If defined, specifies where to set the value as an offset.
  78362. */
  78363. setUInt32(entry: number, byteOffset?: number): void;
  78364. }
  78365. }
  78366. declare module BABYLON.GLTF2.Exporter {
  78367. /**
  78368. * @hidden
  78369. * Interface to store animation data.
  78370. */
  78371. export interface _IAnimationData {
  78372. /**
  78373. * Keyframe data.
  78374. */
  78375. inputs: number[];
  78376. /**
  78377. * Value data.
  78378. */
  78379. outputs: number[][];
  78380. /**
  78381. * Animation interpolation data.
  78382. */
  78383. samplerInterpolation: AnimationSamplerInterpolation;
  78384. /**
  78385. * Minimum keyframe value.
  78386. */
  78387. inputsMin: number;
  78388. /**
  78389. * Maximum keyframe value.
  78390. */
  78391. inputsMax: number;
  78392. }
  78393. /**
  78394. * @hidden
  78395. */
  78396. export interface _IAnimationInfo {
  78397. /**
  78398. * The target channel for the animation
  78399. */
  78400. animationChannelTargetPath: AnimationChannelTargetPath;
  78401. /**
  78402. * The glTF accessor type for the data.
  78403. */
  78404. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78405. /**
  78406. * Specifies if quaternions should be used.
  78407. */
  78408. useQuaternion: boolean;
  78409. }
  78410. /**
  78411. * @hidden
  78412. * Utility class for generating glTF animation data from BabylonJS.
  78413. */
  78414. export class _GLTFAnimation {
  78415. /**
  78416. * @ignore
  78417. *
  78418. * Creates glTF channel animation from BabylonJS animation.
  78419. * @param babylonTransformNode - BabylonJS mesh.
  78420. * @param animation - animation.
  78421. * @param animationChannelTargetPath - The target animation channel.
  78422. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78423. * @param useQuaternion - Specifies if quaternions are used.
  78424. * @returns nullable IAnimationData
  78425. */
  78426. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78427. private static _DeduceAnimationInfo;
  78428. /**
  78429. * @ignore
  78430. * Create node animations from the transform node animations
  78431. * @param babylonNode
  78432. * @param runtimeGLTFAnimation
  78433. * @param idleGLTFAnimations
  78434. * @param nodeMap
  78435. * @param nodes
  78436. * @param binaryWriter
  78437. * @param bufferViews
  78438. * @param accessors
  78439. * @param convertToRightHandedSystem
  78440. * @param animationSampleRate
  78441. */
  78442. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78443. [key: number]: number;
  78444. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78445. /**
  78446. * @ignore
  78447. * Create node animations from the animation groups
  78448. * @param babylonScene
  78449. * @param glTFAnimations
  78450. * @param nodeMap
  78451. * @param nodes
  78452. * @param binaryWriter
  78453. * @param bufferViews
  78454. * @param accessors
  78455. * @param convertToRightHandedSystemMap
  78456. * @param animationSampleRate
  78457. */
  78458. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78459. [key: number]: number;
  78460. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78461. [nodeId: number]: boolean;
  78462. }, animationSampleRate: number): void;
  78463. private static AddAnimation;
  78464. /**
  78465. * Create a baked animation
  78466. * @param babylonTransformNode BabylonJS mesh
  78467. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78468. * @param animationChannelTargetPath animation target channel
  78469. * @param minFrame minimum animation frame
  78470. * @param maxFrame maximum animation frame
  78471. * @param fps frames per second of the animation
  78472. * @param inputs input key frames of the animation
  78473. * @param outputs output key frame data of the animation
  78474. * @param convertToRightHandedSystem converts the values to right-handed
  78475. * @param useQuaternion specifies if quaternions should be used
  78476. */
  78477. private static _CreateBakedAnimation;
  78478. private static _ConvertFactorToVector3OrQuaternion;
  78479. private static _SetInterpolatedValue;
  78480. /**
  78481. * Creates linear animation from the animation key frames
  78482. * @param babylonTransformNode BabylonJS mesh
  78483. * @param animation BabylonJS animation
  78484. * @param animationChannelTargetPath The target animation channel
  78485. * @param frameDelta The difference between the last and first frame of the animation
  78486. * @param inputs Array to store the key frame times
  78487. * @param outputs Array to store the key frame data
  78488. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78489. * @param useQuaternion Specifies if quaternions are used in the animation
  78490. */
  78491. private static _CreateLinearOrStepAnimation;
  78492. /**
  78493. * Creates cubic spline animation from the animation key frames
  78494. * @param babylonTransformNode BabylonJS mesh
  78495. * @param animation BabylonJS animation
  78496. * @param animationChannelTargetPath The target animation channel
  78497. * @param frameDelta The difference between the last and first frame of the animation
  78498. * @param inputs Array to store the key frame times
  78499. * @param outputs Array to store the key frame data
  78500. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78501. * @param useQuaternion Specifies if quaternions are used in the animation
  78502. */
  78503. private static _CreateCubicSplineAnimation;
  78504. private static _GetBasePositionRotationOrScale;
  78505. /**
  78506. * Adds a key frame value
  78507. * @param keyFrame
  78508. * @param animation
  78509. * @param outputs
  78510. * @param animationChannelTargetPath
  78511. * @param basePositionRotationOrScale
  78512. * @param convertToRightHandedSystem
  78513. * @param useQuaternion
  78514. */
  78515. private static _AddKeyframeValue;
  78516. /**
  78517. * Determine the interpolation based on the key frames
  78518. * @param keyFrames
  78519. * @param animationChannelTargetPath
  78520. * @param useQuaternion
  78521. */
  78522. private static _DeduceInterpolation;
  78523. /**
  78524. * Adds an input tangent or output tangent to the output data
  78525. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78526. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78527. * @param outputs The animation data by keyframe
  78528. * @param animationChannelTargetPath The target animation channel
  78529. * @param interpolation The interpolation type
  78530. * @param keyFrame The key frame with the animation data
  78531. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78532. * @param useQuaternion Specifies if quaternions are used
  78533. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78534. */
  78535. private static AddSplineTangent;
  78536. /**
  78537. * Get the minimum and maximum key frames' frame values
  78538. * @param keyFrames animation key frames
  78539. * @returns the minimum and maximum key frame value
  78540. */
  78541. private static calculateMinMaxKeyFrames;
  78542. }
  78543. }
  78544. declare module BABYLON.GLTF2.Exporter {
  78545. /** @hidden */
  78546. export var textureTransformPixelShader: {
  78547. name: string;
  78548. shader: string;
  78549. };
  78550. }
  78551. declare module BABYLON.GLTF2.Exporter.Extensions {
  78552. /**
  78553. * @hidden
  78554. */
  78555. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78556. private _recordedTextures;
  78557. /** Name of this extension */
  78558. readonly name: string;
  78559. /** Defines whether this extension is enabled */
  78560. enabled: boolean;
  78561. /** Defines whether this extension is required */
  78562. required: boolean;
  78563. /** Reference to the glTF exporter */
  78564. private _wasUsed;
  78565. constructor(exporter: _Exporter);
  78566. dispose(): void;
  78567. /** @hidden */
  78568. get wasUsed(): boolean;
  78569. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78570. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78571. /**
  78572. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78573. * @param babylonTexture
  78574. * @param offset
  78575. * @param rotation
  78576. * @param scale
  78577. * @param scene
  78578. */
  78579. private _textureTransformTextureAsync;
  78580. }
  78581. }
  78582. declare module BABYLON.GLTF2.Exporter.Extensions {
  78583. /**
  78584. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78585. */
  78586. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78587. /** The name of this extension. */
  78588. readonly name: string;
  78589. /** Defines whether this extension is enabled. */
  78590. enabled: boolean;
  78591. /** Defines whether this extension is required */
  78592. required: boolean;
  78593. /** Reference to the glTF exporter */
  78594. private _exporter;
  78595. private _lights;
  78596. /** @hidden */
  78597. constructor(exporter: _Exporter);
  78598. /** @hidden */
  78599. dispose(): void;
  78600. /** @hidden */
  78601. get wasUsed(): boolean;
  78602. /** @hidden */
  78603. onExporting(): void;
  78604. /**
  78605. * Define this method to modify the default behavior when exporting a node
  78606. * @param context The context when exporting the node
  78607. * @param node glTF node
  78608. * @param babylonNode BabylonJS node
  78609. * @param nodeMap Node mapping of unique id to glTF node index
  78610. * @returns nullable INode promise
  78611. */
  78612. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78613. [key: number]: number;
  78614. }): Promise<Nullable<INode>>;
  78615. }
  78616. }
  78617. declare module BABYLON.GLTF2.Exporter.Extensions {
  78618. /**
  78619. * @hidden
  78620. */
  78621. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78622. /** Name of this extension */
  78623. readonly name: string;
  78624. /** Defines whether this extension is enabled */
  78625. enabled: boolean;
  78626. /** Defines whether this extension is required */
  78627. required: boolean;
  78628. /** Reference to the glTF exporter */
  78629. private _textureInfos;
  78630. private _exportedTextures;
  78631. private _wasUsed;
  78632. constructor(exporter: _Exporter);
  78633. dispose(): void;
  78634. /** @hidden */
  78635. get wasUsed(): boolean;
  78636. private _getTextureIndex;
  78637. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78638. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78639. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78640. }
  78641. }
  78642. declare module BABYLON {
  78643. /**
  78644. * Class for generating STL data from a Babylon scene.
  78645. */
  78646. export class STLExport {
  78647. /**
  78648. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78649. * @param meshes list defines the mesh to serialize
  78650. * @param download triggers the automatic download of the file.
  78651. * @param fileName changes the downloads fileName.
  78652. * @param binary changes the STL to a binary type.
  78653. * @param isLittleEndian toggle for binary type exporter.
  78654. * @returns the STL as UTF8 string
  78655. */
  78656. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78657. }
  78658. }
  78659. declare module "babylonjs-gltf2interface" {
  78660. export = BABYLON.GLTF2;
  78661. }
  78662. /**
  78663. * Module for glTF 2.0 Interface
  78664. */
  78665. declare module BABYLON.GLTF2 {
  78666. /**
  78667. * The datatype of the components in the attribute
  78668. */
  78669. const enum AccessorComponentType {
  78670. /**
  78671. * Byte
  78672. */
  78673. BYTE = 5120,
  78674. /**
  78675. * Unsigned Byte
  78676. */
  78677. UNSIGNED_BYTE = 5121,
  78678. /**
  78679. * Short
  78680. */
  78681. SHORT = 5122,
  78682. /**
  78683. * Unsigned Short
  78684. */
  78685. UNSIGNED_SHORT = 5123,
  78686. /**
  78687. * Unsigned Int
  78688. */
  78689. UNSIGNED_INT = 5125,
  78690. /**
  78691. * Float
  78692. */
  78693. FLOAT = 5126,
  78694. }
  78695. /**
  78696. * Specifies if the attirbute is a scalar, vector, or matrix
  78697. */
  78698. const enum AccessorType {
  78699. /**
  78700. * Scalar
  78701. */
  78702. SCALAR = "SCALAR",
  78703. /**
  78704. * Vector2
  78705. */
  78706. VEC2 = "VEC2",
  78707. /**
  78708. * Vector3
  78709. */
  78710. VEC3 = "VEC3",
  78711. /**
  78712. * Vector4
  78713. */
  78714. VEC4 = "VEC4",
  78715. /**
  78716. * Matrix2x2
  78717. */
  78718. MAT2 = "MAT2",
  78719. /**
  78720. * Matrix3x3
  78721. */
  78722. MAT3 = "MAT3",
  78723. /**
  78724. * Matrix4x4
  78725. */
  78726. MAT4 = "MAT4",
  78727. }
  78728. /**
  78729. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78730. */
  78731. const enum AnimationChannelTargetPath {
  78732. /**
  78733. * Translation
  78734. */
  78735. TRANSLATION = "translation",
  78736. /**
  78737. * Rotation
  78738. */
  78739. ROTATION = "rotation",
  78740. /**
  78741. * Scale
  78742. */
  78743. SCALE = "scale",
  78744. /**
  78745. * Weights
  78746. */
  78747. WEIGHTS = "weights",
  78748. }
  78749. /**
  78750. * Interpolation algorithm
  78751. */
  78752. const enum AnimationSamplerInterpolation {
  78753. /**
  78754. * The animated values are linearly interpolated between keyframes
  78755. */
  78756. LINEAR = "LINEAR",
  78757. /**
  78758. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78759. */
  78760. STEP = "STEP",
  78761. /**
  78762. * The animation's interpolation is computed using a cubic spline with specified tangents
  78763. */
  78764. CUBICSPLINE = "CUBICSPLINE",
  78765. }
  78766. /**
  78767. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78768. */
  78769. const enum CameraType {
  78770. /**
  78771. * A perspective camera containing properties to create a perspective projection matrix
  78772. */
  78773. PERSPECTIVE = "perspective",
  78774. /**
  78775. * An orthographic camera containing properties to create an orthographic projection matrix
  78776. */
  78777. ORTHOGRAPHIC = "orthographic",
  78778. }
  78779. /**
  78780. * The mime-type of the image
  78781. */
  78782. const enum ImageMimeType {
  78783. /**
  78784. * JPEG Mime-type
  78785. */
  78786. JPEG = "image/jpeg",
  78787. /**
  78788. * PNG Mime-type
  78789. */
  78790. PNG = "image/png",
  78791. }
  78792. /**
  78793. * The alpha rendering mode of the material
  78794. */
  78795. const enum MaterialAlphaMode {
  78796. /**
  78797. * The alpha value is ignored and the rendered output is fully opaque
  78798. */
  78799. OPAQUE = "OPAQUE",
  78800. /**
  78801. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78802. */
  78803. MASK = "MASK",
  78804. /**
  78805. * 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)
  78806. */
  78807. BLEND = "BLEND",
  78808. }
  78809. /**
  78810. * The type of the primitives to render
  78811. */
  78812. const enum MeshPrimitiveMode {
  78813. /**
  78814. * Points
  78815. */
  78816. POINTS = 0,
  78817. /**
  78818. * Lines
  78819. */
  78820. LINES = 1,
  78821. /**
  78822. * Line Loop
  78823. */
  78824. LINE_LOOP = 2,
  78825. /**
  78826. * Line Strip
  78827. */
  78828. LINE_STRIP = 3,
  78829. /**
  78830. * Triangles
  78831. */
  78832. TRIANGLES = 4,
  78833. /**
  78834. * Triangle Strip
  78835. */
  78836. TRIANGLE_STRIP = 5,
  78837. /**
  78838. * Triangle Fan
  78839. */
  78840. TRIANGLE_FAN = 6,
  78841. }
  78842. /**
  78843. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78844. */
  78845. const enum TextureMagFilter {
  78846. /**
  78847. * Nearest
  78848. */
  78849. NEAREST = 9728,
  78850. /**
  78851. * Linear
  78852. */
  78853. LINEAR = 9729,
  78854. }
  78855. /**
  78856. * Minification filter. All valid values correspond to WebGL enums
  78857. */
  78858. const enum TextureMinFilter {
  78859. /**
  78860. * Nearest
  78861. */
  78862. NEAREST = 9728,
  78863. /**
  78864. * Linear
  78865. */
  78866. LINEAR = 9729,
  78867. /**
  78868. * Nearest Mip-Map Nearest
  78869. */
  78870. NEAREST_MIPMAP_NEAREST = 9984,
  78871. /**
  78872. * Linear Mipmap Nearest
  78873. */
  78874. LINEAR_MIPMAP_NEAREST = 9985,
  78875. /**
  78876. * Nearest Mipmap Linear
  78877. */
  78878. NEAREST_MIPMAP_LINEAR = 9986,
  78879. /**
  78880. * Linear Mipmap Linear
  78881. */
  78882. LINEAR_MIPMAP_LINEAR = 9987,
  78883. }
  78884. /**
  78885. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78886. */
  78887. const enum TextureWrapMode {
  78888. /**
  78889. * Clamp to Edge
  78890. */
  78891. CLAMP_TO_EDGE = 33071,
  78892. /**
  78893. * Mirrored Repeat
  78894. */
  78895. MIRRORED_REPEAT = 33648,
  78896. /**
  78897. * Repeat
  78898. */
  78899. REPEAT = 10497,
  78900. }
  78901. /**
  78902. * glTF Property
  78903. */
  78904. interface IProperty {
  78905. /**
  78906. * Dictionary object with extension-specific objects
  78907. */
  78908. extensions?: {
  78909. [key: string]: any;
  78910. };
  78911. /**
  78912. * Application-Specific data
  78913. */
  78914. extras?: any;
  78915. }
  78916. /**
  78917. * glTF Child of Root Property
  78918. */
  78919. interface IChildRootProperty extends IProperty {
  78920. /**
  78921. * The user-defined name of this object
  78922. */
  78923. name?: string;
  78924. }
  78925. /**
  78926. * Indices of those attributes that deviate from their initialization value
  78927. */
  78928. interface IAccessorSparseIndices extends IProperty {
  78929. /**
  78930. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78931. */
  78932. bufferView: number;
  78933. /**
  78934. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78935. */
  78936. byteOffset?: number;
  78937. /**
  78938. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78939. */
  78940. componentType: AccessorComponentType;
  78941. }
  78942. /**
  78943. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78944. */
  78945. interface IAccessorSparseValues extends IProperty {
  78946. /**
  78947. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78948. */
  78949. bufferView: number;
  78950. /**
  78951. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78952. */
  78953. byteOffset?: number;
  78954. }
  78955. /**
  78956. * Sparse storage of attributes that deviate from their initialization value
  78957. */
  78958. interface IAccessorSparse extends IProperty {
  78959. /**
  78960. * The number of attributes encoded in this sparse accessor
  78961. */
  78962. count: number;
  78963. /**
  78964. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78965. */
  78966. indices: IAccessorSparseIndices;
  78967. /**
  78968. * 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
  78969. */
  78970. values: IAccessorSparseValues;
  78971. }
  78972. /**
  78973. * 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
  78974. */
  78975. interface IAccessor extends IChildRootProperty {
  78976. /**
  78977. * The index of the bufferview
  78978. */
  78979. bufferView?: number;
  78980. /**
  78981. * The offset relative to the start of the bufferView in bytes
  78982. */
  78983. byteOffset?: number;
  78984. /**
  78985. * The datatype of components in the attribute
  78986. */
  78987. componentType: AccessorComponentType;
  78988. /**
  78989. * Specifies whether integer data values should be normalized
  78990. */
  78991. normalized?: boolean;
  78992. /**
  78993. * The number of attributes referenced by this accessor
  78994. */
  78995. count: number;
  78996. /**
  78997. * Specifies if the attribute is a scalar, vector, or matrix
  78998. */
  78999. type: AccessorType;
  79000. /**
  79001. * Maximum value of each component in this attribute
  79002. */
  79003. max?: number[];
  79004. /**
  79005. * Minimum value of each component in this attribute
  79006. */
  79007. min?: number[];
  79008. /**
  79009. * Sparse storage of attributes that deviate from their initialization value
  79010. */
  79011. sparse?: IAccessorSparse;
  79012. }
  79013. /**
  79014. * Targets an animation's sampler at a node's property
  79015. */
  79016. interface IAnimationChannel extends IProperty {
  79017. /**
  79018. * The index of a sampler in this animation used to compute the value for the target
  79019. */
  79020. sampler: number;
  79021. /**
  79022. * The index of the node and TRS property to target
  79023. */
  79024. target: IAnimationChannelTarget;
  79025. }
  79026. /**
  79027. * The index of the node and TRS property that an animation channel targets
  79028. */
  79029. interface IAnimationChannelTarget extends IProperty {
  79030. /**
  79031. * The index of the node to target
  79032. */
  79033. node: number;
  79034. /**
  79035. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79036. */
  79037. path: AnimationChannelTargetPath;
  79038. }
  79039. /**
  79040. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79041. */
  79042. interface IAnimationSampler extends IProperty {
  79043. /**
  79044. * The index of an accessor containing keyframe input values, e.g., time
  79045. */
  79046. input: number;
  79047. /**
  79048. * Interpolation algorithm
  79049. */
  79050. interpolation?: AnimationSamplerInterpolation;
  79051. /**
  79052. * The index of an accessor, containing keyframe output values
  79053. */
  79054. output: number;
  79055. }
  79056. /**
  79057. * A keyframe animation
  79058. */
  79059. interface IAnimation extends IChildRootProperty {
  79060. /**
  79061. * An array of channels, each of which targets an animation's sampler at a node's property
  79062. */
  79063. channels: IAnimationChannel[];
  79064. /**
  79065. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79066. */
  79067. samplers: IAnimationSampler[];
  79068. }
  79069. /**
  79070. * Metadata about the glTF asset
  79071. */
  79072. interface IAsset extends IChildRootProperty {
  79073. /**
  79074. * A copyright message suitable for display to credit the content creator
  79075. */
  79076. copyright?: string;
  79077. /**
  79078. * Tool that generated this glTF model. Useful for debugging
  79079. */
  79080. generator?: string;
  79081. /**
  79082. * The glTF version that this asset targets
  79083. */
  79084. version: string;
  79085. /**
  79086. * The minimum glTF version that this asset targets
  79087. */
  79088. minVersion?: string;
  79089. }
  79090. /**
  79091. * A buffer points to binary geometry, animation, or skins
  79092. */
  79093. interface IBuffer extends IChildRootProperty {
  79094. /**
  79095. * 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
  79096. */
  79097. uri?: string;
  79098. /**
  79099. * The length of the buffer in bytes
  79100. */
  79101. byteLength: number;
  79102. }
  79103. /**
  79104. * A view into a buffer generally representing a subset of the buffer
  79105. */
  79106. interface IBufferView extends IChildRootProperty {
  79107. /**
  79108. * The index of the buffer
  79109. */
  79110. buffer: number;
  79111. /**
  79112. * The offset into the buffer in bytes
  79113. */
  79114. byteOffset?: number;
  79115. /**
  79116. * The lenth of the bufferView in bytes
  79117. */
  79118. byteLength: number;
  79119. /**
  79120. * The stride, in bytes
  79121. */
  79122. byteStride?: number;
  79123. }
  79124. /**
  79125. * An orthographic camera containing properties to create an orthographic projection matrix
  79126. */
  79127. interface ICameraOrthographic extends IProperty {
  79128. /**
  79129. * The floating-point horizontal magnification of the view. Must not be zero
  79130. */
  79131. xmag: number;
  79132. /**
  79133. * The floating-point vertical magnification of the view. Must not be zero
  79134. */
  79135. ymag: number;
  79136. /**
  79137. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79138. */
  79139. zfar: number;
  79140. /**
  79141. * The floating-point distance to the near clipping plane
  79142. */
  79143. znear: number;
  79144. }
  79145. /**
  79146. * A perspective camera containing properties to create a perspective projection matrix
  79147. */
  79148. interface ICameraPerspective extends IProperty {
  79149. /**
  79150. * The floating-point aspect ratio of the field of view
  79151. */
  79152. aspectRatio?: number;
  79153. /**
  79154. * The floating-point vertical field of view in radians
  79155. */
  79156. yfov: number;
  79157. /**
  79158. * The floating-point distance to the far clipping plane
  79159. */
  79160. zfar?: number;
  79161. /**
  79162. * The floating-point distance to the near clipping plane
  79163. */
  79164. znear: number;
  79165. }
  79166. /**
  79167. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79168. */
  79169. interface ICamera extends IChildRootProperty {
  79170. /**
  79171. * An orthographic camera containing properties to create an orthographic projection matrix
  79172. */
  79173. orthographic?: ICameraOrthographic;
  79174. /**
  79175. * A perspective camera containing properties to create a perspective projection matrix
  79176. */
  79177. perspective?: ICameraPerspective;
  79178. /**
  79179. * Specifies if the camera uses a perspective or orthographic projection
  79180. */
  79181. type: CameraType;
  79182. }
  79183. /**
  79184. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79185. */
  79186. interface IImage extends IChildRootProperty {
  79187. /**
  79188. * 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
  79189. */
  79190. uri?: string;
  79191. /**
  79192. * The image's MIME type
  79193. */
  79194. mimeType?: ImageMimeType;
  79195. /**
  79196. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79197. */
  79198. bufferView?: number;
  79199. }
  79200. /**
  79201. * Material Normal Texture Info
  79202. */
  79203. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79204. /**
  79205. * The scalar multiplier applied to each normal vector of the normal texture
  79206. */
  79207. scale?: number;
  79208. }
  79209. /**
  79210. * Material Occlusion Texture Info
  79211. */
  79212. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79213. /**
  79214. * A scalar multiplier controlling the amount of occlusion applied
  79215. */
  79216. strength?: number;
  79217. }
  79218. /**
  79219. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79220. */
  79221. interface IMaterialPbrMetallicRoughness {
  79222. /**
  79223. * The material's base color factor
  79224. */
  79225. baseColorFactor?: number[];
  79226. /**
  79227. * The base color texture
  79228. */
  79229. baseColorTexture?: ITextureInfo;
  79230. /**
  79231. * The metalness of the material
  79232. */
  79233. metallicFactor?: number;
  79234. /**
  79235. * The roughness of the material
  79236. */
  79237. roughnessFactor?: number;
  79238. /**
  79239. * The metallic-roughness texture
  79240. */
  79241. metallicRoughnessTexture?: ITextureInfo;
  79242. }
  79243. /**
  79244. * The material appearance of a primitive
  79245. */
  79246. interface IMaterial extends IChildRootProperty {
  79247. /**
  79248. * 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
  79249. */
  79250. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79251. /**
  79252. * The normal map texture
  79253. */
  79254. normalTexture?: IMaterialNormalTextureInfo;
  79255. /**
  79256. * The occlusion map texture
  79257. */
  79258. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79259. /**
  79260. * The emissive map texture
  79261. */
  79262. emissiveTexture?: ITextureInfo;
  79263. /**
  79264. * 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
  79265. */
  79266. emissiveFactor?: number[];
  79267. /**
  79268. * The alpha rendering mode of the material
  79269. */
  79270. alphaMode?: MaterialAlphaMode;
  79271. /**
  79272. * The alpha cutoff value of the material
  79273. */
  79274. alphaCutoff?: number;
  79275. /**
  79276. * Specifies whether the material is double sided
  79277. */
  79278. doubleSided?: boolean;
  79279. }
  79280. /**
  79281. * Geometry to be rendered with the given material
  79282. */
  79283. interface IMeshPrimitive extends IProperty {
  79284. /**
  79285. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79286. */
  79287. attributes: {
  79288. [name: string]: number;
  79289. };
  79290. /**
  79291. * The index of the accessor that contains the indices
  79292. */
  79293. indices?: number;
  79294. /**
  79295. * The index of the material to apply to this primitive when rendering
  79296. */
  79297. material?: number;
  79298. /**
  79299. * The type of primitives to render. All valid values correspond to WebGL enums
  79300. */
  79301. mode?: MeshPrimitiveMode;
  79302. /**
  79303. * 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
  79304. */
  79305. targets?: {
  79306. [name: string]: number;
  79307. }[];
  79308. }
  79309. /**
  79310. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79311. */
  79312. interface IMesh extends IChildRootProperty {
  79313. /**
  79314. * An array of primitives, each defining geometry to be rendered with a material
  79315. */
  79316. primitives: IMeshPrimitive[];
  79317. /**
  79318. * Array of weights to be applied to the Morph Targets
  79319. */
  79320. weights?: number[];
  79321. }
  79322. /**
  79323. * A node in the node hierarchy
  79324. */
  79325. interface INode extends IChildRootProperty {
  79326. /**
  79327. * The index of the camera referenced by this node
  79328. */
  79329. camera?: number;
  79330. /**
  79331. * The indices of this node's children
  79332. */
  79333. children?: number[];
  79334. /**
  79335. * The index of the skin referenced by this node
  79336. */
  79337. skin?: number;
  79338. /**
  79339. * A floating-point 4x4 transformation matrix stored in column-major order
  79340. */
  79341. matrix?: number[];
  79342. /**
  79343. * The index of the mesh in this node
  79344. */
  79345. mesh?: number;
  79346. /**
  79347. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79348. */
  79349. rotation?: number[];
  79350. /**
  79351. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79352. */
  79353. scale?: number[];
  79354. /**
  79355. * The node's translation along the x, y, and z axes
  79356. */
  79357. translation?: number[];
  79358. /**
  79359. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79360. */
  79361. weights?: number[];
  79362. }
  79363. /**
  79364. * Texture sampler properties for filtering and wrapping modes
  79365. */
  79366. interface ISampler extends IChildRootProperty {
  79367. /**
  79368. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79369. */
  79370. magFilter?: TextureMagFilter;
  79371. /**
  79372. * Minification filter. All valid values correspond to WebGL enums
  79373. */
  79374. minFilter?: TextureMinFilter;
  79375. /**
  79376. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79377. */
  79378. wrapS?: TextureWrapMode;
  79379. /**
  79380. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79381. */
  79382. wrapT?: TextureWrapMode;
  79383. }
  79384. /**
  79385. * The root nodes of a scene
  79386. */
  79387. interface IScene extends IChildRootProperty {
  79388. /**
  79389. * The indices of each root node
  79390. */
  79391. nodes: number[];
  79392. }
  79393. /**
  79394. * Joints and matrices defining a skin
  79395. */
  79396. interface ISkin extends IChildRootProperty {
  79397. /**
  79398. * 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
  79399. */
  79400. inverseBindMatrices?: number;
  79401. /**
  79402. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79403. */
  79404. skeleton?: number;
  79405. /**
  79406. * 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)
  79407. */
  79408. joints: number[];
  79409. }
  79410. /**
  79411. * A texture and its sampler
  79412. */
  79413. interface ITexture extends IChildRootProperty {
  79414. /**
  79415. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79416. */
  79417. sampler?: number;
  79418. /**
  79419. * The index of the image used by this texture
  79420. */
  79421. source: number;
  79422. }
  79423. /**
  79424. * Reference to a texture
  79425. */
  79426. interface ITextureInfo extends IProperty {
  79427. /**
  79428. * The index of the texture
  79429. */
  79430. index: number;
  79431. /**
  79432. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79433. */
  79434. texCoord?: number;
  79435. }
  79436. /**
  79437. * The root object for a glTF asset
  79438. */
  79439. interface IGLTF extends IProperty {
  79440. /**
  79441. * An array of accessors. An accessor is a typed view into a bufferView
  79442. */
  79443. accessors?: IAccessor[];
  79444. /**
  79445. * An array of keyframe animations
  79446. */
  79447. animations?: IAnimation[];
  79448. /**
  79449. * Metadata about the glTF asset
  79450. */
  79451. asset: IAsset;
  79452. /**
  79453. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79454. */
  79455. buffers?: IBuffer[];
  79456. /**
  79457. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79458. */
  79459. bufferViews?: IBufferView[];
  79460. /**
  79461. * An array of cameras
  79462. */
  79463. cameras?: ICamera[];
  79464. /**
  79465. * Names of glTF extensions used somewhere in this asset
  79466. */
  79467. extensionsUsed?: string[];
  79468. /**
  79469. * Names of glTF extensions required to properly load this asset
  79470. */
  79471. extensionsRequired?: string[];
  79472. /**
  79473. * An array of images. An image defines data used to create a texture
  79474. */
  79475. images?: IImage[];
  79476. /**
  79477. * An array of materials. A material defines the appearance of a primitive
  79478. */
  79479. materials?: IMaterial[];
  79480. /**
  79481. * An array of meshes. A mesh is a set of primitives to be rendered
  79482. */
  79483. meshes?: IMesh[];
  79484. /**
  79485. * An array of nodes
  79486. */
  79487. nodes?: INode[];
  79488. /**
  79489. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79490. */
  79491. samplers?: ISampler[];
  79492. /**
  79493. * The index of the default scene
  79494. */
  79495. scene?: number;
  79496. /**
  79497. * An array of scenes
  79498. */
  79499. scenes?: IScene[];
  79500. /**
  79501. * An array of skins. A skin is defined by joints and matrices
  79502. */
  79503. skins?: ISkin[];
  79504. /**
  79505. * An array of textures
  79506. */
  79507. textures?: ITexture[];
  79508. }
  79509. /**
  79510. * The glTF validation results
  79511. * @ignore
  79512. */
  79513. interface IGLTFValidationResults {
  79514. info: {
  79515. generator: string;
  79516. hasAnimations: boolean;
  79517. hasDefaultScene: boolean;
  79518. hasMaterials: boolean;
  79519. hasMorphTargets: boolean;
  79520. hasSkins: boolean;
  79521. hasTextures: boolean;
  79522. maxAttributesUsed: number;
  79523. primitivesCount: number
  79524. };
  79525. issues: {
  79526. messages: Array<string>;
  79527. numErrors: number;
  79528. numHints: number;
  79529. numInfos: number;
  79530. numWarnings: number;
  79531. truncated: boolean
  79532. };
  79533. mimeType: string;
  79534. uri: string;
  79535. validatedAt: string;
  79536. validatorVersion: string;
  79537. }
  79538. /**
  79539. * The glTF validation options
  79540. */
  79541. interface IGLTFValidationOptions {
  79542. /** Uri to use */
  79543. uri?: string;
  79544. /** Function used to load external resources */
  79545. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79546. /** Boolean indicating that we need to validate accessor data */
  79547. validateAccessorData?: boolean;
  79548. /** max number of issues allowed */
  79549. maxIssues?: number;
  79550. /** Ignored issues */
  79551. ignoredIssues?: Array<string>;
  79552. /** Value to override severy settings */
  79553. severityOverrides?: Object;
  79554. }
  79555. /**
  79556. * The glTF validator object
  79557. * @ignore
  79558. */
  79559. interface IGLTFValidator {
  79560. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79561. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79562. }
  79563. }
  79564. declare module BABYLON {
  79565. /** @hidden */
  79566. export var cellPixelShader: {
  79567. name: string;
  79568. shader: string;
  79569. };
  79570. }
  79571. declare module BABYLON {
  79572. /** @hidden */
  79573. export var cellVertexShader: {
  79574. name: string;
  79575. shader: string;
  79576. };
  79577. }
  79578. declare module BABYLON {
  79579. export class CellMaterial extends BABYLON.PushMaterial {
  79580. private _diffuseTexture;
  79581. diffuseTexture: BABYLON.BaseTexture;
  79582. diffuseColor: BABYLON.Color3;
  79583. _computeHighLevel: boolean;
  79584. computeHighLevel: boolean;
  79585. private _disableLighting;
  79586. disableLighting: boolean;
  79587. private _maxSimultaneousLights;
  79588. maxSimultaneousLights: number;
  79589. private _renderId;
  79590. constructor(name: string, scene: BABYLON.Scene);
  79591. needAlphaBlending(): boolean;
  79592. needAlphaTesting(): boolean;
  79593. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79594. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79595. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79596. getAnimatables(): BABYLON.IAnimatable[];
  79597. getActiveTextures(): BABYLON.BaseTexture[];
  79598. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79599. dispose(forceDisposeEffect?: boolean): void;
  79600. getClassName(): string;
  79601. clone(name: string): CellMaterial;
  79602. serialize(): any;
  79603. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79604. }
  79605. }
  79606. declare module BABYLON {
  79607. export class CustomShaderStructure {
  79608. FragmentStore: string;
  79609. VertexStore: string;
  79610. constructor();
  79611. }
  79612. export class ShaderSpecialParts {
  79613. constructor();
  79614. Fragment_Begin: string;
  79615. Fragment_Definitions: string;
  79616. Fragment_MainBegin: string;
  79617. Fragment_Custom_Diffuse: string;
  79618. Fragment_Before_Lights: string;
  79619. Fragment_Before_Fog: string;
  79620. Fragment_Custom_Alpha: string;
  79621. Fragment_Before_FragColor: string;
  79622. Vertex_Begin: string;
  79623. Vertex_Definitions: string;
  79624. Vertex_MainBegin: string;
  79625. Vertex_Before_PositionUpdated: string;
  79626. Vertex_Before_NormalUpdated: string;
  79627. Vertex_MainEnd: string;
  79628. }
  79629. export class CustomMaterial extends BABYLON.StandardMaterial {
  79630. static ShaderIndexer: number;
  79631. CustomParts: ShaderSpecialParts;
  79632. _isCreatedShader: boolean;
  79633. _createdShaderName: string;
  79634. _customUniform: string[];
  79635. _newUniforms: string[];
  79636. _newUniformInstances: any[];
  79637. _newSamplerInstances: BABYLON.Texture[];
  79638. _customAttributes: string[];
  79639. FragmentShader: string;
  79640. VertexShader: string;
  79641. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79642. ReviewUniform(name: string, arr: string[]): string[];
  79643. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines, attributes?: string[]): string;
  79644. constructor(name: string, scene: BABYLON.Scene);
  79645. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79646. AddAttribute(name: string): CustomMaterial;
  79647. Fragment_Begin(shaderPart: string): CustomMaterial;
  79648. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79649. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79650. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79651. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79652. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79653. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79654. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79655. Vertex_Begin(shaderPart: string): CustomMaterial;
  79656. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79657. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79658. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79659. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79660. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79661. }
  79662. }
  79663. declare module BABYLON {
  79664. export class ShaderAlebdoParts {
  79665. constructor();
  79666. Fragment_Begin: string;
  79667. Fragment_Definitions: string;
  79668. Fragment_MainBegin: string;
  79669. Fragment_Custom_Albedo: string;
  79670. Fragment_Before_Lights: string;
  79671. Fragment_Custom_MetallicRoughness: string;
  79672. Fragment_Custom_MicroSurface: string;
  79673. Fragment_Before_Fog: string;
  79674. Fragment_Custom_Alpha: string;
  79675. Fragment_Before_FragColor: string;
  79676. Vertex_Begin: string;
  79677. Vertex_Definitions: string;
  79678. Vertex_MainBegin: string;
  79679. Vertex_Before_PositionUpdated: string;
  79680. Vertex_Before_NormalUpdated: string;
  79681. Vertex_MainEnd: string;
  79682. }
  79683. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79684. static ShaderIndexer: number;
  79685. CustomParts: ShaderAlebdoParts;
  79686. _isCreatedShader: boolean;
  79687. _createdShaderName: string;
  79688. _customUniform: string[];
  79689. _newUniforms: string[];
  79690. _newUniformInstances: any[];
  79691. _newSamplerInstances: BABYLON.Texture[];
  79692. _customAttributes: string[];
  79693. FragmentShader: string;
  79694. VertexShader: string;
  79695. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79696. ReviewUniform(name: string, arr: string[]): string[];
  79697. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines, attributes?: string[]): string;
  79698. constructor(name: string, scene: BABYLON.Scene);
  79699. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79700. AddAttribute(name: string): PBRCustomMaterial;
  79701. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79702. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79703. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79704. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79705. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79706. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79707. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79708. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79709. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79710. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79711. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79712. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79713. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79714. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79715. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79716. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79717. }
  79718. }
  79719. declare module BABYLON {
  79720. /** @hidden */
  79721. export var firePixelShader: {
  79722. name: string;
  79723. shader: string;
  79724. };
  79725. }
  79726. declare module BABYLON {
  79727. /** @hidden */
  79728. export var fireVertexShader: {
  79729. name: string;
  79730. shader: string;
  79731. };
  79732. }
  79733. declare module BABYLON {
  79734. export class FireMaterial extends BABYLON.PushMaterial {
  79735. private _diffuseTexture;
  79736. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79737. private _distortionTexture;
  79738. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79739. private _opacityTexture;
  79740. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79741. diffuseColor: BABYLON.Color3;
  79742. speed: number;
  79743. private _scaledDiffuse;
  79744. private _renderId;
  79745. private _lastTime;
  79746. constructor(name: string, scene: BABYLON.Scene);
  79747. needAlphaBlending(): boolean;
  79748. needAlphaTesting(): boolean;
  79749. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79750. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79751. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79752. getAnimatables(): BABYLON.IAnimatable[];
  79753. getActiveTextures(): BABYLON.BaseTexture[];
  79754. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79755. getClassName(): string;
  79756. dispose(forceDisposeEffect?: boolean): void;
  79757. clone(name: string): FireMaterial;
  79758. serialize(): any;
  79759. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79760. }
  79761. }
  79762. declare module BABYLON {
  79763. /** @hidden */
  79764. export var furPixelShader: {
  79765. name: string;
  79766. shader: string;
  79767. };
  79768. }
  79769. declare module BABYLON {
  79770. /** @hidden */
  79771. export var furVertexShader: {
  79772. name: string;
  79773. shader: string;
  79774. };
  79775. }
  79776. declare module BABYLON {
  79777. export class FurMaterial extends BABYLON.PushMaterial {
  79778. private _diffuseTexture;
  79779. diffuseTexture: BABYLON.BaseTexture;
  79780. private _heightTexture;
  79781. heightTexture: BABYLON.BaseTexture;
  79782. diffuseColor: BABYLON.Color3;
  79783. furLength: number;
  79784. furAngle: number;
  79785. furColor: BABYLON.Color3;
  79786. furOffset: number;
  79787. furSpacing: number;
  79788. furGravity: BABYLON.Vector3;
  79789. furSpeed: number;
  79790. furDensity: number;
  79791. furOcclusion: number;
  79792. furTexture: BABYLON.DynamicTexture;
  79793. private _disableLighting;
  79794. disableLighting: boolean;
  79795. private _maxSimultaneousLights;
  79796. maxSimultaneousLights: number;
  79797. highLevelFur: boolean;
  79798. _meshes: BABYLON.AbstractMesh[];
  79799. private _renderId;
  79800. private _furTime;
  79801. constructor(name: string, scene: BABYLON.Scene);
  79802. get furTime(): number;
  79803. set furTime(furTime: number);
  79804. needAlphaBlending(): boolean;
  79805. needAlphaTesting(): boolean;
  79806. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79807. updateFur(): void;
  79808. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79809. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79810. getAnimatables(): BABYLON.IAnimatable[];
  79811. getActiveTextures(): BABYLON.BaseTexture[];
  79812. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79813. dispose(forceDisposeEffect?: boolean): void;
  79814. clone(name: string): FurMaterial;
  79815. serialize(): any;
  79816. getClassName(): string;
  79817. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79818. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79819. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79820. }
  79821. }
  79822. declare module BABYLON {
  79823. /** @hidden */
  79824. export var gradientPixelShader: {
  79825. name: string;
  79826. shader: string;
  79827. };
  79828. }
  79829. declare module BABYLON {
  79830. /** @hidden */
  79831. export var gradientVertexShader: {
  79832. name: string;
  79833. shader: string;
  79834. };
  79835. }
  79836. declare module BABYLON {
  79837. export class GradientMaterial extends BABYLON.PushMaterial {
  79838. private _maxSimultaneousLights;
  79839. maxSimultaneousLights: number;
  79840. topColor: BABYLON.Color3;
  79841. topColorAlpha: number;
  79842. bottomColor: BABYLON.Color3;
  79843. bottomColorAlpha: number;
  79844. offset: number;
  79845. scale: number;
  79846. smoothness: number;
  79847. private _disableLighting;
  79848. disableLighting: boolean;
  79849. private _renderId;
  79850. constructor(name: string, scene: BABYLON.Scene);
  79851. needAlphaBlending(): boolean;
  79852. needAlphaTesting(): boolean;
  79853. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79854. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79855. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79856. getAnimatables(): BABYLON.IAnimatable[];
  79857. dispose(forceDisposeEffect?: boolean): void;
  79858. clone(name: string): GradientMaterial;
  79859. serialize(): any;
  79860. getClassName(): string;
  79861. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79862. }
  79863. }
  79864. declare module BABYLON {
  79865. /** @hidden */
  79866. export var gridPixelShader: {
  79867. name: string;
  79868. shader: string;
  79869. };
  79870. }
  79871. declare module BABYLON {
  79872. /** @hidden */
  79873. export var gridVertexShader: {
  79874. name: string;
  79875. shader: string;
  79876. };
  79877. }
  79878. declare module BABYLON {
  79879. /**
  79880. * The grid materials allows you to wrap any shape with a grid.
  79881. * Colors are customizable.
  79882. */
  79883. export class GridMaterial extends BABYLON.PushMaterial {
  79884. /**
  79885. * Main color of the grid (e.g. between lines)
  79886. */
  79887. mainColor: BABYLON.Color3;
  79888. /**
  79889. * Color of the grid lines.
  79890. */
  79891. lineColor: BABYLON.Color3;
  79892. /**
  79893. * The scale of the grid compared to unit.
  79894. */
  79895. gridRatio: number;
  79896. /**
  79897. * Allows setting an offset for the grid lines.
  79898. */
  79899. gridOffset: BABYLON.Vector3;
  79900. /**
  79901. * The frequency of thicker lines.
  79902. */
  79903. majorUnitFrequency: number;
  79904. /**
  79905. * The visibility of minor units in the grid.
  79906. */
  79907. minorUnitVisibility: number;
  79908. /**
  79909. * The grid opacity outside of the lines.
  79910. */
  79911. opacity: number;
  79912. /**
  79913. * Determine RBG output is premultiplied by alpha value.
  79914. */
  79915. preMultiplyAlpha: boolean;
  79916. private _opacityTexture;
  79917. opacityTexture: BABYLON.BaseTexture;
  79918. private _gridControl;
  79919. private _renderId;
  79920. /**
  79921. * constructor
  79922. * @param name The name given to the material in order to identify it afterwards.
  79923. * @param scene The scene the material is used in.
  79924. */
  79925. constructor(name: string, scene: BABYLON.Scene);
  79926. /**
  79927. * Returns wehter or not the grid requires alpha blending.
  79928. */
  79929. needAlphaBlending(): boolean;
  79930. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79931. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79932. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79933. /**
  79934. * Dispose the material and its associated resources.
  79935. * @param forceDisposeEffect will also dispose the used effect when true
  79936. */
  79937. dispose(forceDisposeEffect?: boolean): void;
  79938. clone(name: string): GridMaterial;
  79939. serialize(): any;
  79940. getClassName(): string;
  79941. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79942. }
  79943. }
  79944. declare module BABYLON {
  79945. /** @hidden */
  79946. export var lavaPixelShader: {
  79947. name: string;
  79948. shader: string;
  79949. };
  79950. }
  79951. declare module BABYLON {
  79952. /** @hidden */
  79953. export var lavaVertexShader: {
  79954. name: string;
  79955. shader: string;
  79956. };
  79957. }
  79958. declare module BABYLON {
  79959. export class LavaMaterial extends BABYLON.PushMaterial {
  79960. private _diffuseTexture;
  79961. diffuseTexture: BABYLON.BaseTexture;
  79962. noiseTexture: BABYLON.BaseTexture;
  79963. fogColor: BABYLON.Color3;
  79964. speed: number;
  79965. movingSpeed: number;
  79966. lowFrequencySpeed: number;
  79967. fogDensity: number;
  79968. private _lastTime;
  79969. diffuseColor: BABYLON.Color3;
  79970. private _disableLighting;
  79971. disableLighting: boolean;
  79972. private _unlit;
  79973. unlit: boolean;
  79974. private _maxSimultaneousLights;
  79975. maxSimultaneousLights: number;
  79976. private _scaledDiffuse;
  79977. private _renderId;
  79978. constructor(name: string, scene: BABYLON.Scene);
  79979. needAlphaBlending(): boolean;
  79980. needAlphaTesting(): boolean;
  79981. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79982. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79983. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79984. getAnimatables(): BABYLON.IAnimatable[];
  79985. getActiveTextures(): BABYLON.BaseTexture[];
  79986. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79987. dispose(forceDisposeEffect?: boolean): void;
  79988. clone(name: string): LavaMaterial;
  79989. serialize(): any;
  79990. getClassName(): string;
  79991. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79992. }
  79993. }
  79994. declare module BABYLON {
  79995. /** @hidden */
  79996. export var mixPixelShader: {
  79997. name: string;
  79998. shader: string;
  79999. };
  80000. }
  80001. declare module BABYLON {
  80002. /** @hidden */
  80003. export var mixVertexShader: {
  80004. name: string;
  80005. shader: string;
  80006. };
  80007. }
  80008. declare module BABYLON {
  80009. export class MixMaterial extends BABYLON.PushMaterial {
  80010. /**
  80011. * Mix textures
  80012. */
  80013. private _mixTexture1;
  80014. mixTexture1: BABYLON.BaseTexture;
  80015. private _mixTexture2;
  80016. mixTexture2: BABYLON.BaseTexture;
  80017. /**
  80018. * Diffuse textures
  80019. */
  80020. private _diffuseTexture1;
  80021. diffuseTexture1: BABYLON.Texture;
  80022. private _diffuseTexture2;
  80023. diffuseTexture2: BABYLON.Texture;
  80024. private _diffuseTexture3;
  80025. diffuseTexture3: BABYLON.Texture;
  80026. private _diffuseTexture4;
  80027. diffuseTexture4: BABYLON.Texture;
  80028. private _diffuseTexture5;
  80029. diffuseTexture5: BABYLON.Texture;
  80030. private _diffuseTexture6;
  80031. diffuseTexture6: BABYLON.Texture;
  80032. private _diffuseTexture7;
  80033. diffuseTexture7: BABYLON.Texture;
  80034. private _diffuseTexture8;
  80035. diffuseTexture8: BABYLON.Texture;
  80036. /**
  80037. * Uniforms
  80038. */
  80039. diffuseColor: BABYLON.Color3;
  80040. specularColor: BABYLON.Color3;
  80041. specularPower: number;
  80042. private _disableLighting;
  80043. disableLighting: boolean;
  80044. private _maxSimultaneousLights;
  80045. maxSimultaneousLights: number;
  80046. private _renderId;
  80047. constructor(name: string, scene: BABYLON.Scene);
  80048. needAlphaBlending(): boolean;
  80049. needAlphaTesting(): boolean;
  80050. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80051. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80052. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80053. getAnimatables(): BABYLON.IAnimatable[];
  80054. getActiveTextures(): BABYLON.BaseTexture[];
  80055. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80056. dispose(forceDisposeEffect?: boolean): void;
  80057. clone(name: string): MixMaterial;
  80058. serialize(): any;
  80059. getClassName(): string;
  80060. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80061. }
  80062. }
  80063. declare module BABYLON {
  80064. /** @hidden */
  80065. export var normalPixelShader: {
  80066. name: string;
  80067. shader: string;
  80068. };
  80069. }
  80070. declare module BABYLON {
  80071. /** @hidden */
  80072. export var normalVertexShader: {
  80073. name: string;
  80074. shader: string;
  80075. };
  80076. }
  80077. declare module BABYLON {
  80078. export class NormalMaterial extends BABYLON.PushMaterial {
  80079. private _diffuseTexture;
  80080. diffuseTexture: BABYLON.BaseTexture;
  80081. diffuseColor: BABYLON.Color3;
  80082. private _disableLighting;
  80083. disableLighting: boolean;
  80084. private _maxSimultaneousLights;
  80085. maxSimultaneousLights: number;
  80086. private _renderId;
  80087. constructor(name: string, scene: BABYLON.Scene);
  80088. needAlphaBlending(): boolean;
  80089. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80090. needAlphaTesting(): boolean;
  80091. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80092. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80093. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80094. getAnimatables(): BABYLON.IAnimatable[];
  80095. getActiveTextures(): BABYLON.BaseTexture[];
  80096. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80097. dispose(forceDisposeEffect?: boolean): void;
  80098. clone(name: string): NormalMaterial;
  80099. serialize(): any;
  80100. getClassName(): string;
  80101. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80102. }
  80103. }
  80104. declare module BABYLON {
  80105. /** @hidden */
  80106. export var shadowOnlyPixelShader: {
  80107. name: string;
  80108. shader: string;
  80109. };
  80110. }
  80111. declare module BABYLON {
  80112. /** @hidden */
  80113. export var shadowOnlyVertexShader: {
  80114. name: string;
  80115. shader: string;
  80116. };
  80117. }
  80118. declare module BABYLON {
  80119. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80120. private _renderId;
  80121. private _activeLight;
  80122. constructor(name: string, scene: BABYLON.Scene);
  80123. shadowColor: BABYLON.Color3;
  80124. needAlphaBlending(): boolean;
  80125. needAlphaTesting(): boolean;
  80126. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80127. get activeLight(): BABYLON.IShadowLight;
  80128. set activeLight(light: BABYLON.IShadowLight);
  80129. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80130. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80131. clone(name: string): ShadowOnlyMaterial;
  80132. serialize(): any;
  80133. getClassName(): string;
  80134. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80135. }
  80136. }
  80137. declare module BABYLON {
  80138. /** @hidden */
  80139. export var simplePixelShader: {
  80140. name: string;
  80141. shader: string;
  80142. };
  80143. }
  80144. declare module BABYLON {
  80145. /** @hidden */
  80146. export var simpleVertexShader: {
  80147. name: string;
  80148. shader: string;
  80149. };
  80150. }
  80151. declare module BABYLON {
  80152. export class SimpleMaterial extends BABYLON.PushMaterial {
  80153. private _diffuseTexture;
  80154. diffuseTexture: BABYLON.BaseTexture;
  80155. diffuseColor: BABYLON.Color3;
  80156. private _disableLighting;
  80157. disableLighting: boolean;
  80158. private _maxSimultaneousLights;
  80159. maxSimultaneousLights: number;
  80160. private _renderId;
  80161. constructor(name: string, scene: BABYLON.Scene);
  80162. needAlphaBlending(): boolean;
  80163. needAlphaTesting(): boolean;
  80164. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80165. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80166. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80167. getAnimatables(): BABYLON.IAnimatable[];
  80168. getActiveTextures(): BABYLON.BaseTexture[];
  80169. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80170. dispose(forceDisposeEffect?: boolean): void;
  80171. clone(name: string): SimpleMaterial;
  80172. serialize(): any;
  80173. getClassName(): string;
  80174. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80175. }
  80176. }
  80177. declare module BABYLON {
  80178. /** @hidden */
  80179. export var skyPixelShader: {
  80180. name: string;
  80181. shader: string;
  80182. };
  80183. }
  80184. declare module BABYLON {
  80185. /** @hidden */
  80186. export var skyVertexShader: {
  80187. name: string;
  80188. shader: string;
  80189. };
  80190. }
  80191. declare module BABYLON {
  80192. /**
  80193. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80194. * @see https://doc.babylonjs.com/extensions/sky
  80195. */
  80196. export class SkyMaterial extends BABYLON.PushMaterial {
  80197. /**
  80198. * Defines the overall luminance of sky in interval ]0, 1[.
  80199. */
  80200. luminance: number;
  80201. /**
  80202. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80203. */
  80204. turbidity: number;
  80205. /**
  80206. * Defines the sky appearance (light intensity).
  80207. */
  80208. rayleigh: number;
  80209. /**
  80210. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80211. */
  80212. mieCoefficient: number;
  80213. /**
  80214. * Defines the amount of haze particles following the Mie scattering theory.
  80215. */
  80216. mieDirectionalG: number;
  80217. /**
  80218. * Defines the distance of the sun according to the active scene camera.
  80219. */
  80220. distance: number;
  80221. /**
  80222. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80223. * "inclined".
  80224. */
  80225. inclination: number;
  80226. /**
  80227. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80228. * an object direction and a reference direction.
  80229. */
  80230. azimuth: number;
  80231. /**
  80232. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80233. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80234. */
  80235. sunPosition: BABYLON.Vector3;
  80236. /**
  80237. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80238. * .sunPosition property.
  80239. */
  80240. useSunPosition: boolean;
  80241. /**
  80242. * Defines an offset vector used to get a horizon offset.
  80243. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80244. */
  80245. cameraOffset: BABYLON.Vector3;
  80246. private _cameraPosition;
  80247. private _renderId;
  80248. /**
  80249. * Instantiates a new sky material.
  80250. * This material allows to create dynamic and texture free
  80251. * effects for skyboxes by taking care of the atmosphere state.
  80252. * @see https://doc.babylonjs.com/extensions/sky
  80253. * @param name Define the name of the material in the scene
  80254. * @param scene Define the scene the material belong to
  80255. */
  80256. constructor(name: string, scene: BABYLON.Scene);
  80257. /**
  80258. * Specifies if the material will require alpha blending
  80259. * @returns a boolean specifying if alpha blending is needed
  80260. */
  80261. needAlphaBlending(): boolean;
  80262. /**
  80263. * Specifies if this material should be rendered in alpha test mode
  80264. * @returns false as the sky material doesn't need alpha testing.
  80265. */
  80266. needAlphaTesting(): boolean;
  80267. /**
  80268. * Get the texture used for alpha test purpose.
  80269. * @returns null as the sky material has no texture.
  80270. */
  80271. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80272. /**
  80273. * Get if the submesh is ready to be used and all its information available.
  80274. * Child classes can use it to update shaders
  80275. * @param mesh defines the mesh to check
  80276. * @param subMesh defines which submesh to check
  80277. * @param useInstances specifies that instances should be used
  80278. * @returns a boolean indicating that the submesh is ready or not
  80279. */
  80280. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80281. /**
  80282. * Binds the submesh to this material by preparing the effect and shader to draw
  80283. * @param world defines the world transformation matrix
  80284. * @param mesh defines the mesh containing the submesh
  80285. * @param subMesh defines the submesh to bind the material to
  80286. */
  80287. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80288. /**
  80289. * Get the list of animatables in the material.
  80290. * @returns the list of animatables object used in the material
  80291. */
  80292. getAnimatables(): BABYLON.IAnimatable[];
  80293. /**
  80294. * Disposes the material
  80295. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80296. */
  80297. dispose(forceDisposeEffect?: boolean): void;
  80298. /**
  80299. * Makes a duplicate of the material, and gives it a new name
  80300. * @param name defines the new name for the duplicated material
  80301. * @returns the cloned material
  80302. */
  80303. clone(name: string): SkyMaterial;
  80304. /**
  80305. * Serializes this material in a JSON representation
  80306. * @returns the serialized material object
  80307. */
  80308. serialize(): any;
  80309. /**
  80310. * Gets the current class name of the material e.g. "SkyMaterial"
  80311. * Mainly use in serialization.
  80312. * @returns the class name
  80313. */
  80314. getClassName(): string;
  80315. /**
  80316. * Creates a sky material from parsed material data
  80317. * @param source defines the JSON representation of the material
  80318. * @param scene defines the hosting scene
  80319. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80320. * @returns a new sky material
  80321. */
  80322. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80323. }
  80324. }
  80325. declare module BABYLON {
  80326. /** @hidden */
  80327. export var terrainPixelShader: {
  80328. name: string;
  80329. shader: string;
  80330. };
  80331. }
  80332. declare module BABYLON {
  80333. /** @hidden */
  80334. export var terrainVertexShader: {
  80335. name: string;
  80336. shader: string;
  80337. };
  80338. }
  80339. declare module BABYLON {
  80340. export class TerrainMaterial extends BABYLON.PushMaterial {
  80341. private _mixTexture;
  80342. mixTexture: BABYLON.BaseTexture;
  80343. private _diffuseTexture1;
  80344. diffuseTexture1: BABYLON.Texture;
  80345. private _diffuseTexture2;
  80346. diffuseTexture2: BABYLON.Texture;
  80347. private _diffuseTexture3;
  80348. diffuseTexture3: BABYLON.Texture;
  80349. private _bumpTexture1;
  80350. bumpTexture1: BABYLON.Texture;
  80351. private _bumpTexture2;
  80352. bumpTexture2: BABYLON.Texture;
  80353. private _bumpTexture3;
  80354. bumpTexture3: BABYLON.Texture;
  80355. diffuseColor: BABYLON.Color3;
  80356. specularColor: BABYLON.Color3;
  80357. specularPower: number;
  80358. private _disableLighting;
  80359. disableLighting: boolean;
  80360. private _maxSimultaneousLights;
  80361. maxSimultaneousLights: number;
  80362. private _renderId;
  80363. constructor(name: string, scene: BABYLON.Scene);
  80364. needAlphaBlending(): boolean;
  80365. needAlphaTesting(): boolean;
  80366. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80367. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80368. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80369. getAnimatables(): BABYLON.IAnimatable[];
  80370. getActiveTextures(): BABYLON.BaseTexture[];
  80371. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80372. dispose(forceDisposeEffect?: boolean): void;
  80373. clone(name: string): TerrainMaterial;
  80374. serialize(): any;
  80375. getClassName(): string;
  80376. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80377. }
  80378. }
  80379. declare module BABYLON {
  80380. /** @hidden */
  80381. export var triplanarPixelShader: {
  80382. name: string;
  80383. shader: string;
  80384. };
  80385. }
  80386. declare module BABYLON {
  80387. /** @hidden */
  80388. export var triplanarVertexShader: {
  80389. name: string;
  80390. shader: string;
  80391. };
  80392. }
  80393. declare module BABYLON {
  80394. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80395. mixTexture: BABYLON.BaseTexture;
  80396. private _diffuseTextureX;
  80397. diffuseTextureX: BABYLON.BaseTexture;
  80398. private _diffuseTextureY;
  80399. diffuseTextureY: BABYLON.BaseTexture;
  80400. private _diffuseTextureZ;
  80401. diffuseTextureZ: BABYLON.BaseTexture;
  80402. private _normalTextureX;
  80403. normalTextureX: BABYLON.BaseTexture;
  80404. private _normalTextureY;
  80405. normalTextureY: BABYLON.BaseTexture;
  80406. private _normalTextureZ;
  80407. normalTextureZ: BABYLON.BaseTexture;
  80408. tileSize: number;
  80409. diffuseColor: BABYLON.Color3;
  80410. specularColor: BABYLON.Color3;
  80411. specularPower: number;
  80412. private _disableLighting;
  80413. disableLighting: boolean;
  80414. private _maxSimultaneousLights;
  80415. maxSimultaneousLights: number;
  80416. private _renderId;
  80417. constructor(name: string, scene: BABYLON.Scene);
  80418. needAlphaBlending(): boolean;
  80419. needAlphaTesting(): boolean;
  80420. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80421. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80422. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80423. getAnimatables(): BABYLON.IAnimatable[];
  80424. getActiveTextures(): BABYLON.BaseTexture[];
  80425. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80426. dispose(forceDisposeEffect?: boolean): void;
  80427. clone(name: string): TriPlanarMaterial;
  80428. serialize(): any;
  80429. getClassName(): string;
  80430. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80431. }
  80432. }
  80433. declare module BABYLON {
  80434. /** @hidden */
  80435. export var waterPixelShader: {
  80436. name: string;
  80437. shader: string;
  80438. };
  80439. }
  80440. declare module BABYLON {
  80441. /** @hidden */
  80442. export var waterVertexShader: {
  80443. name: string;
  80444. shader: string;
  80445. };
  80446. }
  80447. declare module BABYLON {
  80448. export class WaterMaterial extends BABYLON.PushMaterial {
  80449. renderTargetSize: BABYLON.Vector2;
  80450. private _bumpTexture;
  80451. bumpTexture: BABYLON.BaseTexture;
  80452. diffuseColor: BABYLON.Color3;
  80453. specularColor: BABYLON.Color3;
  80454. specularPower: number;
  80455. private _disableLighting;
  80456. disableLighting: boolean;
  80457. private _maxSimultaneousLights;
  80458. maxSimultaneousLights: number;
  80459. /**
  80460. * @param {number}: Represents the wind force
  80461. */
  80462. windForce: number;
  80463. /**
  80464. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80465. */
  80466. windDirection: BABYLON.Vector2;
  80467. /**
  80468. * @param {number}: Wave height, represents the height of the waves
  80469. */
  80470. waveHeight: number;
  80471. /**
  80472. * @param {number}: Bump height, represents the bump height related to the bump map
  80473. */
  80474. bumpHeight: number;
  80475. /**
  80476. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80477. */
  80478. private _bumpSuperimpose;
  80479. bumpSuperimpose: boolean;
  80480. /**
  80481. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80482. */
  80483. private _fresnelSeparate;
  80484. fresnelSeparate: boolean;
  80485. /**
  80486. * @param {boolean}: bump Waves modify the reflection.
  80487. */
  80488. private _bumpAffectsReflection;
  80489. bumpAffectsReflection: boolean;
  80490. /**
  80491. * @param {number}: The water color blended with the refraction (near)
  80492. */
  80493. waterColor: BABYLON.Color3;
  80494. /**
  80495. * @param {number}: The blend factor related to the water color
  80496. */
  80497. colorBlendFactor: number;
  80498. /**
  80499. * @param {number}: The water color blended with the reflection (far)
  80500. */
  80501. waterColor2: BABYLON.Color3;
  80502. /**
  80503. * @param {number}: The blend factor related to the water color (reflection, far)
  80504. */
  80505. colorBlendFactor2: number;
  80506. /**
  80507. * @param {number}: Represents the maximum length of a wave
  80508. */
  80509. waveLength: number;
  80510. /**
  80511. * @param {number}: Defines the waves speed
  80512. */
  80513. waveSpeed: number;
  80514. /**
  80515. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80516. * will avoid calculating useless pixels in the pixel shader of the water material.
  80517. */
  80518. disableClipPlane: boolean;
  80519. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80520. private _mesh;
  80521. private _refractionRTT;
  80522. private _reflectionRTT;
  80523. private _reflectionTransform;
  80524. private _lastTime;
  80525. private _lastDeltaTime;
  80526. private _renderId;
  80527. private _useLogarithmicDepth;
  80528. private _waitingRenderList;
  80529. private _imageProcessingConfiguration;
  80530. private _imageProcessingObserver;
  80531. /**
  80532. * Gets a boolean indicating that current material needs to register RTT
  80533. */
  80534. get hasRenderTargetTextures(): boolean;
  80535. /**
  80536. * Constructor
  80537. */
  80538. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80539. get useLogarithmicDepth(): boolean;
  80540. set useLogarithmicDepth(value: boolean);
  80541. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80542. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80543. addToRenderList(node: any): void;
  80544. enableRenderTargets(enable: boolean): void;
  80545. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80546. get renderTargetsEnabled(): boolean;
  80547. needAlphaBlending(): boolean;
  80548. needAlphaTesting(): boolean;
  80549. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80550. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80551. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80552. private _createRenderTargets;
  80553. getAnimatables(): BABYLON.IAnimatable[];
  80554. getActiveTextures(): BABYLON.BaseTexture[];
  80555. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80556. dispose(forceDisposeEffect?: boolean): void;
  80557. clone(name: string): WaterMaterial;
  80558. serialize(): any;
  80559. getClassName(): string;
  80560. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80561. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80562. }
  80563. }
  80564. declare module BABYLON {
  80565. /** @hidden */
  80566. export var asciiartPixelShader: {
  80567. name: string;
  80568. shader: string;
  80569. };
  80570. }
  80571. declare module BABYLON {
  80572. /**
  80573. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80574. *
  80575. * It basically takes care rendering the font front the given font size to a texture.
  80576. * This is used later on in the postprocess.
  80577. */
  80578. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80579. private _font;
  80580. private _text;
  80581. private _charSize;
  80582. /**
  80583. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80584. */
  80585. get charSize(): number;
  80586. /**
  80587. * Create a new instance of the Ascii Art FontTexture class
  80588. * @param name the name of the texture
  80589. * @param font the font to use, use the W3C CSS notation
  80590. * @param text the caracter set to use in the rendering.
  80591. * @param scene the scene that owns the texture
  80592. */
  80593. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80594. /**
  80595. * Gets the max char width of a font.
  80596. * @param font the font to use, use the W3C CSS notation
  80597. * @return the max char width
  80598. */
  80599. private getFontWidth;
  80600. /**
  80601. * Gets the max char height of a font.
  80602. * @param font the font to use, use the W3C CSS notation
  80603. * @return the max char height
  80604. */
  80605. private getFontHeight;
  80606. /**
  80607. * Clones the current AsciiArtTexture.
  80608. * @return the clone of the texture.
  80609. */
  80610. clone(): AsciiArtFontTexture;
  80611. /**
  80612. * Parses a json object representing the texture and returns an instance of it.
  80613. * @param source the source JSON representation
  80614. * @param scene the scene to create the texture for
  80615. * @return the parsed texture
  80616. */
  80617. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80618. }
  80619. /**
  80620. * Option available in the Ascii Art Post Process.
  80621. */
  80622. export interface IAsciiArtPostProcessOptions {
  80623. /**
  80624. * The font to use following the w3c font definition.
  80625. */
  80626. font?: string;
  80627. /**
  80628. * The character set to use in the postprocess.
  80629. */
  80630. characterSet?: string;
  80631. /**
  80632. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80633. * This number is defined between 0 and 1;
  80634. */
  80635. mixToTile?: number;
  80636. /**
  80637. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80638. * This number is defined between 0 and 1;
  80639. */
  80640. mixToNormal?: number;
  80641. }
  80642. /**
  80643. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80644. *
  80645. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80646. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80647. */
  80648. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80649. /**
  80650. * The font texture used to render the char in the post process.
  80651. */
  80652. private _asciiArtFontTexture;
  80653. /**
  80654. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80655. * This number is defined between 0 and 1;
  80656. */
  80657. mixToTile: number;
  80658. /**
  80659. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80660. * This number is defined between 0 and 1;
  80661. */
  80662. mixToNormal: number;
  80663. /**
  80664. * Instantiates a new Ascii Art Post Process.
  80665. * @param name the name to give to the postprocess
  80666. * @camera the camera to apply the post process to.
  80667. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80668. */
  80669. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80670. }
  80671. }
  80672. declare module BABYLON {
  80673. /** @hidden */
  80674. export var digitalrainPixelShader: {
  80675. name: string;
  80676. shader: string;
  80677. };
  80678. }
  80679. declare module BABYLON {
  80680. /**
  80681. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80682. *
  80683. * It basically takes care rendering the font front the given font size to a texture.
  80684. * This is used later on in the postprocess.
  80685. */
  80686. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80687. private _font;
  80688. private _text;
  80689. private _charSize;
  80690. /**
  80691. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80692. */
  80693. get charSize(): number;
  80694. /**
  80695. * Create a new instance of the Digital Rain FontTexture class
  80696. * @param name the name of the texture
  80697. * @param font the font to use, use the W3C CSS notation
  80698. * @param text the caracter set to use in the rendering.
  80699. * @param scene the scene that owns the texture
  80700. */
  80701. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80702. /**
  80703. * Gets the max char width of a font.
  80704. * @param font the font to use, use the W3C CSS notation
  80705. * @return the max char width
  80706. */
  80707. private getFontWidth;
  80708. /**
  80709. * Gets the max char height of a font.
  80710. * @param font the font to use, use the W3C CSS notation
  80711. * @return the max char height
  80712. */
  80713. private getFontHeight;
  80714. /**
  80715. * Clones the current DigitalRainFontTexture.
  80716. * @return the clone of the texture.
  80717. */
  80718. clone(): DigitalRainFontTexture;
  80719. /**
  80720. * Parses a json object representing the texture and returns an instance of it.
  80721. * @param source the source JSON representation
  80722. * @param scene the scene to create the texture for
  80723. * @return the parsed texture
  80724. */
  80725. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80726. }
  80727. /**
  80728. * Option available in the Digital Rain Post Process.
  80729. */
  80730. export interface IDigitalRainPostProcessOptions {
  80731. /**
  80732. * The font to use following the w3c font definition.
  80733. */
  80734. font?: string;
  80735. /**
  80736. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80737. * This number is defined between 0 and 1;
  80738. */
  80739. mixToTile?: number;
  80740. /**
  80741. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80742. * This number is defined between 0 and 1;
  80743. */
  80744. mixToNormal?: number;
  80745. }
  80746. /**
  80747. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80748. *
  80749. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80750. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80751. */
  80752. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80753. /**
  80754. * The font texture used to render the char in the post process.
  80755. */
  80756. private _digitalRainFontTexture;
  80757. /**
  80758. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80759. * This number is defined between 0 and 1;
  80760. */
  80761. mixToTile: number;
  80762. /**
  80763. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80764. * This number is defined between 0 and 1;
  80765. */
  80766. mixToNormal: number;
  80767. /**
  80768. * Instantiates a new Digital Rain Post Process.
  80769. * @param name the name to give to the postprocess
  80770. * @camera the camera to apply the post process to.
  80771. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80772. */
  80773. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80774. }
  80775. }
  80776. declare module BABYLON {
  80777. /** @hidden */
  80778. export var brickProceduralTexturePixelShader: {
  80779. name: string;
  80780. shader: string;
  80781. };
  80782. }
  80783. declare module BABYLON {
  80784. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80785. private _numberOfBricksHeight;
  80786. private _numberOfBricksWidth;
  80787. private _jointColor;
  80788. private _brickColor;
  80789. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80790. updateShaderUniforms(): void;
  80791. get numberOfBricksHeight(): number;
  80792. set numberOfBricksHeight(value: number);
  80793. get numberOfBricksWidth(): number;
  80794. set numberOfBricksWidth(value: number);
  80795. get jointColor(): BABYLON.Color3;
  80796. set jointColor(value: BABYLON.Color3);
  80797. get brickColor(): BABYLON.Color3;
  80798. set brickColor(value: BABYLON.Color3);
  80799. /**
  80800. * Serializes this brick procedural texture
  80801. * @returns a serialized brick procedural texture object
  80802. */
  80803. serialize(): any;
  80804. /**
  80805. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80806. * @param parsedTexture defines parsed texture data
  80807. * @param scene defines the current scene
  80808. * @param rootUrl defines the root URL containing brick procedural texture information
  80809. * @returns a parsed Brick Procedural BABYLON.Texture
  80810. */
  80811. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80812. }
  80813. }
  80814. declare module BABYLON {
  80815. /** @hidden */
  80816. export var cloudProceduralTexturePixelShader: {
  80817. name: string;
  80818. shader: string;
  80819. };
  80820. }
  80821. declare module BABYLON {
  80822. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80823. private _skyColor;
  80824. private _cloudColor;
  80825. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80826. updateShaderUniforms(): void;
  80827. get skyColor(): BABYLON.Color4;
  80828. set skyColor(value: BABYLON.Color4);
  80829. get cloudColor(): BABYLON.Color4;
  80830. set cloudColor(value: BABYLON.Color4);
  80831. /**
  80832. * Serializes this cloud procedural texture
  80833. * @returns a serialized cloud procedural texture object
  80834. */
  80835. serialize(): any;
  80836. /**
  80837. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80838. * @param parsedTexture defines parsed texture data
  80839. * @param scene defines the current scene
  80840. * @param rootUrl defines the root URL containing cloud procedural texture information
  80841. * @returns a parsed Cloud Procedural BABYLON.Texture
  80842. */
  80843. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80844. }
  80845. }
  80846. declare module BABYLON {
  80847. /** @hidden */
  80848. export var fireProceduralTexturePixelShader: {
  80849. name: string;
  80850. shader: string;
  80851. };
  80852. }
  80853. declare module BABYLON {
  80854. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80855. private _time;
  80856. private _speed;
  80857. private _autoGenerateTime;
  80858. private _fireColors;
  80859. private _alphaThreshold;
  80860. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80861. updateShaderUniforms(): void;
  80862. render(useCameraPostProcess?: boolean): void;
  80863. static get PurpleFireColors(): BABYLON.Color3[];
  80864. static get GreenFireColors(): BABYLON.Color3[];
  80865. static get RedFireColors(): BABYLON.Color3[];
  80866. static get BlueFireColors(): BABYLON.Color3[];
  80867. get autoGenerateTime(): boolean;
  80868. set autoGenerateTime(value: boolean);
  80869. get fireColors(): BABYLON.Color3[];
  80870. set fireColors(value: BABYLON.Color3[]);
  80871. get time(): number;
  80872. set time(value: number);
  80873. get speed(): BABYLON.Vector2;
  80874. set speed(value: BABYLON.Vector2);
  80875. get alphaThreshold(): number;
  80876. set alphaThreshold(value: number);
  80877. /**
  80878. * Serializes this fire procedural texture
  80879. * @returns a serialized fire procedural texture object
  80880. */
  80881. serialize(): any;
  80882. /**
  80883. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  80884. * @param parsedTexture defines parsed texture data
  80885. * @param scene defines the current scene
  80886. * @param rootUrl defines the root URL containing fire procedural texture information
  80887. * @returns a parsed Fire Procedural BABYLON.Texture
  80888. */
  80889. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  80890. }
  80891. }
  80892. declare module BABYLON {
  80893. /** @hidden */
  80894. export var grassProceduralTexturePixelShader: {
  80895. name: string;
  80896. shader: string;
  80897. };
  80898. }
  80899. declare module BABYLON {
  80900. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  80901. private _grassColors;
  80902. private _groundColor;
  80903. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80904. updateShaderUniforms(): void;
  80905. get grassColors(): BABYLON.Color3[];
  80906. set grassColors(value: BABYLON.Color3[]);
  80907. get groundColor(): BABYLON.Color3;
  80908. set groundColor(value: BABYLON.Color3);
  80909. /**
  80910. * Serializes this grass procedural texture
  80911. * @returns a serialized grass procedural texture object
  80912. */
  80913. serialize(): any;
  80914. /**
  80915. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  80916. * @param parsedTexture defines parsed texture data
  80917. * @param scene defines the current scene
  80918. * @param rootUrl defines the root URL containing grass procedural texture information
  80919. * @returns a parsed Grass Procedural BABYLON.Texture
  80920. */
  80921. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80922. }
  80923. }
  80924. declare module BABYLON {
  80925. /** @hidden */
  80926. export var marbleProceduralTexturePixelShader: {
  80927. name: string;
  80928. shader: string;
  80929. };
  80930. }
  80931. declare module BABYLON {
  80932. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80933. private _numberOfTilesHeight;
  80934. private _numberOfTilesWidth;
  80935. private _amplitude;
  80936. private _jointColor;
  80937. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80938. updateShaderUniforms(): void;
  80939. get numberOfTilesHeight(): number;
  80940. set numberOfTilesHeight(value: number);
  80941. get amplitude(): number;
  80942. set amplitude(value: number);
  80943. get numberOfTilesWidth(): number;
  80944. set numberOfTilesWidth(value: number);
  80945. get jointColor(): BABYLON.Color3;
  80946. set jointColor(value: BABYLON.Color3);
  80947. /**
  80948. * Serializes this marble procedural texture
  80949. * @returns a serialized marble procedural texture object
  80950. */
  80951. serialize(): any;
  80952. /**
  80953. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80954. * @param parsedTexture defines parsed texture data
  80955. * @param scene defines the current scene
  80956. * @param rootUrl defines the root URL containing marble procedural texture information
  80957. * @returns a parsed Marble Procedural BABYLON.Texture
  80958. */
  80959. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80960. }
  80961. }
  80962. declare module BABYLON {
  80963. /** @hidden */
  80964. export var normalMapProceduralTexturePixelShader: {
  80965. name: string;
  80966. shader: string;
  80967. };
  80968. }
  80969. declare module BABYLON {
  80970. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80971. private _baseTexture;
  80972. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80973. updateShaderUniforms(): void;
  80974. render(useCameraPostProcess?: boolean): void;
  80975. resize(size: any, generateMipMaps: any): void;
  80976. get baseTexture(): BABYLON.Texture;
  80977. set baseTexture(texture: BABYLON.Texture);
  80978. /**
  80979. * Serializes this normal map procedural texture
  80980. * @returns a serialized normal map procedural texture object
  80981. */
  80982. serialize(): any;
  80983. /**
  80984. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80985. * @param parsedTexture defines parsed texture data
  80986. * @param scene defines the current scene
  80987. * @param rootUrl defines the root URL containing normal map procedural texture information
  80988. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80989. */
  80990. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80991. }
  80992. }
  80993. declare module BABYLON {
  80994. /** @hidden */
  80995. export var perlinNoiseProceduralTexturePixelShader: {
  80996. name: string;
  80997. shader: string;
  80998. };
  80999. }
  81000. declare module BABYLON {
  81001. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  81002. time: number;
  81003. timeScale: number;
  81004. translationSpeed: number;
  81005. private _currentTranslation;
  81006. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81007. updateShaderUniforms(): void;
  81008. render(useCameraPostProcess?: boolean): void;
  81009. resize(size: any, generateMipMaps: any): void;
  81010. /**
  81011. * Serializes this perlin noise procedural texture
  81012. * @returns a serialized perlin noise procedural texture object
  81013. */
  81014. serialize(): any;
  81015. /**
  81016. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  81017. * @param parsedTexture defines parsed texture data
  81018. * @param scene defines the current scene
  81019. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  81020. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  81021. */
  81022. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  81023. }
  81024. }
  81025. declare module BABYLON {
  81026. /** @hidden */
  81027. export var roadProceduralTexturePixelShader: {
  81028. name: string;
  81029. shader: string;
  81030. };
  81031. }
  81032. declare module BABYLON {
  81033. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  81034. private _roadColor;
  81035. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81036. updateShaderUniforms(): void;
  81037. get roadColor(): BABYLON.Color3;
  81038. set roadColor(value: BABYLON.Color3);
  81039. /**
  81040. * Serializes this road procedural texture
  81041. * @returns a serialized road procedural texture object
  81042. */
  81043. serialize(): any;
  81044. /**
  81045. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  81046. * @param parsedTexture defines parsed texture data
  81047. * @param scene defines the current scene
  81048. * @param rootUrl defines the root URL containing road procedural texture information
  81049. * @returns a parsed Road Procedural BABYLON.Texture
  81050. */
  81051. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  81052. }
  81053. }
  81054. declare module BABYLON {
  81055. /** @hidden */
  81056. export var starfieldProceduralTexturePixelShader: {
  81057. name: string;
  81058. shader: string;
  81059. };
  81060. }
  81061. declare module BABYLON {
  81062. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  81063. private _time;
  81064. private _alpha;
  81065. private _beta;
  81066. private _zoom;
  81067. private _formuparam;
  81068. private _stepsize;
  81069. private _tile;
  81070. private _brightness;
  81071. private _darkmatter;
  81072. private _distfading;
  81073. private _saturation;
  81074. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81075. updateShaderUniforms(): void;
  81076. get time(): number;
  81077. set time(value: number);
  81078. get alpha(): number;
  81079. set alpha(value: number);
  81080. get beta(): number;
  81081. set beta(value: number);
  81082. get formuparam(): number;
  81083. set formuparam(value: number);
  81084. get stepsize(): number;
  81085. set stepsize(value: number);
  81086. get zoom(): number;
  81087. set zoom(value: number);
  81088. get tile(): number;
  81089. set tile(value: number);
  81090. get brightness(): number;
  81091. set brightness(value: number);
  81092. get darkmatter(): number;
  81093. set darkmatter(value: number);
  81094. get distfading(): number;
  81095. set distfading(value: number);
  81096. get saturation(): number;
  81097. set saturation(value: number);
  81098. /**
  81099. * Serializes this starfield procedural texture
  81100. * @returns a serialized starfield procedural texture object
  81101. */
  81102. serialize(): any;
  81103. /**
  81104. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  81105. * @param parsedTexture defines parsed texture data
  81106. * @param scene defines the current scene
  81107. * @param rootUrl defines the root URL containing startfield procedural texture information
  81108. * @returns a parsed Starfield Procedural BABYLON.Texture
  81109. */
  81110. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  81111. }
  81112. }
  81113. declare module BABYLON {
  81114. /** @hidden */
  81115. export var woodProceduralTexturePixelShader: {
  81116. name: string;
  81117. shader: string;
  81118. };
  81119. }
  81120. declare module BABYLON {
  81121. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  81122. private _ampScale;
  81123. private _woodColor;
  81124. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81125. updateShaderUniforms(): void;
  81126. get ampScale(): number;
  81127. set ampScale(value: number);
  81128. get woodColor(): BABYLON.Color3;
  81129. set woodColor(value: BABYLON.Color3);
  81130. /**
  81131. * Serializes this wood procedural texture
  81132. * @returns a serialized wood procedural texture object
  81133. */
  81134. serialize(): any;
  81135. /**
  81136. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  81137. * @param parsedTexture defines parsed texture data
  81138. * @param scene defines the current scene
  81139. * @param rootUrl defines the root URL containing wood procedural texture information
  81140. * @returns a parsed Wood Procedural BABYLON.Texture
  81141. */
  81142. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  81143. }
  81144. }